context-forge
Version:
AI orchestration platform with autonomous teams, enhancement planning, migration tools, 25+ slash commands, checkpoints & hooks. Multi-IDE: Claude, Cursor, Windsurf, Cline, Copilot
883 lines (693 loc) • 26.5 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSlashCommands = generateSlashCommands;
exports.generateSlashCommandFiles = generateSlashCommandFiles;
const checkpointCommands_1 = require("./checkpointCommands");
async function generateSlashCommands(config) {
const commands = [];
// PRP Commands
commands.push({
name: 'prp-create',
category: 'PRPs',
description: 'Generate a comprehensive PRP with deep research',
content: `# Create PRP for Feature: $ARGUMENTS
Generate a complete PRP for feature implementation with deep and thorough research. Ensure rich context is passed to the AI through the PRP to enable one-pass implementation success.
## Research Process
1. **Codebase Analysis**
- Search for similar features/patterns in the codebase
- Identify all necessary files to reference
- Note existing conventions to follow
- Check test patterns for validation approach
2. **External Research**
- Find relevant documentation (include URLs)
- Search for implementation examples
- Document best practices and common pitfalls
- Add critical docs to PRPs/ai_docs/ if needed
3. **User Clarification**
- Ask for any missing requirements
## PRP Generation
Using the PRP template, include:
- All necessary context (docs, examples, gotchas)
- Implementation blueprint with pseudocode
- Executable validation gates
- Clear task breakdown
## Output
Save as: \`PRPs/{feature-name}-prp.md\`
Remember: The goal is one-pass implementation success through comprehensive context.`,
});
commands.push({
name: 'prp-execute',
category: 'PRPs',
description: 'Execute a PRP against the codebase',
content: `# Execute PRP: $ARGUMENTS
Load and execute the specified PRP file.
## Workflow
1. **Load PRP**: Read PRPs/$ARGUMENTS.md
2. **Plan**: Create comprehensive implementation plan
3. **Execute**: Implement following the blueprint
4. **Validate**: Run all validation gates
5. **Complete**: Ensure all checklist items done
## Execution Guidelines
- Follow existing code patterns
- Implement incrementally with validation
- Use TodoWrite tool to track progress
- Run validation gates after each component
- Fix any failures before proceeding
When complete, all validation gates should pass.`,
});
commands.push({
name: 'prime-context',
category: 'development',
description: 'Prime Claude with intelligent project context and mode switching',
content: generateSmartPrimeContextCommand(config),
});
commands.push({
name: 'validate-prp',
category: 'PRPs',
description: 'Validate a PRP for completeness',
content: `# Validate PRP: $ARGUMENTS
Check if the PRP contains all necessary elements for one-pass success.
## Validation Checklist
### Required Sections
- [ ] Clear Goal statement
- [ ] Why (business value)
- [ ] What (requirements)
- [ ] All Needed Context section
- [ ] Implementation Blueprint
- [ ] Validation Gates (4 levels)
- [ ] Task Breakdown
### Context Quality
- [ ] Documentation URLs included
- [ ] Code examples referenced
- [ ] Known gotchas documented
- [ ] Patterns identified
### Validation Gates
- [ ] Level 1: Syntax/Style commands
- [ ] Level 2: Unit test patterns
- [ ] Level 3: Integration tests
- [ ] Level 4: Creative validation
## Score
Rate the PRP 1-10 for likelihood of one-pass success.`,
});
// Development Commands
commands.push({
name: 'debug-issue',
category: 'development',
description: 'Debug and find root cause of an issue',
content: `# Debug Issue: $ARGUMENTS
Systematically debug and resolve the specified issue.
## Debug Process
1. **Reproduce**: Understand how to trigger the issue
2. **Investigate**:
- Check error logs and stack traces
- Examine relevant code paths
- Review recent changes
3. **Root Cause**: Identify the underlying problem
4. **Fix**: Implement and test the solution
5. **Verify**: Ensure the issue is resolved
Report findings and implemented fix.`,
});
// Code Quality Commands
commands.push({
name: 'review-code',
category: 'quality',
description: 'Review code for quality and best practices',
content: `# Code Review: $ARGUMENTS
Review the specified code for quality, security, and best practices.
## Review Areas
1. **Code Quality**
- Readability and maintainability
- Proper error handling
- Performance considerations
- Security vulnerabilities
2. **Best Practices**
- Follows project conventions
- Appropriate abstractions
- Test coverage
- Documentation
3. **Suggestions**
- Specific improvements
- Refactoring opportunities
- Additional test cases
Provide actionable feedback with examples.`,
});
commands.push({
name: 'refactor-code',
category: 'quality',
description: 'Refactor code for better structure',
content: `# Refactor: $ARGUMENTS
Refactor the specified code while maintaining functionality.
## Refactoring Process
1. **Understand**: Analyze current implementation
2. **Plan**: Identify refactoring opportunities
3. **Test**: Ensure existing tests pass
4. **Refactor**: Apply improvements incrementally
5. **Validate**: Verify no regressions
## Focus Areas
- Extract reusable functions
- Improve naming and clarity
- Reduce complexity
- Enhance type safety
- Follow SOLID principles
Maintain all existing functionality.`,
});
// Add rapid development commands
commands.push({
name: 'parallel-prp-create',
category: 'rapid',
description: 'Create multiple PRPs in parallel using subagents',
content: `# Parallel PRP Creation: $ARGUMENTS
Create multiple PRPs simultaneously using batch tools and subagents.
## Process
1. **Parse Requirements**: Break down into independent features
2. **Spawn Subagents**: Create parallel research tasks
3. **Deep Research**: Each agent researches their feature
4. **Generate PRPs**: Create comprehensive PRPs
5. **Validate**: Ensure all PRPs meet quality standards
## Subagent Instructions
Each subagent should:
- Research existing patterns thoroughly
- Find external documentation
- Document gotchas and pitfalls
- Create executable validation gates
- Score PRP confidence (1-10)
Use batch tools to maximize efficiency.`,
});
commands.push({
name: 'smart-commit',
category: 'git',
description: 'Create intelligent git commits',
content: `# Smart Commit
Analyze changes and create a well-structured commit.
## Process
1. **Analyze Changes**: Review all modified files
2. **Group Changes**: Organize by feature/fix
3. **Generate Message**: Create conventional commit message
4. **Validate**: Ensure message follows standards
## Commit Format
\`\`\`
<type>(<scope>): <subject>
<body>
<footer>
\`\`\`
Types: feat, fix, docs, style, refactor, test, chore`,
});
commands.push({
name: 'create-pr',
category: 'git',
description: 'Create comprehensive pull request',
content: `# Create Pull Request
Generate a detailed PR with all necessary context.
## PR Structure
1. **Title**: Clear, concise description
2. **Summary**: What and why
3. **Changes**: Detailed list of modifications
4. **Testing**: How to verify changes
5. **Screenshots**: If UI changes
6. **Checklist**: Required validations
## Template
### Summary
Brief description of changes and motivation
### Changes
- Change 1: Description
- Change 2: Description
### Testing
Steps to test the changes
### Checklist
- [ ] Tests pass
- [ ] Documentation updated
- [ ] No regressions`,
});
// Checkpoint Commands (if enabled)
if (config.extras.checkpoints) {
const checkpointCommands = (0, checkpointCommands_1.generateCheckpointCommands)(config);
checkpointCommands.forEach((cmd) => {
commands.push({
name: cmd.name,
category: cmd.category,
description: cmd.description,
content: cmd.template,
});
});
}
// Orchestration Commands
commands.push({
name: 'orchestrate-project',
category: 'orchestration',
description: 'Deploy autonomous AI team for 24/7 development',
content: generateOrchestratorCommand(config),
});
commands.push({
name: 'orchestrate-feature',
category: 'orchestration',
description: 'Deploy focused team for specific feature',
content: generateFeatureOrchestratorCommand(config),
});
commands.push({
name: 'orchestrate-status',
category: 'orchestration',
description: 'Check orchestration team status',
content: generateOrchestratorStatusCommand(),
});
commands.push({
name: 'feature-status',
category: 'development',
description: 'Check feature implementation progress',
content: `# Check Feature Status: $ARGUMENTS
View progress on a specific feature implementation.
## Usage
\`/feature-status "authentication"\` - Status of auth feature
\`/feature-status all\` - Status of all features
## Information Displayed
### Feature Overview
- Feature name and description
- Assigned team members
- Current phase
- Overall progress percentage
### Task Breakdown
- Completed tasks ✅
- In-progress tasks 🔄
- Blocked tasks 🚫
- Pending tasks ⏳
### Quality Metrics
- Test coverage
- Code review status
- Documentation status
- Performance benchmarks
### Timeline
- Start date
- Expected completion
- Actual vs planned progress
- Blocker impact on timeline
### Recent Activity
- Last 5 commits related to feature
- Recent PR activity
- Test results
- Key decisions made
## Quick Actions
Based on status:
1. Unblock team members
2. Adjust timeline
3. Add resources
4. Review completed work
Use this to keep features on track!`,
});
return commands;
}
function generateSlashCommandFiles(commands) {
const files = [];
for (const command of commands) {
files.push({
path: path_1.default.join('.claude', 'commands', command.category, `${command.name}.md`),
content: command.content,
description: command.description,
});
}
// Add README for commands
files.push({
path: path_1.default.join('.claude', 'commands', 'README.md'),
content: generateCommandsReadme(commands),
description: 'Slash commands documentation',
});
// Add PRPs/ai_docs directory with README
files.push({
path: path_1.default.join('PRPs', 'ai_docs', 'README.md'),
content: generateAiDocsReadme(),
description: 'AI documentation curation guide',
});
return files;
}
function generateCommandsReadme(commands) {
const commandsByCategory = commands.reduce((acc, cmd) => {
if (!acc[cmd.category])
acc[cmd.category] = [];
acc[cmd.category].push(cmd);
return acc;
}, {});
let content = `# Context Forge Slash Commands
Custom slash commands for Claude Code to enhance your development workflow.
## Usage
In Claude Code, type \`/\` followed by the command name:
- \`/prp-create feature-name\` - Create a new PRP
- \`/prp-execute feature-name\` - Execute an existing PRP
- \`/prime-context\` - Load project context
## Available Commands
`;
for (const [category, cmds] of Object.entries(commandsByCategory)) {
content += `\n### ${category.charAt(0).toUpperCase() + category.slice(1)}\n\n`;
for (const cmd of cmds) {
content += `- **/${cmd.name}** - ${cmd.description}\n`;
}
}
content += `\n## Creating Custom Commands
Add your own commands by creating markdown files in the appropriate category folder:
- \`.claude/commands/PRPs/\` - PRP-related commands
- \`.claude/commands/development/\` - Development utilities
- \`.claude/commands/quality/\` - Code quality tools
- \`.claude/commands/rapid/\` - Rapid development tools
- \`.claude/commands/git/\` - Git operations
Use \`$ARGUMENTS\` placeholder for dynamic input.
## Tips
- Commands are automatically discovered by Claude Code
- Use descriptive names for easy discovery
- Include clear instructions in command content
- Reference existing patterns in the codebase
- Commands can call other commands`;
return content;
}
function generateAiDocsReadme() {
return `# AI Documentation Curation
This directory contains curated documentation for AI-assisted development. These docs are referenced in PRPs to provide comprehensive context.
## Purpose
When creating PRPs, you may need to include specific documentation that isn't easily accessible via URLs or is critical for implementation success. This directory serves as a repository for such documentation.
## Usage in PRPs
Reference documents in your PRPs using:
\`\`\`yaml
- docfile: PRPs/ai_docs/library-guide.md
why: Specific implementation patterns and gotchas
\`\`\`
## What to Include
1. **Library Documentation** - Key sections from official docs
2. **Implementation Patterns** - Common patterns and best practices
3. **API References** - Detailed API documentation for complex integrations
4. **Migration Guides** - When upgrading versions or switching libraries
5. **Internal Standards** - Team-specific coding standards and practices
## File Naming Convention
- Use descriptive names: \`react-hooks-guide.md\`, \`fastapi-async-patterns.md\`
- Include version if relevant: \`nextjs-15-app-router.md\`
- Use lowercase with hyphens
## Example Structure
\`\`\`
PRPs/ai_docs/
├── README.md (this file)
├── react-hooks-guide.md
├── fastapi-async-patterns.md
├── postgres-optimization.md
└── aws-lambda-best-practices.md
\`\`\`
Remember: The goal is to provide AI with all necessary context for one-pass implementation success.`;
}
const path_1 = __importDefault(require("path"));
function generateOrchestratorCommand(config) {
return `# Deploy Autonomous Orchestration: $ARGUMENTS
Deploy a full AI orchestration team to work on your project autonomously.
## What This Does
1. **Creates AI Team**: Deploys orchestrator, project managers, and developers
2. **Self-Managing**: Agents schedule their own check-ins and manage workload
3. **Git Discipline**: Auto-commits every 30 minutes to prevent work loss
4. **24/7 Operation**: Can run continuously without human intervention
## Usage
\`/orchestrate-project\` - Deploy with default team structure
\`/orchestrate-project small\` - Small team (1 PM, 2 devs)
\`/orchestrate-project large\` - Large team (2 PMs, 4 devs, QA, DevOps)
## Team Structure
### Default Team
- 1 Orchestrator (oversees everything)
- 1 Project Manager (coordinates work)
- 2 Developers (implement features)
- 1 QA Engineer (ensures quality)
### Small Team
- 1 Orchestrator
- 1 Project Manager
- 2 Developers
### Large Team
- 1 Orchestrator
- 2 Project Managers
- 4 Developers
- 2 QA Engineers
- 1 DevOps Engineer
- 1 Code Reviewer
## Prerequisites
1. **tmux installed**: Required for agent management
2. **Git initialized**: Project must be a git repository
3. **Claude access**: Each agent needs Claude access
4. **PRPs created**: Agents work best with clear PRPs
## Deployment Process
1. Check tmux availability
2. Create orchestration session
3. Deploy agents with specific roles
4. Initialize git auto-commit
5. Set up self-scheduling
6. Brief each agent on their responsibilities
## Monitoring
Use \`/orchestrate-status\` to check on your team
Use \`tmux attach -t cf-${config.projectName}\` to view agents
## Important Notes
- Agents commit automatically - review commits regularly
- Each agent has specific responsibilities and constraints
- Communication follows hub-and-spoke model through PM
- Orchestrator handles high-level decisions only
Ready to deploy your AI team!`;
}
function generateFeatureOrchestratorCommand(_config) {
return `# Deploy Feature-Focused Orchestration: $ARGUMENTS
Deploy a focused AI team to implement a specific feature.
## Usage
\`/orchestrate-feature "user authentication"\` - Deploy team for auth feature
\`/orchestrate-feature "payment integration" large\` - Large team for complex feature
## What This Does
1. **Focused Team**: Smaller team dedicated to one feature
2. **Feature PRP**: Generates feature-specific PRP if needed
3. **Auto PR**: Creates pull request when feature is complete
4. **Progress Tracking**: Regular updates on feature progress
## Team Composition
### Default Feature Team
- 1 Lead Developer (owns the feature)
- 1 Supporting Developer (assists and reviews)
- 1 QA Engineer (tests the feature)
### Large Feature Team
- 1 Feature Lead
- 2 Developers
- 1 QA Engineer
- 1 Code Reviewer
## Process
1. Analyze feature requirements
2. Generate or load feature PRP
3. Deploy specialized team
4. Implement with test-driven development
5. Create PR when complete
## Feature Workflow
1. **Planning**: Team reviews requirements
2. **Implementation**: TDD approach
3. **Testing**: Comprehensive test coverage
4. **Review**: Internal code review
5. **PR Creation**: Automated PR with details
## Success Criteria
- All acceptance criteria met
- Tests passing with >80% coverage
- Code review approved
- No regressions in existing features
- Documentation updated
## Monitoring
Check progress with:
- \`/feature-status [feature-name]\`
- \`/orchestrate-status\`
Feature-focused orchestration ensures dedicated attention to critical features!`;
}
function generateOrchestratorStatusCommand() {
return `# Check Orchestration Status
View the current status of your AI orchestration team.
## Usage
\`/orchestrate-status\` - Show current team status
\`/orchestrate-status detailed\` - Include agent performance metrics
\`/orchestrate-status logs\` - Show recent agent activity
## Status Information
### Team Overview
- Active agents and their roles
- Current tasks being worked on
- Blocked agents needing attention
- Overall progress metrics
### Git Activity
- Recent commits by agents
- Current branch structure
- Pending changes
### Performance Metrics
- Tasks completed per agent
- Average task completion time
- Code quality scores
- Communication efficiency
### Health Indicators
- Agent uptime
- Error rates
- Blocker frequency
- Recovery success rate
## Status Codes
- 🟢 **Active**: Agent working normally
- 🟡 **Idle**: No activity for 30+ minutes
- 🔴 **Blocked**: Agent needs help
- ⚫ **Offline**: Agent not responding
## Quick Actions
Based on status, you might:
1. Unblock agents with additional context
2. Adjust team size for workload
3. Review and merge completed work
4. Address quality issues
## Dashboard View
For real-time monitoring:
\`tmux attach -t cf-[project-name]\`
This lets you watch agents work in real-time!`;
}
function generateSmartPrimeContextCommand(config) {
return `# Smart Prime Context for ${config.projectName}
Intelligently prime Claude with project context and switch to appropriate mode based on project state.
## Phase 1: Project State Detection
First, analyze the project to determine if this is a new project or an existing codebase:
\`\`\`bash
# Check for source code files
find . -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.py" -o -name "*.java" -o -name "*.go" -o -name "*.rs" -o -name "*.php" -o -name "*.rb" | grep -v node_modules | head -10
# Check package.json and dependencies
if [ -f package.json ]; then
echo "=== Package.json found ==="
cat package.json | jq '.dependencies // {}'
echo "=== Dev Dependencies ==="
cat package.json | jq '.devDependencies // {}'
fi
# Check for build artifacts and installed dependencies
ls -la | grep -E "(node_modules|dist|build|target|__pycache__|\.git)"
# Check project structure
tree -L 3 -I 'node_modules|\.git|dist|build' . || ls -la
\`\`\`
## Phase 2: Mode Selection
Based on the analysis above, determine project state:
### NEW PROJECT INDICATORS:
- No source code files (only documentation)
- Empty or minimal package.json
- No node_modules or build artifacts
- Only README.md, CLAUDE.md, and basic config files
### EXISTING PROJECT INDICATORS:
- Source code files present
- Package.json with dependencies
- Build artifacts or node_modules exists
- Established project structure
## Phase 3: Context Loading & Mode Execution
### If NEW PROJECT - Switch to LEAD SOFTWARE ARCHITECT MODE:
\`\`\`
🏗️ ARCHITECT MODE ACTIVATED
Role: Lead Software Architect
Mission: Transform requirements into working software
\`\`\`
**Immediate Actions:**
1. **Requirements Analysis**
- Read CLAUDE.md for project guidelines and requirements
- Read README.md for project overview and specifications
- Extract technical requirements, features, and constraints
- Identify target users and success criteria
2. **Technical Architecture Planning**
- Review specified tech stack: ${config.techStack
? Object.entries(config.techStack)
.map(([key, value]) => `${key}: ${value}`)
.join(', ')
: 'To be determined'}
- Design system architecture and component structure
- Plan database schema and API design
- Identify external integrations and dependencies
3. **Development Planning**
- Create TodoWrite tasks for immediate development priorities
- Set up project structure and boilerplate
- Plan MVP feature set and development phases
- Identify critical path and dependencies
4. **Implementation Kickoff**
- Generate initial project structure
- Set up development environment
- Create first working components
- Begin feature implementation immediately
**TodoWrite Tasks to Create:**
- [ ] Set up project structure and dependencies
- [ ] Create core application framework
- [ ] Implement authentication system (if required)
- [ ] Build primary user interface
- [ ] Set up database and data models
- [ ] Create API endpoints and business logic
- [ ] Implement key features from requirements
- [ ] Add testing framework and initial tests
- [ ] Set up deployment configuration
**🚫 CRITICAL: Git Commit Rules**
**NEVER include these in commit messages:**
- ❌ \`🤖 Generated with [Claude Code](https://claude.ai/code)\`
- ❌ \`Co-Authored-By: Claude <noreply@anthropic.com>\`
- ❌ Any Claude Code signatures or attributions
**Always use clean commit messages:**
\`\`\`bash
# ✅ Good commit messages:
git commit -m "Initial project setup with ${config.techStack?.frontend || 'web framework'}"
git commit -m "Add user authentication components"
git commit -m "Implement core business logic"
git commit -m "Add responsive UI components"
# ❌ BAD - Never include:
git commit -m "Add components
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"
\`\`\`
**Next Actions:**
- Start with project setup and core framework
- Focus on getting a working prototype quickly
- Implement features incrementally with validation
- Build, test, and iterate rapidly
- **Commit frequently with clean, descriptive messages**
### If EXISTING PROJECT - Switch to ANALYSIS & GUIDANCE MODE:
\`\`\`
🔍 ANALYSIS MODE ACTIVATED
Role: Senior Developer & Code Architect
Mission: Understand codebase and provide strategic guidance
\`\`\`
**Comprehensive Analysis:**
1. **Project Discovery**
- Read CLAUDE.md for project guidelines and context
- Read README.md for project overview and setup
- Analyze package.json for dependencies and scripts
- Review project structure and organization patterns
2. **Codebase Analysis**
- Examine key source files and entry points
- Identify architectural patterns and frameworks
- Analyze code quality, structure, and conventions
- Review testing strategy and coverage
3. **Technical Assessment**
- Evaluate current tech stack and dependencies
- Identify potential security vulnerabilities
- Assess performance and scalability considerations
- Review configuration and environment setup
4. **Strategic Recommendations**
- Suggest architectural improvements
- Recommend code quality enhancements
- Identify technical debt and refactoring opportunities
- Propose new feature development approaches
**Report Structure:**
- **Project Overview**: Purpose, architecture, and tech stack
- **Current State**: Strengths, weaknesses, and opportunities
- **Code Quality**: Patterns, conventions, and areas for improvement
- **Technical Recommendations**: Specific actionable suggestions
- **Development Workflow**: Best practices and next steps
**Key Analysis Areas:**
- Project structure and organization
- Code patterns and architectural decisions
- Dependencies and security considerations
- Testing strategy and coverage
- Development workflow and tooling
- Performance and scalability factors
## Phase 4: Continuous Context Awareness
After initial priming, maintain context awareness:
- **For New Projects**: Focus on rapid development and feature delivery
- **For Existing Projects**: Provide ongoing analysis and improvement suggestions
- **For Both**: Track progress, identify blockers, and suggest optimizations
## 🎯 Key Success Factors
### For New Projects:
1. **Act immediately** - Don't just plan, start building
2. **Use TodoWrite** - Track concrete next steps
3. **Build incrementally** - Working software over documentation
4. **Clean commits** - No Claude Code signatures ever
5. **Follow tech stack** - Use specified technologies consistently
### For Existing Projects:
1. **Comprehensive analysis** - Understand before suggesting
2. **Actionable recommendations** - Provide specific improvements
3. **Respect existing patterns** - Build on current architecture
4. **Identify quick wins** - Suggest immediate improvements
5. **Long-term vision** - Plan strategic enhancements
## 🚀 Execution Directive
**NEW PROJECT**: You are the Lead Software Architect. Your job is to build working software immediately. Use TodoWrite, start coding, and make it real.
**EXISTING PROJECT**: You are the Senior Code Analyst. Your job is to understand deeply and guide effectively. Provide specific, actionable insights.
Execute the appropriate mode based on your project state analysis above.`;
}
//# sourceMappingURL=slashCommands.js.map