Loading...
Loading...
Perform initial analysis of a codebase - detect tech stack, directory structure, and completeness. This is Step 1 of the 6-step reverse engineering process that transforms incomplete applications into spec-driven codebases. Automatically detects programming languages, frameworks, architecture patterns, and generates comprehensive analysis-report.md. Use when starting reverse engineering on any codebase.
npx skill4agent add jschulte/claude-plugins analyzeanalysis-report.mdanalysis-report.md/speckit.analyze/speckit.analyze# Function to find batch session file (walks up like .git search)
find_batch_session() {
local current_dir="$(pwd)"
while [[ "$current_dir" != "/" ]]; do
# Stop at git root to prevent path traversal
if [[ -d "$current_dir/.git" ]] && [[ ! -f "$current_dir/.stackshift-batch-session.json" ]]; then
return 1
fi
if [[ -f "$current_dir/.stackshift-batch-session.json" ]]; then
echo "$current_dir/.stackshift-batch-session.json"
return 0
fi
current_dir="$(dirname "$current_dir")"
done
return 1
}
# Check if batch session exists
BATCH_SESSION=$(find_batch_session)
if [[ -n "$BATCH_SESSION" ]]; then
echo "✅ Using batch session configuration from: $BATCH_SESSION"
cat "$BATCH_SESSION" | jq '.answers'
# Auto-apply answers from batch session
# Skip questionnaire entirely
fi.stackshift-batch-session.json.stackshift-state.json~/git/osiris/
├── .stackshift-batch-session.json ← Batch session here
├── ws-vehicle-details/
│ └── [agent working here finds parent session]
├── ws-hours/
│ └── [agent working here finds parent session]
└── ws-contact/
└── [agent working here finds parent session]# Check repository name and structure
REPO_NAME=$(basename $(pwd))
PARENT_DIR=$(basename $(dirname $(pwd)))
# Detection patterns (in priority order)
# Add your own patterns here for your framework/architecture!
# Monorepo service detection
if [[ "$PARENT_DIR" == "services" || "$PARENT_DIR" == "apps" ]] && [ -f "../../package.json" ]; then
DETECTION="monorepo-service"
echo "📦 Detected: Monorepo Service (services/* or apps/* directory)"
# Nx workspace detection
elif [ -f "nx.json" ] || [ -f "../../nx.json" ]; then
DETECTION="nx-app"
echo "⚡ Detected: Nx Application"
# Turborepo detection
elif [ -f "turbo.json" ] || [ -f "../../turbo.json" ]; then
DETECTION="turborepo-package"
echo "🚀 Detected: Turborepo Package"
# Lerna package detection
elif [ -f "lerna.json" ] || [ -f "../../lerna.json" ]; then
DETECTION="lerna-package"
echo "📦 Detected: Lerna Package"
# Generic application (default)
else
DETECTION="generic"
echo "🔍 Detected: Generic Application"
fi
echo "Detection type: $DETECTION"# Example: Custom framework detection
# elif [[ "$REPO_NAME" =~ ^my-widget- ]]; then
# DETECTION="my-framework-widget"
# echo "🎯 Detected: My Framework Widget"Which path best aligns with your goals?
A) Greenfield: Extract for migration to new tech stack
→ Extract business logic only (tech-agnostic)
→ Can implement in any stack
→ Suitable for platform migrations
→ Example: Extract Rails app business logic → rebuild in Next.js
B) Brownfield: Extract for maintaining existing codebase
→ Extract business logic + technical details (tech-prescriptive)
→ Manage existing codebase with specs
→ Suitable for in-place improvements
→ Example: Add specs to Express API for ongoing maintenanceWhich implementation framework do you want to use?
A) GitHub Spec Kit (Recommended for most projects)
→ Feature-level specifications in .specify/
→ Task-driven implementation with /speckit.* commands
→ Simpler, lightweight workflow
→ Best for: small-medium projects, focused features
B) BMAD Auto-Pilot (Recommended for BMAD users)
→ Auto-generates BMAD artifacts (PRD, Architecture, Epics) from reverse-eng docs
→ Three modes: YOLO (fully automatic), Guided (ask on ambiguities), Interactive
→ Optionally hand off to BMAD agents for collaborative refinement
→ Best for: projects that want BMAD format without the full conversation
C) BMAD Method (Full collaborative workflow)
→ Uses same reverse-engineering docs as other frameworks
→ Hands off to BMAD's collaborative PM/Architect agents
→ BMAD creates PRD + Architecture through conversation
→ Best for: large projects needing deep collaborative refinement
D) Architecture Only
→ Generates architecture document with your constraints
→ Asks about tech stack, cloud, scale, hard constraints
→ Includes Mermaid diagrams, ADRs, infrastructure recommendations
→ Best for: when you already know what to build, need architecture
After StackShift extracts documentation (Gear 2):
- All frameworks get the same 11 docs in docs/reverse-engineering/
- Spec Kit: Gears 3-6 create .specify/ specs, use /speckit.implement
- BMAD Auto-Pilot: /stackshift.bmad-synthesize generates BMAD artifacts automatically
- BMAD: Skip to Gear 6, hand off to *workflow-init with rich context
- Architecture Only: /stackshift.architect generates architecture.md with your constraintsDo you want to upgrade dependencies after establishing specs?
A) Standard - Just create specs for current state
→ Document existing implementation as-is
→ Specs match current code exactly
→ Good for maintaining existing versions
B) Upgrade - Create specs + upgrade all dependencies
→ Spec current state first (100% coverage)
→ Then upgrade all dependencies to latest versions
→ Fix breaking changes with spec guidance
→ Improve test coverage to spec standards
→ End with modern, fully-spec'd application
→ Perfect for modernizing legacy apps
**Upgrade mode includes:**
- npm update / pip upgrade / go get -u (based on tech stack)
- Automated breaking change detection
- Test-driven upgrade fixes
- Spec updates for API changes
- Coverage improvement to 85%+How do you want to shift through the gears?
A) Manual - Review each gear before proceeding
→ You're in control
→ Stop at each step
→ Good for first-time users
B) Cruise Control - Shift through all gears automatically
→ Hands-free
→ Unattended execution
→ Good for experienced users or overnight runsHow thorough should specification generation be in Gear 3?
A) Specs only (30 min - fast)
→ Generate specs for all features
→ Create plans manually with /speckit.plan as needed
→ Good for: quick assessment, flexibility
B) Specs + Plans (45-60 min - recommended)
→ Generate specs for all features
→ Auto-generate implementation plans for incomplete features
→ Ready for /speckit.tasks when you implement
→ Good for: most projects, balanced automation
C) Specs + Plans + Tasks (90-120 min - complete roadmap)
→ Generate specs for all features
→ Auto-generate plans for incomplete features
→ Auto-generate comprehensive task lists (300-500 lines each)
→ Ready for immediate implementation
→ Good for: large projects, maximum automationHow should [NEEDS CLARIFICATION] markers be handled?
A) Defer - Mark them, continue implementation around them
→ Fastest
→ Can clarify later with /speckit.clarify
B) Prompt - Stop and ask questions interactively
→ Most thorough
→ Takes longer
C) Skip - Only implement fully-specified features
→ Safest
→ Some features won't be implementedWhat should be implemented in Gear 6?
A) None - Stop after specs are ready
→ Just want specifications
→ Will implement manually later
B) P0 only - Critical features only
→ Essential features
→ Fastest implementation
C) P0 + P1 - Critical + high-value features
→ Good balance
→ Most common choice
D) All - Every feature (may take hours/days)
→ Complete implementation
→ Longest runtimeWhere should specifications and documentation be written?
A) Current repository (default)
→ Specs in: ./docs/reverse-engineering/, ./.specify/
→ Simple, everything in one place
→ Good for: small teams, single repo
B) New application repository
→ Specs in: ~/git/my-new-app/.specify/
→ Specs live with NEW codebase
→ Good for: clean separation, NEW repo already exists
C) Separate documentation repository
→ Specs in: ~/git/my-app-docs/.specify/
→ Central docs repo for multiple apps
→ Good for: enterprise, multiple related apps
D) Custom location
→ Your choice: [specify path]
Default: Current repository (A)What tech stack for the new implementation?
Examples:
- Next.js 15 + TypeScript + Prisma + PostgreSQL
- Python/FastAPI + SQLAlchemy + PostgreSQL
- Go + Gin + GORM + PostgreSQL
- Your choice: [specify your preferred stack]Where should the new application be built?
A) Subfolder (recommended for Web)
→ Examples: greenfield/, v2/, new-app/
→ Keeps old and new in same repo
→ Works in Claude Code Web
B) Separate directory (local only)
→ Examples: ~/git/my-new-app, ../my-app-v2
→ Completely separate location
→ Requires local Claude Code (doesn't work in Web)
C) Replace in place (destructive)
→ Removes old code as new is built
→ Not recommendedFolder name within this repo? (default: greenfield/)
Examples: v2/, new-app/, nextjs-version/, rebuilt/
Your choice: [or press enter for greenfield/]Full path to new application directory:
Examples:
- ~/git/my-new-app
- ../my-app-v2
- /Users/you/projects/new-version
Your choice: [absolute or relative path]
⚠️ Note: Directory will be created if it doesn't exist.
Claude Code Web users: This won't work in Web - use subfolder instead..stackshift-state.json{
"detection_type": "monorepo-service", // What kind of app: monorepo-service, nx-app, generic, etc.
"route": "greenfield", // How to spec it: greenfield or brownfield
"implementation_framework": "speckit", // speckit, bmad-autopilot, bmad, or architect-only
"config": {
"spec_output_location": "~/git/my-new-app", // Where to write specs/docs
"build_location": "~/git/my-new-app", // Where to build new code (Gear 6)
"target_stack": "Next.js 15 + React 19 + Prisma",
"clarifications_strategy": "defer",
"implementation_scope": "p0_p1"
}
}detection_typerouteimplementation_framework{spec_output_location}/docs/reverse-engineering/{spec_output_location}/.specify/memory/{build_location}/src/{build_location}/package.jsongreenfield/StackShift: "What folder name for the new application? (default: greenfield/)"
User: "v2/" (or just press enter for greenfield/)
StackShift: "✅ New app will be built in: v2/"{
"config": {
"greenfield_location": "v2/" // Relative (subfolder)
// OR
"greenfield_location": "~/git/my-new-app" // Absolute (separate)
}
}# Building in: /Users/you/git/my-app/greenfield/
cd /Users/you/git/my-app
# StackShift creates: ./greenfield/
# Everything in one repo# Current repo: /Users/you/git/my-app
# New app: /Users/you/git/my-new-app
# StackShift:
# - Reads specs from: /Users/you/git/my-app/.specify/
# - Builds new app in: /Users/you/git/my-new-app/
# - Two completely separate repos# Create project commands directory
mkdir -p .claude/commands
# Copy StackShift's slash commands to project
cp ~/.claude/plugins/stackshift/.claude/commands/speckit.*.md .claude/commands/
cp ~/.claude/plugins/stackshift/.claude/commands/stackshift.modernize.md .claude/commands/
# Verify installation
ls .claude/commands/speckit.*.md.claude/commands//speckit.*# Allow .claude directory structure
!.claude/
!.claude/commands/
# Track slash commands (team needs these!)
!.claude/commands/*.md
# Ignore user-specific settings
.claude/settings.json
.claude/mcp-settings.jsongit add .claude/commands/
git commit -m "chore: add StackShift and Spec Kit slash commands
Adds /speckit.* and /stackshift.* slash commands for team use.
Commands added:
- /speckit.specify - Create feature specifications
- /speckit.plan - Create technical plans
- /speckit.tasks - Generate task lists
- /speckit.implement - Execute implementation
- /speckit.clarify - Resolve ambiguities
- /speckit.analyze - Validate specs match code
- /stackshift.modernize - Upgrade dependencies
These commands enable spec-driven development workflow.
All team members will have access after cloning.
"analysis-report.mdanalysis-report.mdanalysis-report.mdhead"I need to reverse engineer this application and create specifications. Let's start."