|
| 1 | +# Claude Code Configuration - SPARC Development Environment |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +This project uses the SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology for systematic Test-Driven Development with AI assistance through Claude-Flow orchestration. |
| 5 | + |
| 6 | +## SPARC Development Commands |
| 7 | + |
| 8 | +### Core SPARC Commands |
| 9 | +- `./claude-flow sparc modes`: List all available SPARC development modes |
| 10 | +- `./claude-flow sparc run <mode> "<task>"`: Execute specific SPARC mode for a task |
| 11 | +- `./claude-flow sparc tdd "<feature>"`: Run complete TDD workflow using SPARC methodology |
| 12 | +- `./claude-flow sparc info <mode>`: Get detailed information about a specific mode |
| 13 | + |
| 14 | +### Standard Build Commands |
| 15 | +- `npm run build`: Build the project |
| 16 | +- `npm run test`: Run the test suite |
| 17 | +- `npm run lint`: Run linter and format checks |
| 18 | +- `npm run typecheck`: Run TypeScript type checking |
| 19 | + |
| 20 | +## SPARC Methodology Workflow |
| 21 | + |
| 22 | +### 1. Specification Phase |
| 23 | +```bash |
| 24 | +# Create detailed specifications and requirements |
| 25 | +./claude-flow sparc run spec-pseudocode "Define user authentication requirements" |
| 26 | +``` |
| 27 | +- Define clear functional requirements |
| 28 | +- Document edge cases and constraints |
| 29 | +- Create user stories and acceptance criteria |
| 30 | +- Establish non-functional requirements |
| 31 | + |
| 32 | +### 2. Pseudocode Phase |
| 33 | +```bash |
| 34 | +# Develop algorithmic logic and data flows |
| 35 | +./claude-flow sparc run spec-pseudocode "Create authentication flow pseudocode" |
| 36 | +``` |
| 37 | +- Break down complex logic into steps |
| 38 | +- Define data structures and interfaces |
| 39 | +- Plan error handling and edge cases |
| 40 | +- Create modular, testable components |
| 41 | + |
| 42 | +### 3. Architecture Phase |
| 43 | +```bash |
| 44 | +# Design system architecture and component structure |
| 45 | +./claude-flow sparc run architect "Design authentication service architecture" |
| 46 | +``` |
| 47 | +- Create system diagrams and component relationships |
| 48 | +- Define API contracts and interfaces |
| 49 | +- Plan database schemas and data flows |
| 50 | +- Establish security and scalability patterns |
| 51 | + |
| 52 | +### 4. Refinement Phase (TDD Implementation) |
| 53 | +```bash |
| 54 | +# Execute Test-Driven Development cycle |
| 55 | +./claude-flow sparc tdd "implement user authentication system" |
| 56 | +``` |
| 57 | + |
| 58 | +**TDD Cycle:** |
| 59 | +1. **Red**: Write failing tests first |
| 60 | +2. **Green**: Implement minimal code to pass tests |
| 61 | +3. **Refactor**: Optimize and clean up code |
| 62 | +4. **Repeat**: Continue until feature is complete |
| 63 | + |
| 64 | +### 5. Completion Phase |
| 65 | +```bash |
| 66 | +# Integration, documentation, and validation |
| 67 | +./claude-flow sparc run integration "integrate authentication with user management" |
| 68 | +``` |
| 69 | +- Integrate all components |
| 70 | +- Perform end-to-end testing |
| 71 | +- Create comprehensive documentation |
| 72 | +- Validate against original requirements |
| 73 | + |
| 74 | +## SPARC Mode Reference |
| 75 | + |
| 76 | +### Development Modes |
| 77 | +- **`architect`**: System design and architecture planning |
| 78 | +- **`code`**: Clean, modular code implementation |
| 79 | +- **`tdd`**: Test-driven development and testing |
| 80 | +- **`spec-pseudocode`**: Requirements and algorithmic planning |
| 81 | +- **`integration`**: System integration and coordination |
| 82 | + |
| 83 | +### Quality Assurance Modes |
| 84 | +- **`debug`**: Troubleshooting and bug resolution |
| 85 | +- **`security-review`**: Security analysis and vulnerability assessment |
| 86 | +- **`refinement-optimization-mode`**: Performance optimization and refactoring |
| 87 | + |
| 88 | +### Support Modes |
| 89 | +- **`docs-writer`**: Documentation creation and maintenance |
| 90 | +- **`devops`**: Deployment and infrastructure management |
| 91 | +- **`mcp`**: External service integration |
| 92 | +- **`swarm`**: Multi-agent coordination for complex tasks |
| 93 | + |
| 94 | +## Claude Code Slash Commands |
| 95 | + |
| 96 | +Claude Code slash commands are available in `.claude/commands/`: |
| 97 | + |
| 98 | +### Project Commands |
| 99 | +- `/sparc`: Execute SPARC methodology workflows |
| 100 | +- `/sparc-<mode>`: Run specific SPARC mode (e.g., /sparc-architect) |
| 101 | +- `/claude-flow-help`: Show all Claude-Flow commands |
| 102 | +- `/claude-flow-memory`: Interact with memory system |
| 103 | +- `/claude-flow-swarm`: Coordinate multi-agent swarms |
| 104 | + |
| 105 | +### Using Slash Commands |
| 106 | +1. Type `/` in Claude Code to see available commands |
| 107 | +2. Select a command or type its name |
| 108 | +3. Commands are context-aware and project-specific |
| 109 | +4. Custom commands can be added to `.claude/commands/` |
| 110 | + |
| 111 | +## Code Style and Best Practices |
| 112 | + |
| 113 | +### SPARC Development Principles |
| 114 | +- **Modular Design**: Keep files under 500 lines, break into logical components |
| 115 | +- **Environment Safety**: Never hardcode secrets or environment-specific values |
| 116 | +- **Test-First**: Always write tests before implementation (Red-Green-Refactor) |
| 117 | +- **Clean Architecture**: Separate concerns, use dependency injection |
| 118 | +- **Documentation**: Maintain clear, up-to-date documentation |
| 119 | + |
| 120 | +### Coding Standards |
| 121 | +- Use TypeScript for type safety and better tooling |
| 122 | +- Follow consistent naming conventions (camelCase for variables, PascalCase for classes) |
| 123 | +- Implement proper error handling and logging |
| 124 | +- Use async/await for asynchronous operations |
| 125 | +- Prefer composition over inheritance |
| 126 | + |
| 127 | +### Memory and State Management |
| 128 | +- Use claude-flow memory system for persistent state across sessions |
| 129 | +- Store progress and findings using namespaced keys |
| 130 | +- Query previous work before starting new tasks |
| 131 | +- Export/import memory for backup and sharing |
| 132 | + |
| 133 | +## SPARC Memory Integration |
| 134 | + |
| 135 | +### Memory Commands for SPARC Development |
| 136 | +```bash |
| 137 | +# Store project specifications |
| 138 | +./claude-flow memory store spec_auth "User authentication requirements and constraints" |
| 139 | + |
| 140 | +# Store architectural decisions |
| 141 | +./claude-flow memory store arch_decisions "Database schema and API design choices" |
| 142 | + |
| 143 | +# Store test results and coverage |
| 144 | +./claude-flow memory store test_coverage "Authentication module: 95% coverage, all tests passing" |
| 145 | + |
| 146 | +# Query previous work |
| 147 | +./claude-flow memory query auth_implementation |
| 148 | + |
| 149 | +# Export project memory |
| 150 | +./claude-flow memory export project_backup.json |
| 151 | +``` |
| 152 | + |
| 153 | +### Memory Namespaces |
| 154 | +- **`spec`**: Requirements and specifications |
| 155 | +- **`arch`**: Architecture and design decisions |
| 156 | +- **`impl`**: Implementation notes and code patterns |
| 157 | +- **`test`**: Test results and coverage reports |
| 158 | +- **`debug`**: Bug reports and resolution notes |
| 159 | + |
| 160 | +## Workflow Examples |
| 161 | + |
| 162 | +### Feature Development Workflow |
| 163 | +```bash |
| 164 | +# 1. Start with specification |
| 165 | +./claude-flow sparc run spec-pseudocode "User profile management feature" |
| 166 | + |
| 167 | +# 2. Design architecture |
| 168 | +./claude-flow sparc run architect "Profile service architecture with data validation" |
| 169 | + |
| 170 | +# 3. Implement with TDD |
| 171 | +./claude-flow sparc tdd "user profile CRUD operations" |
| 172 | + |
| 173 | +# 4. Security review |
| 174 | +./claude-flow sparc run security-review "profile data access and validation" |
| 175 | + |
| 176 | +# 5. Integration testing |
| 177 | +./claude-flow sparc run integration "profile service with authentication system" |
| 178 | + |
| 179 | +# 6. Documentation |
| 180 | +./claude-flow sparc run docs-writer "profile service API documentation" |
| 181 | +``` |
| 182 | + |
| 183 | +### Bug Fix Workflow |
| 184 | +```bash |
| 185 | +# 1. Debug and analyze |
| 186 | +./claude-flow sparc run debug "authentication token expiration issue" |
| 187 | + |
| 188 | +# 2. Write regression tests |
| 189 | +./claude-flow sparc run tdd "token refresh mechanism tests" |
| 190 | + |
| 191 | +# 3. Implement fix |
| 192 | +./claude-flow sparc run code "fix token refresh in authentication service" |
| 193 | + |
| 194 | +# 4. Security review |
| 195 | +./claude-flow sparc run security-review "token handling security implications" |
| 196 | +``` |
| 197 | + |
| 198 | +## Configuration Files |
| 199 | + |
| 200 | +### Claude Code Integration |
| 201 | +- **`.claude/commands/`**: Claude Code slash commands for all SPARC modes |
| 202 | +- **`.claude/logs/`**: Conversation and session logs |
| 203 | + |
| 204 | +### SPARC Configuration |
| 205 | +- **`.roomodes`**: SPARC mode definitions and configurations (auto-generated) |
| 206 | +- **`.roo/`**: SPARC templates and workflows (auto-generated) |
| 207 | + |
| 208 | +### Claude-Flow Configuration |
| 209 | +- **`memory/`**: Persistent memory and session data |
| 210 | +- **`coordination/`**: Multi-agent coordination settings |
| 211 | +- **`CLAUDE.md`**: Project instructions for Claude Code |
| 212 | + |
| 213 | +## Git Workflow Integration |
| 214 | + |
| 215 | +### Commit Strategy with SPARC |
| 216 | +- **Specification commits**: After completing requirements analysis |
| 217 | +- **Architecture commits**: After design phase completion |
| 218 | +- **TDD commits**: After each Red-Green-Refactor cycle |
| 219 | +- **Integration commits**: After successful component integration |
| 220 | +- **Documentation commits**: After completing documentation updates |
| 221 | + |
| 222 | +### Branch Strategy |
| 223 | +- **`feature/sparc-<feature-name>`**: Feature development with SPARC methodology |
| 224 | +- **`hotfix/sparc-<issue>`**: Bug fixes using SPARC debugging workflow |
| 225 | +- **`refactor/sparc-<component>`**: Refactoring using optimization mode |
| 226 | + |
| 227 | +## Troubleshooting |
| 228 | + |
| 229 | +### Common SPARC Issues |
| 230 | +- **Mode not found**: Check `.roomodes` file exists and is valid JSON |
| 231 | +- **Memory persistence**: Ensure `memory/` directory has write permissions |
| 232 | +- **Tool access**: Verify required tools are available for the selected mode |
| 233 | +- **Namespace conflicts**: Use unique memory namespaces for different features |
| 234 | + |
| 235 | +### Debug Commands |
| 236 | +```bash |
| 237 | +# Check SPARC configuration |
| 238 | +./claude-flow sparc modes |
| 239 | + |
| 240 | +# Verify memory system |
| 241 | +./claude-flow memory stats |
| 242 | + |
| 243 | +# Check system status |
| 244 | +./claude-flow status |
| 245 | + |
| 246 | +# View detailed mode information |
| 247 | +./claude-flow sparc info <mode-name> |
| 248 | +``` |
| 249 | + |
| 250 | +## Project Architecture |
| 251 | + |
| 252 | +This SPARC-enabled project follows a systematic development approach: |
| 253 | +- **Clear separation of concerns** through modular design |
| 254 | +- **Test-driven development** ensuring reliability and maintainability |
| 255 | +- **Iterative refinement** for continuous improvement |
| 256 | +- **Comprehensive documentation** for team collaboration |
| 257 | +- **AI-assisted development** through specialized SPARC modes |
| 258 | + |
| 259 | +## Important Notes |
| 260 | + |
| 261 | +- Always run tests before committing (`npm run test`) |
| 262 | +- Use SPARC memory system to maintain context across sessions |
| 263 | +- Follow the Red-Green-Refactor cycle during TDD phases |
| 264 | +- Document architectural decisions in memory for future reference |
| 265 | +- Regular security reviews for any authentication or data handling code |
| 266 | +- Claude Code slash commands provide quick access to SPARC modes |
| 267 | + |
| 268 | +For more information about SPARC methodology, see: https://github.com/ruvnet/claude-code-flow/docs/sparc.md |
0 commit comments