feat: add Context7 documentation integration for up-to-date library docs

Add Context7 MCP integration to provide agents with current, version-specific
documentation for libraries and frameworks, eliminating outdated code generation.

- Create comprehensive Context7 task (bmad-core/tasks/context7-docs.md)
- Add Context7 configuration to core-config.yaml with command templates
- Enhance dev agent with implementation-focused documentation access
- Enhance architect agent with architecture pattern documentation
- Enhance researcher agent with technical domain research capabilities
- Follow proven Gemini CLI integration pattern for consistency
- Support six documentation modes: library, API, patterns, troubleshooting, etc.
- Include agent-specific usage guidance and safety measures

Agents can now use `*context7-docs {technology}` to get current documentation
by including "use context7" in their prompts, ensuring accurate and up-to-date
implementation guidance for architecture decisions and code patterns.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
LNKB82REZ2GE4 2025-09-21 12:29:30 +01:00
parent 8324a95286
commit 0a33c9cec5
5 changed files with 353 additions and 0 deletions

View File

@ -66,6 +66,7 @@ commands:
- research {topic}: Request specialized research analysis using task request-research
- research-prompt {topic}: execute task create-deep-research-prompt
- gemini-analyze {target}: Analyze large codebases or architectural patterns using Gemini CLI massive context (task gemini-analysis.md)
- context7-docs {technology/architecture}: Get up-to-date architecture patterns and technology documentation for system design (task context7-docs.md)
- shard-prd: run the task shard-doc.md for the provided architecture.md (ask if not found)
- yolo: Toggle Yolo Mode
- exit: Say goodbye as the Architect, and then abandon inhabiting this persona
@ -75,6 +76,7 @@ dependencies:
data:
- technical-preferences.md
tasks:
- context7-docs.md
- create-deep-research-prompt.md
- create-doc.md
- document-project.md

View File

@ -70,6 +70,7 @@ commands:
- review-qa: run task `apply-qa-fixes.md'
- run-tests: Execute linting and tests
- gemini-analyze {target}: Analyze large files or debug complex multi-file issues using Gemini CLI massive context (task gemini-analysis.md)
- context7-docs {technology/library}: Get up-to-date documentation and implementation examples for libraries and frameworks (task context7-docs.md)
- exit: Say goodbye as the Developer, and then abandon inhabiting this persona
dependencies:
@ -77,6 +78,7 @@ dependencies:
- story-dod-checklist.md
tasks:
- apply-qa-fixes.md
- context7-docs.md
- execute-checklist.md
- gemini-analysis.md
- validate-next-story.md

View File

@ -73,6 +73,7 @@ commands:
- technical-deep-dive: In-depth technical analysis and assessment
- market-intelligence: Market-focused research and analysis
- user-research: User behavior and preference analysis
- context7-docs {technology/domain}: Get up-to-date technical documentation for specialized code-focused domain research (task context7-docs.md)
- yolo: Toggle Yolo Mode
- exit: Say goodbye as the Domain Researcher, and then abandon inhabiting this persona
@ -128,6 +129,7 @@ dependencies:
- credible-source-directories.md
tasks:
- conduct-domain-research.md
- context7-docs.md
- evaluate-source-credibility.md
- synthesize-domain-findings.md
templates:

View File

@ -37,3 +37,32 @@ geminiCli:
requireApproval: true
maxContextSize: "2GB"
timeoutSeconds: 300
context7:
enabled: true
defaultMode: documentation
preferredSources: official
versionHandling: latest
integrationPattern: "use context7"
documentationTypes:
- api
- examples
- patterns
- bestPractices
- troubleshooting
commandTemplates:
libraryDocs: "For {library} {useCase}, use context7 to get current documentation and examples."
apiReference: "For {technology} {api} methods, use context7 to get current API documentation."
implementationPattern: "For {pattern} implementation in {technology}, use context7 to get current patterns and examples."
troubleshooting: "For {issue} debugging in {technology}, use context7 to get current troubleshooting documentation."
bestPractices: "For {technology} {context} best practices, use context7 to get current recommendations."
architectureGuidance: "For {technology} {architecture} patterns, use context7 to get current architectural documentation."
agentSpecialization:
dev:
focus: implementation
priorities: [api, examples, troubleshooting]
architect:
focus: design
priorities: [patterns, bestPractices, architecture]
researcher:
focus: analysis
priorities: [api, patterns, bestPractices, examples]

View File

@ -0,0 +1,318 @@
<!-- Powered by BMAD™ Core -->
# Context7 Documentation Task
## Purpose
This task provides access to Context7's up-to-date documentation service for libraries, frameworks, and technologies. Context7 ensures that agents have access to current, version-specific documentation and code examples, eliminating outdated or hallucinated API information during development and architecture work.
## Key Capabilities
- **Current Documentation**: Access to up-to-date, version-specific documentation
- **Code Examples**: Real working code snippets from official sources
- **Library Support**: Coverage of popular programming libraries and frameworks
- **Version Awareness**: Automatically filters documentation by version
- **Integration Ready**: Seamless integration with AI coding workflows
## When to Use Context7 Documentation
### Ideal Use Cases
- **Implementation Guidance**: Getting current API documentation during development
- **Architecture Planning**: Understanding current capabilities of technology choices
- **Code Pattern Discovery**: Finding official examples and best practices
- **API Verification**: Confirming current API signatures and usage patterns
- **Technology Research**: Understanding latest features and capabilities
- **Best Practice Guidance**: Accessing official recommendations and patterns
### Context7 Triggers
- Need for current library/framework documentation
- Uncertainty about API changes or deprecations
- Looking for official code examples
- Verifying implementation patterns
- Researching technology capabilities
- Architecture document accuracy verification
## Documentation Request Modes
### 1. Library Documentation
**Use Case**: Getting comprehensive documentation for a specific library or framework
**Pattern**: Request specific library documentation with version if needed
**Examples**:
- "Get current React documentation for hooks patterns"
- "Fetch Express.js middleware documentation"
- "Show Next.js App Router documentation"
### 2. API Reference
**Use Case**: Getting specific API method documentation and examples
**Pattern**: Request specific API or method documentation
**Examples**:
- "Get documentation for Prisma client methods"
- "Show current FastAPI route decorators"
- "Fetch MongoDB connection patterns"
### 3. Implementation Patterns
**Use Case**: Finding official examples and implementation patterns
**Pattern**: Request implementation guidance for specific use cases
**Examples**:
- "Show authentication patterns for Django REST framework"
- "Get file upload examples for Node.js Express"
- "Find pagination patterns for GraphQL"
### 4. Technology Comparison
**Use Case**: Understanding differences between libraries or approaches
**Pattern**: Request comparative documentation
**Examples**:
- "Compare Vue 3 Composition API vs Options API"
- "Show differences between Jest and Vitest testing"
- "Compare AWS SDK v2 vs v3 patterns"
### 5. Architecture Verification
**Use Case**: Verifying architectural decisions with current documentation
**Pattern**: Request documentation to validate architectural choices
**Examples**:
- "Verify current microservices patterns for Node.js"
- "Check latest database connection pooling recommendations"
- "Get current security best practices for React applications"
### 6. Troubleshooting Support
**Use Case**: Getting documentation to resolve implementation issues
**Pattern**: Request specific troubleshooting or debugging documentation
**Examples**:
- "Get error handling patterns for async/await in Node.js"
- "Show CORS configuration examples for Express.js"
- "Find memory optimization patterns for React applications"
## Task Process
### 1. Documentation Request Processing
#### Gather Requirements
- **Technology/Library**: What specific technology needs documentation?
- **Version Specificity**: Is a particular version required?
- **Use Case Context**: What is the documentation needed for?
- **Scope of Information**: Broad overview vs specific implementation details?
- **Integration Context**: How will this documentation be applied?
#### Request Validation
- **Technology Support**: Verify Context7 supports the requested technology
- **Specificity Check**: Ensure request is specific enough for useful results
- **Context Relevance**: Confirm documentation aligns with current task needs
- **Version Compatibility**: Check if version requirements are reasonable
### 2. Context7 Integration
#### Documentation Retrieval Process
The Context7 integration works by:
1. **Agent Issues Request**: Agent determines need for current documentation
2. **Context7 Activation**: Include "use context7" in the documentation request
3. **Documentation Injection**: Context7 fetches and injects current documentation
4. **AI Processing**: AI assistant processes request with up-to-date context
5. **Response Generation**: Receive current, accurate implementation guidance
#### Integration Pattern
```markdown
For [specific technology/library] [specific use case], use context7 to get current documentation and examples.
```
#### Example Integration Requests
```markdown
# Architecture Documentation
For Next.js App Router middleware patterns, use context7 to get current documentation and examples.
# Development Implementation
For Prisma database migrations with TypeScript, use context7 to get current documentation and examples.
# Research Analysis
For React Server Components performance patterns, use context7 to get current documentation and examples.
```
### 3. Documentation Application
#### Implementation Guidance
- **Code Examples**: Apply current code patterns from official documentation
- **API Usage**: Use verified current API signatures and methods
- **Best Practices**: Follow official recommendations and patterns
- **Version Compatibility**: Ensure compatibility with current library versions
- **Security Considerations**: Apply current security recommendations
#### Architecture Integration
- **Technology Decisions**: Validate architectural choices with current capabilities
- **Integration Patterns**: Use current recommended integration approaches
- **Performance Considerations**: Apply current performance recommendations
- **Scalability Patterns**: Use current scalability best practices
- **Maintenance Considerations**: Follow current maintenance recommendations
### 4. Quality Assurance
#### Documentation Verification
- **Source Authority**: Verify information comes from official sources
- **Version Accuracy**: Confirm documentation matches intended version
- **Implementation Validity**: Test that provided examples work as expected
- **Completeness Check**: Ensure documentation covers required use cases
- **Currency Validation**: Verify documentation represents current state
#### Integration Testing
- **Pattern Validation**: Test that documented patterns work in context
- **API Verification**: Confirm API calls work as documented
- **Example Testing**: Validate that provided examples execute correctly
- **Compatibility Check**: Ensure compatibility with existing codebase
- **Performance Impact**: Assess performance implications of documented approaches
## Integration with BMAD Workflow
### Documentation Storage
- **Architecture Updates**: Update architecture documents with current patterns
- **Code Standards**: Update coding standards with current best practices
- **Technology Stack**: Validate and update technology stack documentation
- **Implementation Guides**: Create current implementation guidance
- **Best Practice Documentation**: Maintain current best practice references
### Knowledge Management
- **Team Knowledge**: Share current documentation insights with team
- **Decision Documentation**: Document technology decisions with current context
- **Pattern Libraries**: Maintain libraries of current implementation patterns
- **Reference Materials**: Create reference materials from current documentation
- **Learning Resources**: Generate learning resources from official documentation
### Development Integration
- **Story Implementation**: Use current documentation during story development
- **Code Reviews**: Reference current best practices during reviews
- **Architecture Reviews**: Validate architectural decisions with current documentation
- **Technology Evaluation**: Use current documentation for technology assessment
- **Implementation Planning**: Plan implementations using current patterns
## Agent-Specific Usage
### Development Agent (dev)
**Focus**: Implementation-specific documentation for coding tasks
**Usage Patterns**:
- Getting current API documentation during implementation
- Finding current code examples and patterns
- Verifying current library usage patterns
- Checking current security and performance recommendations
**Example Requests**:
- "For implementing JWT authentication in Express.js, use context7"
- "For setting up React Query with TypeScript, use context7"
- "For configuring Webpack 5 optimization, use context7"
### Architecture Agent (architect)
**Focus**: Architecture and technology documentation for system design
**Usage Patterns**:
- Validating technology choices with current capabilities
- Understanding current integration patterns
- Researching current scalability and performance patterns
- Verifying current security and compliance approaches
**Example Requests**:
- "For microservices communication patterns with Node.js, use context7"
- "For database design patterns with PostgreSQL and Prisma, use context7"
- "For cloud deployment patterns with AWS and Docker, use context7"
### Research Agent (researcher)
**Focus**: Code-specific domain research and technology analysis
**Usage Patterns**:
- Deep technical research on specific technologies
- Comparative analysis of technical approaches
- Understanding current industry standards and practices
- Researching emerging patterns and methodologies
**Example Requests**:
- "For comparing GraphQL vs REST API design patterns, use context7"
- "For researching current React state management solutions, use context7"
- "For analyzing current testing framework capabilities, use context7"
## Error Handling and Limitations
### Common Issues
- **Technology Not Supported**: Context7 may not have documentation for all technologies
- **Version Specificity**: May not have documentation for very specific or outdated versions
- **Request Ambiguity**: Vague requests may not return useful documentation
- **Context Integration**: Documentation may need adaptation to specific project context
### Error Recovery
- **Alternative Sources**: Suggest alternative documentation sources if Context7 unavailable
- **Manual Research**: Fall back to manual documentation research
- **Request Refinement**: Help refine requests for better Context7 results
- **Community Resources**: Supplement with community documentation when official docs insufficient
### Best Practices
- **Specific Requests**: Make documentation requests as specific as possible
- **Version Awareness**: Specify versions when compatibility is critical
- **Context Combination**: Combine Context7 documentation with project-specific knowledge
- **Validation Steps**: Always validate documentation against current project needs
- **Update Frequency**: Regularly refresh documentation understanding for evolving projects
## Configuration Integration
Context7 integration respects the following configuration patterns:
### Core Configuration
Context7 settings are managed in `bmad-core/core-config.yaml`:
```yaml
context7:
enabled: true
defaultMode: documentation
preferredSources: official
versionHandling: latest
integrationPattern: 'use context7'
```
### Agent Configuration
Agents can customize Context7 behavior based on their specific needs:
- **Development Focus**: Emphasize implementation examples and API documentation
- **Architecture Focus**: Emphasize design patterns and integration approaches
- **Research Focus**: Emphasize comprehensive analysis and comparative documentation
### Safety and Quality
- **Source Validation**: Verify documentation comes from authoritative sources
- **Version Compatibility**: Ensure documentation matches project requirements
- **Implementation Testing**: Test documented patterns in project context
- **Currency Monitoring**: Stay aware of documentation freshness and updates