Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 106 additions & 6 deletions .claude/commands/stackshift.analyze.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ description: Gear 1 - Analyze codebase and detect tech stack

**IMPORTANT**: This command runs AST analysis ONCE and saves results for all gears.

---

## Step 0: Check for Pre-Configuration

```bash
# Check if config file exists (skip prompts if pre-configured)
if [ -f .stackshift-config.json ]; then
echo "✅ Found .stackshift-config.json - using pre-configured settings"
cat .stackshift-config.json | jq '.frameworks'
SKIP_PROMPTS=true
else
echo "ℹ️ No .stackshift-config.json found (optional)"
Comment on lines +15 to +20
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-configuration check sets SKIP_PROMPTS but doesn't actually extract and use the configuration values from the file. The bash script should parse implementation_framework and default_route from .stackshift-config.json and use those values instead of prompting. Currently, it only displays the frameworks section but doesn't skip the interactive prompts that follow.

Suggested change
if [ -f .stackshift-config.json ]; then
echo "✅ Found .stackshift-config.json - using pre-configured settings"
cat .stackshift-config.json | jq '.frameworks'
SKIP_PROMPTS=true
else
echo "ℹ️ No .stackshift-config.json found (optional)"
CONFIG_FILE=".stackshift-config.json"
if [ -f "$CONFIG_FILE" ]; then
echo "✅ Found $CONFIG_FILE - using pre-configured settings"
# Show configured frameworks (for visibility)
jq '.frameworks' "$CONFIG_FILE"
# Extract pre-configured values to use instead of interactive prompts
implementation_framework="$(jq -r '.implementation_framework // empty' "$CONFIG_FILE")"
default_route="$(jq -r '.default_route // empty' "$CONFIG_FILE")"
if [ -n "$implementation_framework" ]; then
export IMPLEMENTATION_FRAMEWORK="$implementation_framework"
fi
if [ -n "$default_route" ]; then
export DEFAULT_ROUTE="$default_route"
fi
SKIP_PROMPTS=true
else
echo "ℹ️ No $CONFIG_FILE found (optional)"

Copilot uses AI. Check for mistakes.
echo "Create one to pre-configure options and skip prompts."
SKIP_PROMPTS=false
fi
```

---

## Step 1: Run Full AST Analysis (Deterministic - Saves to Files)

First, use the Bash tool to execute comprehensive AST analysis:
**For all tools (Claude Code, OpenCode, Cursor, VSCode, etc.):**

```bash
~/stackshift/scripts/run-ast-analysis.mjs analyze .
Expand All @@ -28,21 +47,102 @@ First, use the Bash tool to execute comprehensive AST analysis:

**Cache duration**: 1 hour (auto-refreshes if stale)

---

## Step 2: Detect Tech Stack, Route, and Framework

After AST analysis completes, use the Skill tool to detect tech stack:
### For Claude Code users:

Use the Skill tool with skill="analyze".

**The skill will**:
### For OpenCode users:

Use the StackShift agent: `@stackshift analyze this codebase`

Or run the bash workflow below.

### For VSCode/Cursor/Codex users:

Run this interactive workflow:

```bash
# 1. Detect tech stack
if [ -f package.json ]; then
echo "📦 Node.js project detected"
echo "Dependencies:"
cat package.json | jq '.dependencies // {} | keys'
fi

# 2. Choose route
echo ""
echo "Choose your route:"
echo " A) Greenfield - Shift to new tech stack (extract business logic only)"
echo " B) Brownfield - Manage existing code (extract full implementation)"
read -p "Your choice (A/B): " route_choice
case ${route_choice^^} in
A) ROUTE="greenfield" ;;
B) ROUTE="brownfield" ;;
*) ROUTE="brownfield" ;;
esac

# 3. Choose framework (BE RAD!)
echo ""
echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║ Choose Your Implementation Framework ║"
echo "╚═══════════════════════════════════════════════════════════════╝"
echo ""
echo "A) GitHub Spec Kit"
echo " ✓ Feature-level specs in .specify/"
echo " ✓ Task-driven workflow with /speckit.* commands"
echo ""
echo "B) BMAD Method"
echo " ✓ Hands off to BMAD's collaborative PM/Architect agents"
echo " ✓ PRD + Architecture created through conversation"
echo ""
echo "C) BOTH (Recommended for maximum power! 🚀)"
echo " ✓ Generate Spec Kit specs (.specify/)"
echo " ✓ Hand off to BMAD with rich context"
echo " ✓ BE RAD: Best of All Worlds!"
echo ""
read -p "Your choice (A/B/C - or press Enter for C): " fw_choice
fw_choice=${fw_choice:-C}
case ${fw_choice^^} in
A) FRAMEWORK="speckit" ;;
B) FRAMEWORK="bmad" ;;
C) FRAMEWORK="both" ;;
*) FRAMEWORK="both" ;;
esac

# 4. Save state
cat > .stackshift-state.json << EOF
{
"route": "$ROUTE",
"implementation_framework": "$FRAMEWORK",
"gear": 1,
"timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
}
EOF

echo ""
echo "✅ Configuration saved to .stackshift-state.json"
echo " Route: $ROUTE"
echo " Framework: $FRAMEWORK"
```

---

## What the Analysis Does

**The analysis will**:
- Read file structure
- Detect frameworks from package.json
- Choose route (Greenfield/Brownfield)
- Choose implementation framework (GitHub Spec Kit / BMAD Method)
- Choose implementation framework (GitHub Spec Kit / BMAD Method / BOTH)
- Auto-detect app type (monorepo, Nx, etc.)
- Create analysis-report.md
- Save to .stackshift-state.json

**Framework choice determines output format**:
**Framework choice determines workflow**:
- **GitHub Spec Kit**: Creates `.specify/` structure, uses `/speckit.*` commands
- **BMAD Method**: Creates `docs/` structure, hands off to `*workflow-init`
- **BMAD Method**: Creates `docs/reverse-engineering/`, hands off to `*workflow-init`
- **BOTH (BE RAD)**: Creates both `.specify/` AND BMAD handoff for maximum flexibility
83 changes: 83 additions & 0 deletions .claude/commands/stackshift.implement.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,86 @@ docs/reverse-engineering/
**You get the best of both worlds:**
- StackShift's deep, accurate reverse engineering as input
- BMAD's interactive, collaborative artifact creation as output

---

## Path C: BOTH (implementation_framework: both) 🚀

### BE RAD: Best of All Worlds!

When you chose "BOTH", you get maximum flexibility.

### Step 1: Implement Features with Spec Kit

**First**, run Spec Kit implementation:

Use the Skill tool with skill="implement".

**The skill will**:
- Build features using `/speckit.tasks` and `/speckit.implement`
- Only implement PARTIAL and MISSING features
- Follow spec requirements exactly

### Step 2: Verify Implementation

```bash
~/stackshift/scripts/run-ast-analysis.mjs status .
```

### Step 3: BMAD Handoff (Optional)

**Then**, you have the option to hand off to BMAD for collaborative refinement.

**What you now have:**
```
.specify/ # Spec Kit artifacts
├── memory/
│ ├── constitution.md
│ └── [feature-name]/
│ ├── spec.md
│ ├── plan.md
│ └── tasks.md

docs/reverse-engineering/ # BMAD context
├── functional-specification.md
├── data-architecture.md
├── integration-points.md
└── ... (9 files total)
```

**Your options going forward:**

1. **Use Spec Kit workflow** for task-driven development:
- `/speckit.specify` for new features
- `/speckit.plan` for implementation plans
- `/speckit.tasks` for task lists
- `/speckit.implement` for execution

2. **Use BMAD workflow** for collaborative refinement:
- `npx bmad-method@alpha install`
- Run `*workflow-init`
- Point BMAD to `docs/reverse-engineering/`
- Let PM/Architect agents create artifacts through conversation

3. **Mix and match** as needed:
- Use Spec Kit for quick, focused tasks
- Use BMAD when you need deeper architectural discussion
- Both have access to the same rich context

### Why BOTH is Powerful

| Scenario | Use This |
|----------|----------|
| Quick bug fix | Spec Kit `/speckit.implement` |
| New feature with clear scope | Spec Kit workflow |
| Complex feature needing discussion | BMAD PM agent |
| Architecture decision | BMAD Architect agent |
| Day-to-day development | Spec Kit |
| Strategic planning | BMAD |

**The BE RAD philosophy:**
- **B**usiness logic extraction (StackShift)
- **E**verything documented (9 comprehensive files)
- **R**eady for any workflow (Spec Kit OR BMAD)
- **A**daptable to your needs (switch anytime)
- **D**ecision-free (no commitment upfront)
49 changes: 49 additions & 0 deletions .stackshift-config-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://stackshift.dev/config-schema.json",
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $schema URL "https://stackshift.dev/config-schema.json" should be verified to ensure it exists or will exist. If the schema file is not yet published or doesn't exist, this will cause validation errors in editors that respect $schema. Consider either publishing the schema or removing this field until it's available.

Suggested change
"$schema": "https://stackshift.dev/config-schema.json",

Copilot uses AI. Check for mistakes.
"version": "1.0",
"description": "StackShift Configuration - Copy to .stackshift-config.json to customize",

"frameworks": {
"_comment": "Framework preferences (overrides prompts)",
"implementation_framework": null,
"_valid_values": ["speckit", "bmad", "both", null],
"_note": "Set to null to be prompted, or pre-configure for automation"
},

"route": {
"_comment": "Route preference",
"default_route": null,
"_valid_values": ["greenfield", "brownfield", null]
},

"generation": {
"_comment": "Control what to generate (cost optimization)",
"generate_specs": true,
"generate_plans": true,
"generate_tasks": false,
"_note": "Set generate_tasks to false for faster analysis"
},

"cruise_control": {
"_comment": "Cruise control settings",
"clarifications_strategy": "defer",
"_valid_strategies": ["defer", "prompt", "skip"],
"implementation_scope": "p0_p1",
"_valid_scopes": ["none", "p0", "p0_p1", "all"]
},

"tool_modes": {
"_comment": "Enable tool-specific optimizations",
"opencode_enabled": false,
"skip_interactive_prompts": false,
"use_explicit_mentions": true,
"_note": "Set skip_interactive_prompts to true for CI/CD"
},

"paths": {
"_comment": "Custom output paths (optional)",
"spec_output_location": null,
"build_location": null,
"_note": "Set to null to use defaults (current directory)"
}
}
Loading
Loading