搜索

PythonReactSEOPDF
GitHub Skill

sync-spec

Check and synchronize specification documents (docs-spec/) with implementation (src/, src-tauri/, tests/). Detect discrepancies and auto-fix when possible.

koedame☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Specification Synchronizer

Instructions

Phase 1: Scan Specifications
  1. Read all API specs from docs-spec/api/*.md
  2. Read architecture from docs-spec/architecture.md
  3. Read BDD scenarios from docs-spec/behavior/*.feature

For each spec file, extract:

  • Rust code blocks containing struct, enum, trait, fn definitions
  • Thread constraints (スレッド: リアルタイム/非リアルタイム/任意)
  • Module structure diagrams
Phase 2: Scan Implementation
  1. Find all Rust files: src/**/*.rs, src-tauri/**/*.rs

  2. For each file, search for:

    • pub struct definitions
    • pub enum definitions
    • pub trait definitions
    • pub fn definitions
    • impl blocks
  3. Find existing tests: tests/**/*.rs

Phase 3: Match and Compare

Use this mapping table:

Spec File Implementation Files
docs-spec/api/audio_engine.md src/audio/engine.rs, src/audio/device.rs, src/audio/effects.rs, src/audio/recording.rs, src/audio/metronome.rs
docs-spec/api/network.md src/network/connection.rs, src/network/session.rs, src/network/fec.rs, src/network/transport.rs
docs-spec/api/signaling.md src/network/signaling.rs
docs-spec/api/plugin.md src/audio/plugin.rs
docs-spec/api/i18n.md ui/locales/*.json
docs-spec/behavior/*.feature tests/*.rs

Compare:

  • Struct names and fields (name, type)
  • Enum variants
  • Trait methods (signature)
  • Function signatures (name, parameters, return type)
Phase 4: Auto-fix or Ask
Auto-fix (high confidence):
  • Missing struct/enum/fn in impl → Add stub to implementation
  • Missing pub item in spec → Add to spec documentation
  • Missing doc comments → Add based on spec description
  • Missing test file → Create test skeleton
Ask user (low confidence):
  • Signature differs (design choice needed)
  • Implementation more complex than spec (generics, extra params)
  • Conflicts with ADR decisions

Use AskUserQuestion when unsure (with recommendation):

  • Always provide a recommended option based on project requirements
  • Explain why the recommendation is best

Example:

  • Question: "Signature mismatch for fn start_capture. Which to fix?"
  • Options:
    1. "Update implementation (Recommended): Spec is source of truth per CLAUDE.md"
    2. "Update spec: If implementation has better design rationale"
    3. "Skip: Defer decision"
Phase 5: Ensure Tests
  1. For each Scenario: in docs-spec/behavior/*.feature:

    • Map to test file: connection.feature → tests/connection_test.rs
    • If test file missing → Create with test skeleton
    • If scenario not covered → Add test function
  2. Test function structure:

    • Parse Given → setup code
    • Parse When → action code
    • Parse Then → assertion
  3. Run cargo test to verify


Check Rules

Type Definition Checks
Check Action if Failed
Struct in spec, missing in impl Add struct stub to impl
Struct field type mismatch ASK: Which is correct?
Enum variant missing Add variant to impl
Trait method missing Add method stub to impl
Function Signature Checks
Check Action if Failed
Function missing in impl Add function stub
Parameter count differs ASK: Design decision
Return type differs ASK: Design decision
Thread constraint undocumented Add doc comment
Module Structure Checks
Check Action if Failed
Module file missing ASK: Create or update spec?
File exists but not in spec Add to spec module diagram
Test Coverage Checks
Check Action if Failed
No test for scenario Create test file and function
Test exists but incomplete Add missing assertions

Output Format

## Sync Report: [spec_file] <-> [impl_files]

### Auto-fixed
- [FIXED] description (file:line)

### Needs Confirmation
- [QUESTION] description
  - Spec: X
  - Impl: Y

### Tests Created
- [TEST] tests/xxx_test.rs - N scenarios covered

### Summary
- Matched: N items
- Auto-fixed: N items
- User decisions: N items
- Tests created: N files

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!