Transform reverse-engineering documentation into GitHub Spec Kit format. Initializes .specify/ directory, creates constitution.md, generates specifications from reverse-engineered docs, and sets up for /speckit slash commands. This is Step 3 of 6 in the reverse engineering process.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Step 3 of 6 in the Reverse Engineering to Spec-Driven Development process.
Estimated Time: 30 minutes (specs only) to 90 minutes (specs + plans + tasks)
Prerequisites: Step 2 completed (docs/reverse-engineering/ exists with 9 files)
Output: .specify/ directory with GitHub Spec Kit structure
Gear 3 generates different levels of detail based on configuration set in Gear 1:
Option 1: Specs Only (30 min - fast)
.specify/specs/###-feature-name/spec.md for all features/speckit.planOption 2: Specs + Plans (45-60 min - recommended)
plan.md for PARTIAL/MISSING features/speckit.tasksOption 3: Specs + Plans + Tasks (90-120 min - complete roadmap)
tasks.md (300-500 lines each)Configuration: Set during Gear 1 (Analyze) via initial questionnaire, stored in .stackshift-state.json
Use this skill when:
docs/reverse-engineering//speckit slash commands for implementationTrigger Phrases:
Automatically transforms reverse-engineering documentation into GitHub Spec Kit format using F002 automated spec generation:
docs/reverse-engineering/functional-specification.md.specify/memory/constitution.md with project principles.specify/specs/###-feature-name/spec.md for EVERY featureplan.md for PARTIAL and MISSING features only/speckit.* commandsCritical: This creates specs for 100% of features, not just gaps!
Result: Complete spec coverage - entire application under spec control.
Load state file to determine execution plan:
# Check thoroughness level (set in Gear 1)
THOROUGHNESS=$(cat .stackshift-state.json | jq -r '.config.gear3_thoroughness // "specs"')
# Check route
ROUTE=$(cat .stackshift-state.json | jq -r '.path')
# Check spec output location (Greenfield may have custom location)
SPEC_OUTPUT=$(cat .stackshift-state.json | jq -r '.config.spec_output_location // "."')
echo "Route: $ROUTE"
echo "Spec output: $SPEC_OUTPUT"
echo "Thoroughness: $THOROUGHNESS"
# Determine what to execute
case "$THOROUGHNESS" in
"specs")
echo "Will generate: Specs only"
GENERATE_PLANS=false
GENERATE_TASKS=false
;;
"specs+plans")
echo "Will generate: Specs + Plans"
GENERATE_PLANS=true
GENERATE_TASKS=false
;;
"specs+plans+tasks")
echo "Will generate: Specs + Plans + Tasks (complete roadmap)"
GENERATE_PLANS=true
GENERATE_TASKS=true
;;
*)
echo "Unknown thoroughness: $THOROUGHNESS, defaulting to specs only"
GENERATE_PLANS=false
GENERATE_TASKS=false
;;
esac
# If custom location, ensure .specify directory exists there
if [ "$SPEC_OUTPUT" != "." ]; then
echo "Creating .specify/ structure at custom location..."
mkdir -p "$SPEC_OUTPUT/.specify/specs"
mkdir -p "$SPEC_OUTPUT/.specify/memory"
mkdir -p "$SPEC_OUTPUT/.specify/templates"
mkdir -p "$SPEC_OUTPUT/.specify/scripts"
fi
Where specs will be written:
| Route | Config | Specs Written To |
|---|---|---|
| Greenfield | spec_output_location set | {spec_output_location}/.specify/specs/ |
| Greenfield | Not set (default) | ./.specify/specs/ (current repo) |
| Brownfield | Always current | ./.specify/specs/ (current repo) |
Common patterns:
spec_output_location: "." (default)spec_output_location: "~/git/my-new-app"spec_output_location: "~/git/my-app-docs"spec_output_location: "./new-version"IMPORTANT: This skill uses automated spec generation tools from F002.
CRITICAL FIRST STEP: Install the prerequisite scripts needed by /speckit.* commands:
# Install Spec Kit scripts to enable /speckit.* commands
if [ -f ~/git/stackshift/scripts/install-speckit-scripts.sh ]; then
~/git/stackshift/scripts/install-speckit-scripts.sh .
elif [ -f ~/stackshift/scripts/install-speckit-scripts.sh ]; then
~/stackshift/scripts/install-speckit-scripts.sh .
else
# Download directly if script not available
mkdir -p .specify/scripts/bash
BASE_URL="https://raw.githubusercontent.com/github/spec-kit/main/scripts"
curl -sSL "$BASE_URL/bash/check-prerequisites.sh" -o .specify/scripts/bash/check-prerequisites.sh
curl -sSL "$BASE_URL/bash/setup-plan.sh" -o .specify/scripts/bash/setup-plan.sh
curl -sSL "$BASE_URL/bash/create-new-feature.sh" -o .specify/scripts/bash/create-new-feature.sh
curl -sSL "$BASE_URL/bash/update-agent-context.sh" -o .specify/scripts/bash/update-agent-context.sh
curl -sSL "$BASE_URL/bash/common.sh" -o .specify/scripts/bash/common.sh
chmod +x .specify/scripts/bash/*.sh
echo "✅ Downloaded GitHub Spec Kit scripts"
fi
Why this is needed:
/speckit.analyze requires scripts/bash/check-prerequisites.sh/speckit.implement requires scripts/bash/check-prerequisites.sh/speckit.plan requires scripts/bash/setup-plan.sh/speckit.specify requires scripts/bash/create-new-feature.shWithout these scripts, Gear 4 (Gap Analysis) will fail when trying to run /speckit.analyze!
Run the stackshift_create_specs MCP tool to automatically generate ALL specifications:
This tool will:
docs/reverse-engineering/functional-specification.mdUsage:
// Call the MCP tool
const result = await mcp.callTool('stackshift_create_specs', {
directory: process.cwd()
});
// The tool will:
// 1. Read functional-specification.md
// 2. Create specs for ALL features (not just gaps!)
// 3. Mark implementation status (✅/⚠️/❌)
// 4. Generate plans for PARTIAL/MISSING features
// 5. Return summary showing complete coverage
Expected output:
After the tool completes, verify:
.specify/memory/constitution.md exists.specify/specs/###-feature-name/ directories created for ALL featuresspec.mdplan.mdThe MCP tool creates all Spec Kit files programmatically - it does NOT need specify init.
The tool creates:
.specify/memory/constitution.md (from templates).specify/specs/###-feature-name/spec.md (all features).specify/specs/###-feature-name/plan.md (for incomplete features).claude/commands/speckit.*.md (slash commands)If the MCP tool fails, use the manual reconciliation prompt:
# Copy this prompt into Claude.ai:
cat web/reconcile-specs.md
# This will manually create all specs with 100% coverage
DO NOT run specify init - it requires GitHub API access and isn't needed since F002 creates all files directly.
This creates:
.specify/
├── memory/
│ └── constitution.md # Project principles (will be generated)
├── templates/ # AI agent configs
├── scripts/ # Automation utilities
└── specs/ # Feature directories (will be generated)
├── 001-feature-name/
│ ├── spec.md # Feature specification
│ ├── plan.md # Implementation plan
│ └── tasks.md # Task breakdown (generated by /speckit.tasks)
└── 002-another-feature/
└── ...
Note: GitHub Spec Kit uses .specify/specs/NNN-feature-name/ directory structure
See operations/init-speckit.md
From docs/reverse-engineering/functional-specification.md, create .specify/memory/constitution.md:
Constitution includes:
Use /speckit.constitution command:
After generating initial constitution, user can run:
> /speckit.constitution
To refine and update the constitution interactively
See operations/generate-constitution.md
Transform docs/reverse-engineering/functional-specification.md into individual feature specs in specs/FEATURE-ID/:
Recommended: Use the Task tool with subagent_type=stackshift:technical-writer for efficient, parallel spec generation.
Directory Structure (per GitHub Spec Kit conventions):
Each feature gets its own directory:
specs/001-user-authentication/
├── spec.md # Feature specification
└── plan.md # Implementation plan
spec.md format:
# Feature: User Authentication
## Status
⚠️ **PARTIAL** - Backend complete, frontend missing login UI
## Overview
[Description of what this feature does]
## User Stories
- As a user, I want to register an account so that I can save my data
- As a user, I want to log in so that I can access my dashboard
## Acceptance Criteria
- [ ] User can register with email and password
- [x] User can log in with credentials
- [ ] User can reset forgotten password
- [x] JWT tokens issued on successful login
## Technical Requirements
- Authentication method: JWT
- Password hashing: bcrypt
- Session duration: 24 hours
- API endpoints:
- POST /api/auth/register
- POST /api/auth/login
- POST /api/auth/reset-password
## Implementation Status
**Completed:**
- ✅ Backend API endpoints (all 3)
- ✅ Database user model
- ✅ JWT token generation
**Missing:**
- ❌ Frontend login page
- ❌ Frontend registration page
- ❌ Password reset UI
- ❌ Token refresh mechanism
## Dependencies
None
## Related Specifications
- user-profile.md (depends on authentication)
- authorization.md (extends authentication)
Use /speckit.specify command:
After generating initial specs, user can run:
> /speckit.specify
To create additional specifications or refine existing ones
See operations/generate-specifications.md
For each PARTIAL or MISSING feature, create plan.md in the feature's directory:
Location: specs/FEATURE-ID/plan.md
Format:
# Implementation Plan: User Authentication Frontend
## Goal
Complete the frontend UI for user authentication (login, registration, password reset)
## Current State
- Backend API fully functional
- No frontend UI components exist
- User lands on placeholder page
## Target State
- Complete login page with form validation
- Registration page with email verification
- Password reset flow (email + new password)
- Responsive design for mobile/desktop
## Technical Approach
1. Create React components using existing UI library
2. Integrate with backend API endpoints
3. Add form validation with Zod
4. Implement JWT token storage (localStorage)
5. Add route protection for authenticated pages
## Tasks
- [ ] Create LoginPage component
- [ ] Create RegistrationPage component
- [ ] Create PasswordResetPage component
- [ ] Add form validation
- [ ] Integrate with API endpoints
- [ ] Add loading and error states
- [ ] Write component tests
- [ ] Update routing configuration
## Risks & Mitigations
- Risk: Token storage in localStorage (XSS vulnerability)
- Mitigation: Consider httpOnly cookies instead
- Risk: No rate limiting on frontend
- Mitigation: Add rate limiting to API endpoints
## Testing Strategy
- Unit tests for form validation logic
- Integration tests for API calls
- E2E tests for complete auth flow
## Success Criteria
- All acceptance criteria from specification met
- No security vulnerabilities
- Pass all tests
- UI matches design system
Use /speckit.plan command:
After generating initial plans, user can run:
> /speckit.plan
To create or refine implementation plans
See operations/generate-plans.md
In each specification, clearly mark what's implemented vs missing:
This allows /speckit.analyze to verify consistency.
After setting up specs, these commands become available:
# Check consistency between specs and implementation
> /speckit.analyze
# Identifies:
# - Specs marked COMPLETE but implementation missing
# - Implementation exists but not in spec
# - Inconsistencies between related specs
# Generate tasks from implementation plan
> /speckit.tasks
# Implement a specific feature
> /speckit.implement <specification-name>
# Runs through implementation plan step-by-step
# Updates implementation status as it progresses
# Resolve underspecified areas
> /speckit.clarify
# Interactive Q&A to fill in missing details
# Similar to our complete-spec skill
After this skill completes:
.specify/
├── memory/
│ └── constitution.md # Project principles
├── templates/
└── scripts/
specs/ # Feature directories
├── 001-user-authentication/
│ ├── spec.md # ⚠️ PARTIAL
│ └── plan.md # Implementation plan
├── 002-fish-management/
│ ├── spec.md # ⚠️ PARTIAL
│ └── plan.md
├── 003-analytics-dashboard/
│ ├── spec.md # ❌ MISSING
│ └── plan.md
└── 004-photo-upload/
├── spec.md # ⚠️ PARTIAL
└── plan.md
docs/reverse-engineering/ # Keep original docs for reference
├── functional-specification.md
├── data-architecture.md
└── ...
If greenfield_location is an absolute path (e.g., ~/git/my-new-app):
After Gear 3, .specify/ exists in BOTH locations:
Original repo:
~/git/my-app/
├── [original code]
├── .specify/ # Created here first
└── docs/
New repo (created and initialized):
~/git/my-new-app/
├── .specify/ # COPIED from original repo
├── README.md
└── .gitignore
Why copy?
/speckit.* commandsReverse-Engineered Docs → Spec Kit Artifacts:
| Original Doc | Spec Kit Artifact | Location |
|---|---|---|
| functional-specification.md | constitution.md | .specify/memory/ |
| functional-specification.md | Individual feature specs | specs/ |
| data-architecture.md | Technical details in specs | Embedded in specifications |
| operations-guide.md | Operational notes in constitution | .specify/memory/constitution.md |
| technical-debt-analysis.md | Implementation plans | specs/ |
Keep both:
docs/reverse-engineering/ - Comprehensive reference docs.specify/memory/ - Spec Kit format for /speckit commandsIf user selected Option 2 or 3, automatically generate implementation plans for all PARTIAL/MISSING features.
Scan specs directory:
find specs -name "spec.md" -type f | sort
Identify incomplete features:
Generate plans in parallel (5 at a time):
// For each PARTIAL/MISSING feature
Task({
subagent_type: 'general-purpose',
model: 'sonnet',
description: `Create plan for ${featureName}`,
prompt: `
Read: specs/${featureId}/spec.md
Generate implementation plan following /speckit.plan template:
- Assess current state (what exists vs missing)
- Define target state (all acceptance criteria)
- Determine technical approach
- Break into implementation phases
- Identify risks and mitigations
- Define success criteria
Save to: specs/${featureId}/plan.md
Target: 300-500 lines, detailed but not prescriptive
`
});
Verify coverage:
If user selected Option 3, automatically generate comprehensive task breakdowns for all plans.
Scan for plans:
find specs -name "plan.md" -type f | sort
Generate tasks in parallel (3 at a time - slower due to length):
// For each plan
Task({
subagent_type: 'general-purpose',
model: 'sonnet',
description: `Create tasks for ${featureName}`,
prompt: `
Read: specs/${featureId}/spec.md
Read: specs/${featureId}/plan.md
Generate COMPREHENSIVE task breakdown:
- Break into 5-10 logical phases
- Each task has: status, file path, acceptance criteria, code examples
- Include Testing phase (unit, integration, E2E)
- Include Documentation phase
- Include Edge Cases section
- Include Dependencies section
- Include Acceptance Checklist
- Include Priority Actions
Target: 300-500 lines (be thorough!)
Save to: specs/${featureId}/tasks.md
`
});
Verify quality:
In .stackshift-state.json:
{
"config": {
"gear3_thoroughness": "specs+plans+tasks", // or "specs" or "specs+plans"
"plan_parallel_limit": 5,
"task_parallel_limit": 3
}
}
Or ask user interactively if not set.
After running this skill, you should have:
Thoroughness Level 1 (Specs Only):
.specify/ directory initializedconstitution.md created with project principlesspecs//speckit.* slash commands availableThoroughness Level 2 (Specs + Plans):
plan.md for every PARTIAL/MISSING feature/speckit.tasksThoroughness Level 3 (Specs + Plans + Tasks):
tasks.md for every planned featureOnce specifications are created in Spec Kit format, proceed to:
Step 4: Gap Analysis - Use /speckit.analyze to identify inconsistencies and the gap-analysis skill to create prioritized implementation plan.
# This skill runs
1. specify init my-app
2. Generate constitution.md from functional-specification.md
3. Create individual feature specs from functional requirements
4. Mark implementation status (✅/⚠️/❌)
5. Generate implementation plans for gaps
# User can then run
> /speckit.analyze
# Shows: "5 PARTIAL features, 3 MISSING features, 2 inconsistencies"
> /speckit.implement user-authentication
# Walks through implementation plan step-by-step
> /speckit.specify
# Add new features as needed
.specify/ directory (not specs/)/speckit commands are slash commands in Claude Code, not CLIstackshift:technical-writer agent for efficient parallel spec generation--ai claude flag with specify init for non-interactive modeRemember: This integrates your reverse-engineered codebase with GitHub Spec Kit, enabling the full /speckit.* workflow for ongoing development.