UNPKG

claude-flow-depth

Version:

DEPTH Methodology Installer - Ousterhout-First Development for Claude Code

213 lines (167 loc) 4.99 kB
# DEPTH Methodology Guide This project implements the DEPTH methodology - an Ousterhout-first approach to software development. ## What is DEPTH? **DEPTH** stands for: - **D**esign-Twice: Always create two design alternatives - **E**liminate complexity: Simplify interfaces ruthlessly - **P**ull complexity down: Push complexity into modules - **T**rade-off documentation: 10-20% strategic investment - **H**ide implementation: Maximum information hiding ## Core Principles ### 1. Deep Modules Create modules with simple interfaces but rich functionality. **Good Example:** ```javascript // Simple interface logger.info('User logged in', { userId: 123 }); // Hides complex implementation: // - Formatting logic // - Output routing // - Level checking // - Timestamp handling ``` ### 2. Information Hiding Hide implementation details from module users. **Good Example:** ```javascript // Public interface - simple const app = await createApp(); await app.start(); // Hidden complexity: // - Service initialization // - Configuration loading // - Error handling // - State management ``` ### 3. Strategic Investment Dedicate 10-20% of development time to long-term improvements. **Examples:** - Refactoring for better abstractions - Improving documentation - Building reusable tools - Architecture improvements ## Using DEPTH Commands ### Complete Workflow ```bash # Run full DEPTH methodology npm run depth ``` ### Individual Phases ```bash # Phase 1: Create design alternatives npm run depth:design # Phase 2: Simplify interfaces npm run depth:simplify # Phase 3: Allocate complexity npm run depth:allocate # Phase 4: Plan strategic investment npm run depth:invest # Phase 5: Hide implementation npm run depth:hide ``` ## Quality Gates Each phase has specific quality requirements: ### Design-Twice Phase - [ ] Two distinct design alternatives created - [ ] Trade-off analysis completed - [ ] Decision documented with rationale ### Interface Simplification Phase - [ ] Interface complexity < 0.4 - [ ] Simplified interfaces maintain functionality - [ ] Usage examples demonstrate simplicity ### Complexity Allocation Phase - [ ] Complexity pushed into modules - [ ] Information hiding strategy defined - [ ] Module boundaries clearly defined ### Strategic Investment Phase - [ ] Strategic investment 10-20% of time - [ ] Long-term implications assessed - [ ] Technical debt plan created ### Implementation Hiding Phase - [ ] Implementation details hidden - [ ] Comments explain design decisions - [ ] Code follows information hiding principles ## Best Practices ### 1. Interface Design - Keep public APIs minimal - Hide complex parameters - Use sensible defaults - Provide clear abstractions ### 2. Module Organization - One responsibility per module - Simple interfaces, complex implementations - Clear boundaries between modules - Minimize inter-module dependencies ### 3. Code Documentation - Explain design decisions, not implementation - Document trade-offs and alternatives considered - Focus on why, not what - Keep comments up-to-date with code ### 4. Strategic Thinking - Regularly assess long-term architecture - Invest in tools and abstractions - Consider future maintenance costs - Plan for scalability early ## Common Anti-Patterns ### ❌ Shallow Modules ```javascript // Bad: Simple interface, simple implementation function add(a, b) { return a + b; } ``` ### ❌ Information Leakage ```javascript // Bad: Exposing internal structure class Database { constructor() { this.connection = mysql.createConnection(...); this.queryCache = new Map(); } } ``` ### ❌ Complex Interfaces ```javascript // Bad: Too many parameters, complex options function processData(data, format, validation, transform, output, options) { // Complex interface } ``` ## Measuring Success ### Module Depth Ratio Target: > 0.6 ``` Depth = Implementation_Complexity / Interface_Complexity ``` ### Interface Complexity Score Target: < 0.4 ``` Complexity = (Parameters + Methods + Options) / Total_Functionality ``` ### Strategic Investment Percentage Target: 10-20% ``` Strategic_Time / Total_Development_Time ``` ### Information Hiding Effectiveness Target: > 80% ``` Hidden_Details / Total_Implementation_Details ``` ## Integration with Claude Flow DEPTH methodology integrates with Claude Flow for: - **Automated quality checking** - **Design alternative generation** - **Complexity analysis** - **Strategic planning assistance** Use Claude Flow commands for enhanced DEPTH execution: ```bash # Initialize coordinated DEPTH session npx claude-flow@alpha swarm init --methodology depth # Spawn DEPTH-aware agents npx claude-flow@alpha agent spawn --type architect --depth-mode true ``` ## Resources - [John Ousterhout's "A Philosophy of Software Design"](https://web.stanford.edu/~ouster/cgi-bin/book.php) - [DEPTH Methodology Paper](https://github.com/ruvnet/claude-flow) - [Claude Flow Documentation](https://github.com/ruvnet/claude-flow)