Agent Skills › keychat-io/keychat-app

keychat-io/keychat-app

GitHub

阐述Keychat安全消息应用的架构,涵盖Nostr、Signal、MLS及Ecash等核心技术,解析Flutter包结构、GetX状态管理、Isar数据库及Rust FFI桥接机制,并说明端到端加密的消息流转流程。

11 skills 100

Install All Skills

npx skills add keychat-io/keychat-app --all -g -y
More Options

List skills in collection

npx skills add keychat-io/keychat-app --list

Skills in Collection (11)

阐述Keychat安全消息应用的架构,涵盖Nostr、Signal、MLS及Ecash等核心技术,解析Flutter包结构、GetX状态管理、Isar数据库及Rust FFI桥接机制,并说明端到端加密的消息流转流程。
询问Keychat应用架构 解释代码库组件 了解消息加密与发送流程
.claude/skills/architecture/SKILL.md
npx skills add keychat-io/keychat-app --skill architecture -g -y
SKILL.md
Frontmatter
{
    "name": "architecture",
    "description": "Explains the Keychat app architecture and key components",
    "user-invocable": true,
    "disable-model-invocation": false
}

Keychat is a secure messaging app with a unique architecture. When explaining or working with the codebase, understand these key components:

Core Technologies

Technology Purpose Implementation
Nostr Protocol Message delivery/storage lib/nostr-core/, WebSocket connections
Signal Protocol 1:1 E2E encryption api_signal.rs via FFI
MLS Protocol Group E2E encryption api_mls.rs via FFI
Bitcoin Ecash Micropayments to relays api_cashu.rs, keychat_ecash/

Package Structure

packages/
├── app/                    # Main Flutter app
├── keychat_ecash/          # Ecash wallet functionality
└── keychat_rust_ffi_plugin/ # Native crypto via Rust

Key Services (packages/app/lib/service/)

  • signal_chat.service.dart - Signal protocol session management
  • mls_group.service.dart - MLS group key operations
  • websocket.service.dart - Nostr relay connections
  • chat.service.dart - High-level message routing
  • relay.service.dart - Relay management
  • identity.service.dart - User identity management

State Management

Uses GetX pattern:

  • Controllers in lib/controller/
  • Services are singleton instances
  • Reactive state with .obs observables

Database

Uses Isar (NoSQL for Flutter):

  • Models in lib/models/
  • Models use @collection annotation
  • Generated code via build_runner (*.g.dart, *.isar.dart)

Rust FFI Bridge

Native crypto operations use flutter_rust_bridge:

  • Rust code: packages/keychat_rust_ffi_plugin/rust/src/
  • Generated Dart bindings: packages/keychat_rust_ffi_plugin/lib/
  • Key APIs: Cashu, Nostr, Signal, MLS

Message Flow

  1. User composes message
  2. Signal/MLS encrypts content
  3. Message wrapped in Nostr event
  4. Ecash stamp attached (if relay requires payment)
  5. Sent via WebSocket to Nostr relay
  6. Recipient receives, decrypts, displays
协调跨代码库的大规模变更,通过并行隔离工作区代理执行。适用于需同时对多个文件或模块应用相似更改的场景,支持计划审批、并行执行及结果汇总。
需要对大量文件进行批量修改 涉及多模块的并行重构或统一调整
.claude/skills/batch/SKILL.md
npx skills add keychat-io/keychat-app --skill batch -g -y
SKILL.md
Frontmatter
{
    "name": "batch",
    "invoke": "user",
    "description": "Orchestrate large-scale changes across the codebase using parallel worktree agents. Use when you need to apply similar changes to many files or modules simultaneously."
}

Batch

Research and plan a large-scale change, then execute it in parallel across isolated worktree agents.

Workflow

Phase 1: Research & Plan

  1. Understand the requested change thoroughly
  2. Identify all files and modules that need modification
  3. Group changes into independent, parallelizable units (max 10 units)
  4. Present the plan to the user for approval before proceeding

Phase 2: Execute

  1. For each unit of work, launch an Agent with isolation: "worktree" to make the changes independently
  2. Run agents in parallel where possible (up to 5 concurrent agents)
  3. Each agent should:
    • Make the required changes
    • Run relevant tests or lint checks
    • Commit changes with a clear message

Phase 3: Review & Merge

  1. Collect results from all agents
  2. Report successes and failures
  3. For successful changes, present diffs for user review
  4. Help merge changes back to the main branch

Rules

  • Always get user approval before executing changes
  • Never modify more than what was requested
  • If a unit fails, continue with others and report the failure
  • Keep the user informed of progress throughout
用于从零初始化或重置 Keychat 开发环境。通过更新 git 子模块、安装指定版本 melos、执行 bootstrap 命令并检查配置 .env 文件,确保所有依赖正确解析且环境就绪。
初始化 Keychat 项目 重置开发环境
.claude/skills/bootstrap/SKILL.md
npx skills add keychat-io/keychat-app --skill bootstrap -g -y
SKILL.md
Frontmatter
{
    "name": "bootstrap",
    "description": "Initialize or reset the Keychat development environment",
    "allowed-tools": "Bash(git *), Bash(melos *), Bash(dart pub *)",
    "disable-model-invocation": true
}

Set up the Keychat development environment from scratch.

Steps

  1. Update git submodules

    git submodule update --init --recursive
    
  2. Ensure melos is installed

    dart pub global activate melos 7.3.0
    
  3. Bootstrap all packages

    melos bootstrap
    
  4. Check for .env file If packages/app/.env doesn't exist, remind the user:

    • Copy .env.example to .env
    • Configure FCM keys for push notifications

Success criteria

  • All submodules are cloned
  • Melos bootstrap completes without errors
  • Dependencies are resolved for all packages
为Keychat项目执行全面的Flutter质量检查流水线,包括代码分析、格式验证、单元测试及生成文件一致性检查。适用于提交代码前确保代码质量和规范。
提交代码前进行质量检查 运行Flutter项目全面检查
.claude/skills/flutter-check/SKILL.md
npx skills add keychat-io/keychat-app --skill flutter-check -g -y
SKILL.md
Frontmatter
{
    "name": "flutter-check",
    "invoke": "user",
    "description": "Run comprehensive Flutter checks including lint, analyze, test, and format verification. Use before commits to ensure code quality."
}

Flutter Check

Run a comprehensive Flutter quality check pipeline for the Keychat project.

Steps

  1. Analyze: Run melos run analyze to check for Dart analyzer warnings and errors
  2. Format Check: Run dart format --set-exit-if-changed . to verify formatting
  3. Test: Run melos run test:flutter to execute Flutter unit tests
  4. Generated Code: Check if generated files (.g.dart) are up to date by running melos run build:runner and verifying no diff

Behavior

  • Run all steps sequentially
  • Report results for each step clearly
  • If any step fails, continue running remaining steps but report all failures at the end
  • Provide actionable fix suggestions for any issues found
用于 Keychat 项目的代码生成工具,支持 Isar 模型、JSON 序列化及国际化文件的重构。可根据参数执行全部或特定类型的构建命令,并报告错误。
修改 Isar 模型文件后需要重新生成数据库模式 添加新翻译后需要重新生成本地化文件 修改带有 @JsonSerializable 注解的模型后需生成 JSON 序列化代码
.claude/skills/generate/SKILL.md
npx skills add keychat-io/keychat-app --skill generate -g -y
SKILL.md
Frontmatter
{
    "name": "generate",
    "description": "Run code generation for Isar models, JSON serialization, and i18n",
    "allowed-tools": "Bash(melos *), Bash(flutter pub run *)",
    "argument-hint": "[type]",
    "disable-model-invocation": true
}

Run code generation for the Keychat project.

Arguments

  • $ARGUMENTS - Optional: type of generation (all, dart, flutter, intl, runner)

Generation Commands

Type Command Description
all melos run generate:all Run all code generators
dart melos run generate:dart Dart package generators only
flutter melos run generate:flutter Flutter package generators only
intl melos run intl:generate Internationalization strings
runner melos run build:runner App build_runner only

Common scenarios

After modifying Isar model files

Run melos run build:runner to regenerate database schemas.

After adding new translations

Run melos run intl:generate to regenerate localization files.

After modifying any model with @JsonSerializable

Run melos run generate:all to regenerate JSON serialization code.

Workflow

  1. If no argument, run melos run generate:all
  2. If specific type provided, run the corresponding command
  3. Report any errors encountered during generation
用于在 Keychat 项目中执行代码质量检查,包括静态分析、格式化和代码规范校验。支持自动修复格式问题或仅运行全量检查,基于 very_good_analysis 规则确保代码一致性。
用户要求检查代码质量 用户要求格式化代码 用户要求运行 lint 检查
.claude/skills/lint/SKILL.md
npx skills add keychat-io/keychat-app --skill lint -g -y
SKILL.md
Frontmatter
{
    "name": "lint",
    "description": "Run linting, formatting, and static analysis on the codebase",
    "allowed-tools": "Bash(melos *), Bash(dart format *), Bash(dart analyze *)",
    "argument-hint": "[fix]",
    "disable-model-invocation": true
}

Run code quality checks on the Keychat project.

Arguments

  • $ARGUMENTS - Optional: "fix" to auto-fix formatting issues

Commands

Run all checks (analyze + format check)

melos run lint:all

Run analyzer only

melos run analyze

Check formatting

dart format --set-exit-if-changed .

Fix formatting

dart format .

Workflow

  1. If $ARGUMENTS is "fix":

    • Run dart format . to fix formatting
    • Then run melos run analyze to check for remaining issues
  2. Otherwise:

    • Run melos run lint:all to check everything
    • Report any issues found

Analysis configuration

The project uses very_good_analysis rules defined in analysis_options.yaml.

用于更新和安装 iOS/macOS 的 CocoaPods 依赖。通过 melos 脚本自动处理 iOS 和 macOS 目录下的 pod update 与 install,解决依赖不同步或插件升级后的环境配置问题。
添加新的原生 iOS/macOS 依赖 Podfile.lock 文件不同步 升级 Flutter 或相关插件后 遇到 'pod not found' 错误时
.claude/skills/pods/SKILL.md
npx skills add keychat-io/keychat-app --skill pods -g -y
SKILL.md
Frontmatter
{
    "name": "pods",
    "description": "Update and install CocoaPods dependencies for iOS and macOS",
    "allowed-tools": "Bash(pod *), Bash(cd *)",
    "disable-model-invocation": true
}

Update and install CocoaPods dependencies for iOS and macOS builds.

Command

Run the melos pods script:

melos run pod:install

This will:

  1. Navigate to packages/app/ios
  2. Run pod update && pod install --repo-update
  3. Navigate to packages/app/macos
  4. Run pod update && pod install --repo-update

When to use

  • After adding new native iOS/macOS dependencies
  • When Podfile.lock is out of sync
  • After upgrading Flutter or plugins
  • When getting "pod not found" errors

Troubleshooting

If pods fail to install:

  1. Try cleaning first: cd packages/app/ios && rm -rf Pods Podfile.lock
  2. Update CocoaPods: gem install cocoapods
  3. Clear pod cache: pod cache clean --all
清理 Flutter 构建产物并重置项目状态。适用于更新 Flutter、依赖变更或缓存异常导致的构建错误,提供全量或快速清理命令,并在清理后指导恢复依赖与代码生成。
Flutter 版本更新后出现构建错误 包之间状态不一致 重大依赖变更后需要清理 Xcode 或 Gradle 缓存问题
.claude/skills/clean/SKILL.md
npx skills add keychat-io/keychat-app --skill clean -g -y
SKILL.md
Frontmatter
{
    "name": "clean",
    "description": "Clean build artifacts and reset Flutter state",
    "allowed-tools": "Bash(melos *), Bash(flutter clean), Bash(rm *)",
    "disable-model-invocation": true
}

Clean build artifacts and reset the project state.

Commands

Full clean with melos

melos run clean:flutter

This runs in all Flutter packages:

  • flutter clean
  • flutter pub get
  • Removes ios/Podfile.lock
  • Runs pod repo update && pod install

Quick clean for app only

cd packages/app && flutter clean && flutter pub get

Clean generated files

cd packages/app && rm -rf lib/**/*.g.dart lib/**/*.isar.dart

When to use

  • Build errors after updating Flutter
  • Inconsistent state between packages
  • After major dependency changes
  • Xcode or Gradle cache issues

After cleaning

Remember to:

  1. Run melos bootstrap to restore dependencies
  2. Run melos run generate:all to regenerate code
  3. Run melos run pod:install for iOS/macOS
在设备或模拟器上运行 Keychat Flutter 应用。支持指定设备 ID,自动处理设备选择逻辑,并允许通过 -t 参数指定不同的入口文件以适配生产或多开发环境。
启动 Keychat 应用 在特定设备上调试应用 切换应用的开发/生产环境入口
.claude/skills/run/SKILL.md
npx skills add keychat-io/keychat-app --skill run -g -y
SKILL.md
Frontmatter
{
    "name": "run",
    "description": "Run the Keychat app on a device or simulator",
    "allowed-tools": "Bash(flutter *)",
    "argument-hint": "[device-id]",
    "disable-model-invocation": true
}

Run the Keychat app on a device or simulator.

Arguments

  • $ARGUMENTS - Optional: device ID to run on

Workflow

  1. First list available devices:

    flutter devices
    
  2. If $ARGUMENTS is provided, run on that device:

    cd packages/app && flutter run -d $ARGUMENTS
    
  3. If no device specified:

    • If only one device is available, use it
    • If multiple devices, show the list and ask user to specify

Alternative entry points

The app has multiple entry points for different environments:

  • lib/main.dart - Production
  • lib/main_dev1.dart - Development 1
  • lib/main_dev2.dart - Development 2
  • lib/main_dev3.dart - Development 3

To run with a specific entry point:

cd packages/app && flutter run -d <device> -t lib/main_dev1.dart
用于构建 keychat_rust_ffi_plugin 的 Rust 原生库,支持 iOS、Android、Linux、Windows 和 macOS 平台。需预装 flutter_rust_bridge_codegen 及系统依赖,通过指定目标架构进行编译并报告结果。
需要为 Flutter FFI 插件编译 Rust 代码 用户请求构建特定平台的 Rust 原生库
.claude/skills/rust-build/SKILL.md
npx skills add keychat-io/keychat-app --skill rust-build -g -y
SKILL.md
Frontmatter
{
    "name": "rust-build",
    "description": "Build Rust native libraries for the FFI plugin",
    "allowed-tools": "Bash(cargo *), Bash(rustup *)",
    "argument-hint": "[target]",
    "disable-model-invocation": true
}

Build the Rust native libraries for the keychat_rust_ffi_plugin.

Arguments

  • $ARGUMENTS - Target platform: ios, android, linux, windows, macos

Prerequisites

Ensure flutter_rust_bridge codegen is installed:

cargo install flutter_rust_bridge_codegen@2.11.1

For Linux, install system dependencies:

apt install protobuf-compiler libsecret-1-dev

Target Setup and Build Commands

Platform Target Setup & Build
iOS aarch64-apple-ios rustup target add aarch64-apple-ios && cargo build --target aarch64-apple-ios --release
Android aarch64-linux-android rustup target add aarch64-linux-android && cargo build --target aarch64-linux-android --release
Linux x86_64-unknown-linux-gnu rustup target add x86_64-unknown-linux-gnu && cargo build --target x86_64-unknown-linux-gnu --release
Windows x86_64-pc-windows-msvc rustup target add x86_64-pc-windows-msvc && cargo build --target x86_64-pc-windows-msvc --release
macOS aarch64-apple-darwin rustup target add aarch64-apple-darwin && cargo build --target aarch64-apple-darwin --release

Workflow

  1. Change to the Rust plugin directory:

    cd packages/keychat_rust_ffi_plugin/rust
    
  2. If no target specified, ask which platform to build for

  3. Add the rustup target if not already added:

    rustup target add <target>
    
  4. Build the library:

    cargo build --target <target> --release --target-dir target
    
  5. Report build success or any errors

Regenerating Dart Bindings

After modifying Rust API files, regenerate the Dart bindings:

cd packages/keychat_rust_ffi_plugin
flutter_rust_bridge_codegen generate
用于执行 Keychat 项目的测试任务。支持运行全部、仅 Flutter 或仅 Dart 测试,也可指定具体文件路径进行测试,并清晰报告测试结果。
用户要求运行项目测试 用户要求检查代码质量或回归测试 用户指定了特定的测试文件或包
.claude/skills/test/SKILL.md
npx skills add keychat-io/keychat-app --skill test -g -y
SKILL.md
Frontmatter
{
    "name": "test",
    "description": "Run tests for Keychat packages",
    "allowed-tools": "Bash(melos *), Bash(flutter test *)",
    "argument-hint": "[test-file|package]",
    "disable-model-invocation": true
}

Run tests for the Keychat project.

Arguments

  • $ARGUMENTS - Optional: specific test file path or package name

Test Commands

Run all tests

melos run test:all

Run Flutter tests only

melos run test:flutter

Run Dart tests only

melos run test:dart

Run a specific test file

cd packages/app
flutter test $ARGUMENTS

Workflow

  1. If no arguments provided, run melos run test:all
  2. If a file path is provided (ends with .dart), run that specific test
  3. Report test results clearly, including any failures

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-21 07:25
浙ICP备14020137号-1 $お客様$