SuperClaude/superclaude/examples/deep_research_workflows.md
kazuki nakai 050d5ea2ab
refactor: PEP8 compliance - directory rename and code formatting (#425)
* fix(orchestration): add WebFetch auto-trigger for infrastructure configuration

Problem: Infrastructure configuration changes (e.g., Traefik port settings)
were being made based on assumptions without consulting official documentation,
violating the 'Evidence > assumptions' principle in PRINCIPLES.md.

Solution:
- Added Infrastructure Configuration Validation section to MODE_Orchestration.md
- Auto-triggers WebFetch for infrastructure tools (Traefik, nginx, Docker, etc.)
- Enforces MODE_DeepResearch activation for investigation
- BLOCKS assumption-based configuration changes

Testing: Verified WebFetch successfully retrieves Traefik official docs (port 80 default)

This prevents production outages from infrastructure misconfiguration by ensuring
all technical recommendations are backed by official documentation.

* feat: Add PM Agent (Project Manager Agent) for seamless orchestration

Introduces PM Agent as the default orchestration layer that coordinates
all sub-agents and manages workflows automatically.

Key Features:
- Default orchestration: All user interactions handled by PM Agent
- Auto-delegation: Intelligent sub-agent selection based on task analysis
- Docker Gateway integration: Zero-token baseline with dynamic MCP loading
- Self-improvement loop: Automatic documentation of patterns and mistakes
- Optional override: Users can specify sub-agents explicitly if desired

Architecture:
- Agent spec: SuperClaude/Agents/pm-agent.md
- Command: SuperClaude/Commands/pm.md
- Updated docs: README.md (15→16 agents), agents.md (new Orchestration category)

User Experience:
- Default: PM Agent handles everything (seamless, no manual routing)
- Optional: Explicit --agent flag for direct sub-agent access
- Both modes available simultaneously (no user downside)

Implementation Status:
-  Specification complete
-  Documentation complete
-  Prototype implementation needed
-  Docker Gateway integration needed
-  Testing and validation needed

Refs: kazukinakai/docker-mcp-gateway (IRIS MCP Gateway integration)

* feat: Add Agent Orchestration rules for PM Agent default activation

Implements PM Agent as the default orchestration layer in RULES.md.

Key Changes:
- New 'Agent Orchestration' section (CRITICAL priority)
- PM Agent receives ALL user requests by default
- Manual override with @agent-[name] bypasses PM Agent
- Agent Selection Priority clearly defined:
  1. Manual override → Direct routing
  2. Default → PM Agent → Auto-delegation
  3. Delegation based on keywords, file types, complexity, context

User Experience:
- Default: PM Agent handles everything (seamless)
- Override: @agent-[name] for direct specialist access
- Transparent: PM Agent reports delegation decisions

This establishes PM Agent as the orchestration layer while
respecting existing auto-activation patterns and manual overrides.

Next Steps:
- Local testing in agiletec project
- Iteration based on actual behavior
- Documentation updates as needed

* refactor(pm-agent): redesign as self-improvement meta-layer

Problem Resolution:
PM Agent's initial design competed with existing auto-activation for task routing,
creating confusion about orchestration responsibilities and adding unnecessary complexity.

Design Change:
Redefined PM Agent as a meta-layer agent that operates AFTER specialist agents
complete tasks, focusing on:
- Post-implementation documentation and pattern recording
- Immediate mistake analysis with prevention checklists
- Monthly documentation maintenance and noise reduction
- Pattern extraction and knowledge synthesis

Two-Layer Orchestration System:
1. Task Execution Layer: Existing auto-activation handles task routing (unchanged)
2. Self-Improvement Layer: PM Agent meta-layer handles documentation (new)

Files Modified:
- SuperClaude/Agents/pm-agent.md: Complete rewrite with meta-layer design
  - Category: orchestration → meta
  - Triggers: All user interactions → Post-implementation, mistakes, monthly
  - Behavioral Mindset: Continuous learning system
  - Self-Improvement Workflow: BEFORE/DURING/AFTER/MISTAKE RECOVERY/MAINTENANCE

- SuperClaude/Core/RULES.md: Agent Orchestration section updated
  - Split into Task Execution Layer + Self-Improvement Layer
  - Added orchestration flow diagram
  - Clarified PM Agent activates AFTER task completion

- README.md: Updated PM Agent description
  - "orchestrates all interactions" → "ensures continuous learning"

- Docs/User-Guide/agents.md: PM Agent section rewritten
  - Section: Orchestration Agent → Meta-Layer Agent
  - Expertise: Project orchestration → Self-improvement workflow executor
  - Examples: Task coordination → Post-implementation documentation

- PR_DOCUMENTATION.md: Comprehensive PR documentation added
  - Summary, motivation, changes, testing, breaking changes
  - Two-layer orchestration system diagram
  - Verification checklist

Integration Validated:
Tested with agiletec project's self-improvement-workflow.md:
 PM Agent aligns with existing BEFORE/DURING/AFTER/MISTAKE RECOVERY phases
 Complements (not competes with) existing workflow
 agiletec workflow defines WHAT, PM Agent defines WHO executes it

Breaking Changes: None
- Existing auto-activation continues unchanged
- Specialist agents unaffected
- User workflows remain the same
- New capability: Automatic documentation and knowledge maintenance

Value Proposition:
Transforms SuperClaude into a continuously learning system that accumulates
knowledge, prevents recurring mistakes, and maintains fresh documentation
without manual intervention.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add Claude Code conversation history management research

Research covering .jsonl file structure, performance impact, and retention policies.

Content:
- Claude Code .jsonl file format and message types
- Performance issues from GitHub (memory leaks, conversation compaction)
- Retention policies (consumer vs enterprise)
- Rotation recommendations based on actual data
- File history snapshot tracking mechanics

Source: Moved from agiletec project (research applicable to all Claude Code projects)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add Development documentation structure

Phase 1: Documentation Structure complete

- Add Docs/Development/ directory for development documentation
- Add ARCHITECTURE.md - System architecture with PM Agent meta-layer
- Add ROADMAP.md - 5-phase development plan with checkboxes
- Add TASKS.md - Daily task tracking with progress indicators
- Add PROJECT_STATUS.md - Current status dashboard and metrics
- Add pm-agent-integration.md - Implementation guide for PM Agent mode

This establishes comprehensive documentation foundation for:
- System architecture understanding
- Development planning and tracking
- Implementation guidance
- Progress visibility

Related: #pm-agent-mode #documentation #phase-1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: PM Agent session lifecycle and PDCA implementation

Phase 2: PM Agent Mode Integration (Design Phase)

Commands/pm.md updates:
- Add "Always-Active Foundation Layer" concept
- Add Session Lifecycle (Session Start/During Work/Session End)
- Add PDCA Cycle (Plan/Do/Check/Act) automation
- Add Serena MCP Memory Integration (list/read/write_memory)
- Document auto-activation triggers

Agents/pm-agent.md updates:
- Add Session Start Protocol (MANDATORY auto-activation)
- Add During Work PDCA Cycle with example workflows
- Add Session End Protocol with state preservation
- Add PDCA Self-Evaluation Pattern
- Add Documentation Strategy (temp → patterns/mistakes)
- Add Memory Operations Reference

Key Features:
- Session start auto-activation for context restoration
- 30-minute checkpoint saves during work
- Self-evaluation with think_about_* operations
- Systematic documentation lifecycle
- Knowledge evolution to CLAUDE.md

Implementation Status:
-  Design complete (Commands/pm.md, Agents/pm-agent.md)
-  Implementation pending (Core components)
-  Serena MCP integration pending

Salvaged from mistaken development in ~/.claude directory

Related: #pm-agent-mode #session-lifecycle #pdca-cycle #phase-2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: disable Serena MCP auto-browser launch

Disable web dashboard and GUI log window auto-launch in Serena MCP server
to prevent intrusive browser popups on startup. Users can still manually
access the dashboard at http://localhost:24282/dashboard/ if needed.

Changes:
- Add CLI flags to Serena run command:
  - --enable-web-dashboard false
  - --enable-gui-log-window false
- Ensures Git-tracked configuration (no reliance on ~/.serena/serena_config.yml)
- Aligns with AIRIS MCP Gateway integration approach

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: rename directories to lowercase for PEP8 compliance

- Rename superclaude/Agents -> superclaude/agents
- Rename superclaude/Commands -> superclaude/commands
- Rename superclaude/Core -> superclaude/core
- Rename superclaude/Examples -> superclaude/examples
- Rename superclaude/MCP -> superclaude/mcp
- Rename superclaude/Modes -> superclaude/modes

This change follows Python PEP8 naming conventions for package directories.

* style: fix PEP8 violations and update package name to lowercase

Changes:
- Format all Python files with black (43 files reformatted)
- Update package name from 'SuperClaude' to 'superclaude' in pyproject.toml
- Fix import statements to use lowercase package name
- Add missing imports (timedelta, __version__)
- Remove old SuperClaude.egg-info directory

PEP8 violations reduced from 2672 to 701 (mostly E501 line length due to black's 88 char vs flake8's 79 char limit).

* docs: add PM Agent development documentation

Add comprehensive PM Agent development documentation:
- PM Agent ideal workflow (7-phase autonomous cycle)
- Project structure understanding (Git vs installed environment)
- Installation flow understanding (CommandsComponent behavior)
- Task management system (current-tasks.md)

Purpose: Eliminate repeated explanations and enable autonomous PDCA cycles

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(pm-agent): add self-correcting execution and warning investigation culture

## Changes

### superclaude/commands/pm.md
- Add "Self-Correcting Execution" section with root cause analysis protocol
- Add "Warning/Error Investigation Culture" section enforcing zero-tolerance for dismissal
- Define error detection protocol: STOP → Investigate → Hypothesis → Different Solution → Execute
- Document anti-patterns (retry without understanding) and correct patterns (research-first)

### docs/Development/hypothesis-pm-autonomous-enhancement-2025-10-14.md
- Add PDCA workflow hypothesis document for PM Agent autonomous enhancement

## Rationale

PM Agent must never retry failed operations without understanding root causes.
All warnings and errors require investigation via context7/WebFetch/documentation
to ensure production-quality code and prevent technical debt accumulation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(installer): add airis-mcp-gateway MCP server option

## Changes

- Add airis-mcp-gateway to MCP server options in installer
- Configuration: GitHub-based installation via uvx
- Repository: https://github.com/oraios/airis-mcp-gateway
- Purpose: Dynamic MCP Gateway for zero-token baseline and on-demand tool loading

## Implementation

Added to setup/components/mcp.py self.mcp_servers dictionary with:
- install_method: github
- install_command: uvx test installation
- run_command: uvx runtime execution
- required: False (optional server)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: kazuki <kazuki@kazukinoMacBook-Air.local>
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-14 08:47:09 +05:30

495 lines
12 KiB
Markdown

# Deep Research Workflows
## Example 1: Planning-Only Strategy
### Scenario
Clear research question: "Latest TensorFlow 3.0 features"
### Execution
```bash
/sc:research "Latest TensorFlow 3.0 features" --strategy planning-only --depth standard
```
### Workflow
```yaml
1. Planning (Immediate):
- Decompose: Official docs, changelog, tutorials
- No user clarification needed
2. Execution:
- Hop 1: Official TensorFlow documentation
- Hop 2: Recent tutorials and examples
- Confidence: 0.85 achieved
3. Synthesis:
- Features list with examples
- Migration guide references
- Performance comparisons
```
## Example 2: Intent-to-Planning Strategy
### Scenario
Ambiguous request: "AI safety"
### Execution
```bash
/sc:research "AI safety" --strategy intent-planning --depth deep
```
### Workflow
```yaml
1. Intent Clarification:
Questions:
- "Are you interested in technical AI alignment, policy/governance, or current events?"
- "What's your background level (researcher, developer, general interest)?"
- "Any specific AI systems or risks of concern?"
2. User Response:
- "Technical alignment for LLMs, researcher level"
3. Refined Planning:
- Focus on alignment techniques
- Academic sources priority
- Include recent papers
4. Multi-Hop Execution:
- Hop 1: Recent alignment papers
- Hop 2: Key researchers and labs
- Hop 3: Emerging techniques
- Hop 4: Open problems
5. Self-Reflection:
- Coverage: Complete ✓
- Depth: Adequate ✓
- Confidence: 0.82
```
## Example 3: Unified Intent-Planning with Replanning
### Scenario
Complex research: "Build AI startup competitive analysis"
### Execution
```bash
/sc:research "Build AI startup competitive analysis" --strategy unified --hops 5
```
### Workflow
```yaml
1. Initial Plan Presentation:
Proposed Research Areas:
- Current AI startup landscape
- Funding and valuations
- Technology differentiators
- Market positioning
- Growth strategies
"Does this cover your needs? Any specific competitors or aspects to focus on?"
2. User Adjustment:
"Focus on code generation tools, include pricing and technical capabilities"
3. Revised Multi-Hop Research:
- Hop 1: List of code generation startups
- Hop 2: Technical capabilities comparison
- Hop 3: Pricing and business models
- Hop 4: Customer reviews and adoption
- Hop 5: Investment and growth metrics
4. Mid-Research Replanning:
- Low confidence on technical details (0.55)
- Switch to Playwright for interactive demos
- Add GitHub repository analysis
5. Quality Gate Check:
- Technical coverage: Improved to 0.78 ✓
- Pricing data: Complete 0.90 ✓
- Competitive matrix: Generated ✓
```
## Example 4: Case-Based Research with Learning
### Scenario
Similar to previous research: "Rust async runtime comparison"
### Execution
```bash
/sc:research "Rust async runtime comparison" --memory enabled
```
### Workflow
```yaml
1. Case Retrieval:
Found Similar Case:
- "Go concurrency patterns" research
- Successful pattern: Technical benchmarks + code examples + community feedback
2. Adapted Strategy:
- Use similar structure for Rust
- Focus on: Tokio, async-std, smol
- Include benchmarks and examples
3. Execution with Known Patterns:
- Skip broad searches
- Direct to technical sources
- Use proven extraction methods
4. New Learning Captured:
- Rust community prefers different metrics than Go
- Crates.io provides useful statistics
- Discord communities have valuable discussions
5. Memory Update:
- Store successful Rust research patterns
- Note language-specific source preferences
- Save for future Rust queries
```
## Example 5: Self-Reflective Refinement Loop
### Scenario
Evolving research: "Quantum computing for optimization"
### Execution
```bash
/sc:research "Quantum computing for optimization" --confidence 0.8 --depth exhaustive
```
### Workflow
```yaml
1. Initial Research Phase:
- Academic papers collected
- Basic concepts understood
- Confidence: 0.65 (below threshold)
2. Self-Reflection Analysis:
Gaps Identified:
- Practical implementations missing
- No industry use cases
- Mathematical details unclear
3. Replanning Decision:
- Add industry reports
- Include video tutorials for math
- Search for code implementations
4. Enhanced Research:
- Hop 1→2: Papers → Authors → Implementations
- Hop 3→4: Companies → Case studies
- Hop 5: Tutorial videos for complex math
5. Quality Achievement:
- Confidence raised to 0.82 ✓
- Comprehensive coverage achieved
- Multiple perspectives included
```
## Example 6: Technical Documentation Research with Playwright
### Scenario
Research the latest Next.js 14 App Router features
### Execution
```bash
/sc:research "Next.js 14 App Router complete guide" --depth deep --scrape selective --screenshots
```
### Workflow
```yaml
1. Tavily Search:
- Find official docs, tutorials, blog posts
- Identify JavaScript-heavy documentation sites
2. URL Analysis:
- Next.js docs → JavaScript rendering required
- Blog posts → Static content, Tavily sufficient
- Video tutorials → Need transcript extraction
3. Playwright Navigation:
- Navigate to official documentation
- Handle interactive code examples
- Capture screenshots of UI components
4. Dynamic Extraction:
- Extract code samples
- Capture interactive demos
- Document routing patterns
5. Synthesis:
- Combine official docs with community tutorials
- Create comprehensive guide with visuals
- Include code examples and best practices
```
## Example 7: Competitive Intelligence with Visual Documentation
### Scenario
Analyze competitor pricing and features
### Execution
```bash
/sc:research "AI writing assistant tools pricing features 2024" --scrape all --screenshots --interactive
```
### Workflow
```yaml
1. Market Discovery:
- Tavily finds: Jasper, Copy.ai, Writesonic, etc.
- Identify pricing pages and feature lists
2. Complexity Assessment:
- Dynamic pricing calculators detected
- Interactive feature comparisons found
- Login-gated content identified
3. Playwright Extraction:
- Navigate to each pricing page
- Interact with pricing sliders
- Capture screenshots of pricing tiers
4. Feature Analysis:
- Extract feature matrices
- Compare capabilities
- Document limitations
5. Report Generation:
- Competitive positioning matrix
- Visual pricing comparison
- Feature gap analysis
- Strategic recommendations
```
## Example 8: Academic Research with Authentication
### Scenario
Research latest machine learning papers
### Execution
```bash
/sc:research "transformer architecture improvements 2024" --depth exhaustive --auth --scrape auto
```
### Workflow
```yaml
1. Academic Search:
- Tavily finds papers on arXiv, IEEE, ACM
- Identify open vs. gated content
2. Access Strategy:
- arXiv: Direct access, no auth needed
- IEEE: Institutional access required
- ACM: Mixed access levels
3. Extraction Approach:
- Public papers: Tavily extraction
- Gated content: Playwright with auth
- PDFs: Download and process
4. Citation Network:
- Follow reference chains
- Identify key contributors
- Map research lineage
5. Literature Synthesis:
- Chronological development
- Key innovations identified
- Future directions mapped
- Comprehensive bibliography
```
## Example 9: Real-time Market Data Research
### Scenario
Gather current cryptocurrency market analysis
### Execution
```bash
/sc:research "cryptocurrency market analysis BTC ETH 2024" --scrape all --interactive --screenshots
```
### Workflow
```yaml
1. Market Discovery:
- Find: CoinMarketCap, CoinGecko, TradingView
- Identify real-time data sources
2. Dynamic Content Handling:
- Playwright loads live charts
- Capture price movements
- Extract volume data
3. Interactive Analysis:
- Interact with chart timeframes
- Toggle technical indicators
- Capture different views
4. Data Synthesis:
- Current market conditions
- Technical analysis
- Sentiment indicators
- Visual documentation
5. Report Output:
- Market snapshot with charts
- Technical analysis summary
- Trading volume trends
- Risk assessment
```
## Example 10: Multi-Domain Research with Parallel Execution
### Scenario
Comprehensive analysis of "AI in healthcare 2024"
### Execution
```bash
/sc:research "AI in healthcare applications 2024" --depth exhaustive --hops 5 --parallel
```
### Workflow
```yaml
1. Domain Decomposition:
Parallel Searches:
- Medical AI applications
- Regulatory landscape
- Market analysis
- Technical implementations
- Ethical considerations
2. Multi-Hop Exploration:
Each Domain:
- Hop 1: Broad landscape
- Hop 2: Key players
- Hop 3: Case studies
- Hop 4: Challenges
- Hop 5: Future trends
3. Cross-Domain Synthesis:
- Medical ↔ Technical connections
- Regulatory ↔ Market impacts
- Ethical ↔ Implementation constraints
4. Quality Assessment:
- Coverage: All domains addressed
- Depth: Sufficient detail per domain
- Integration: Cross-domain insights
- Confidence: 0.87 achieved
5. Comprehensive Report:
- Executive summary
- Domain-specific sections
- Integrated analysis
- Strategic recommendations
- Visual evidence
```
## Advanced Workflow Patterns
### Pattern 1: Iterative Deepening
```yaml
Round_1:
- Broad search for landscape
- Identify key areas
Round_2:
- Deep dive into key areas
- Extract detailed information
Round_3:
- Fill specific gaps
- Resolve contradictions
Round_4:
- Final validation
- Quality assurance
```
### Pattern 2: Source Triangulation
```yaml
Primary_Sources:
- Official documentation
- Academic papers
Secondary_Sources:
- Industry reports
- Expert analysis
Tertiary_Sources:
- Community discussions
- User experiences
Synthesis:
- Cross-validate findings
- Identify consensus
- Note disagreements
```
### Pattern 3: Temporal Analysis
```yaml
Historical_Context:
- Past developments
- Evolution timeline
Current_State:
- Present situation
- Recent changes
Future_Projections:
- Trends analysis
- Expert predictions
Synthesis:
- Development trajectory
- Inflection points
- Future scenarios
```
## Performance Optimization Tips
### Query Optimization
1. Start with specific terms
2. Use domain filters early
3. Batch similar searches
4. Cache intermediate results
5. Reuse successful patterns
### Extraction Efficiency
1. Assess complexity first
2. Use appropriate tool per source
3. Parallelize when possible
4. Set reasonable timeouts
5. Handle errors gracefully
### Synthesis Strategy
1. Organize findings early
2. Identify patterns quickly
3. Resolve conflicts systematically
4. Build narrative progressively
5. Maintain evidence chains
## Quality Validation Checklist
### Planning Phase
- [ ] Clear objectives defined
- [ ] Appropriate strategy selected
- [ ] Resources estimated correctly
- [ ] Success criteria established
### Execution Phase
- [ ] All planned searches completed
- [ ] Extraction methods appropriate
- [ ] Multi-hop chains logical
- [ ] Confidence scores calculated
### Synthesis Phase
- [ ] All findings integrated
- [ ] Contradictions resolved
- [ ] Evidence chains complete
- [ ] Narrative coherent
### Delivery Phase
- [ ] Format appropriate for audience
- [ ] Citations complete and accurate
- [ ] Visual evidence included
- [ ] Confidence levels transparent