sync-spec-kit Skill
Keep the spec-kit specification folder (.specify/specs/<feature>/) in sync with the actual implementation on a feature branch.
Workflow
Step 1: Validate context
- Check the current branch:
git branch --show-current
If the branch is
mainormaster, stop immediately and tell the user:"Spec sync only runs on feature branches. You're currently on
main. Switch to your feature branch first."Derive the feature name from the branch. Strip common prefixes (
feature/,feat/,bugfix/,fix/,hotfix/,chore/,refactor/) and use the remainder.
Step 2: Locate the spec folder
- List available spec folders:
ls .specify/specs/
- Match the feature name to a spec folder (exact match first, then fuzzy). If no match, list available specs and ask the user which one to sync.
Step 3: Delegate to the sync-spec-kit-agent
Once the branch and spec folder are confirmed, launch the sync-spec-kit-agent using the Agent tool. Pass it the following context in the prompt:
- The current branch name
- The spec folder path (e.g.,
.specify/specs/user-auth/) - Any specific context the user provided about what changed (e.g., "I added rate limiting", "we switched to Redis")
Example Agent invocation prompt:
Sync the spec-kit specification folder
.specify/specs/<feature>/with the current implementation on branch<branch-name>. <user's additional context if any>
The agent will:
- Read all current spec files
- Analyze the full git diff, changed files, and commit history against the base branch
- Identify all spec drift (new requirements, changed requirements, architecture changes, etc.)
- Update all spec files hierarchically (spec.md → plan.md → tasks.md → research.md → others)
- Present a summary of everything that changed
Step 4: Review the agent's output
After the agent completes, relay its summary to the user. If the agent encountered issues (e.g., no spec folder found, ambiguous match), surface those to the user and help resolve them.