Instruction file imported from bamr87/ai-seed (
.github/instructions/docs.instructions.md). Copyright stays with the author.
Documentation Instructions
These instructions provide comprehensive guidance for creating, maintaining, and evolving documentation within the AI-seed ecosystem, emphasizing path-based knowledge organization, automated generation, and collaborative documentation practices.
Documentation Philosophy and Structure
Path-Based Knowledge Organization
Documentation should follow natural learning and information paths, allowing readers to progress from basic concepts to advanced implementations in an organic, low-resistance manner.
Core Documentation Paths
- Discovery Path: From problem identification to solution understanding
- Learning Path: From beginner concepts to expert-level implementation
- Implementation Path: From setup through deployment and maintenance
- Integration Path: From isolated components to system-wide understanding
- Evolution Path: From current state to future enhancements
Documentation Hierarchy and Organization
docs/
├── README.md # Project overview and quick start
├── CONTRIBUTING.md # Contribution guidelines
├── CHANGELOG.md # Version history and changes
├── architecture/ # System design documentation path
│ ├── README.md # Architecture overview
│ ├── decisions/ # Architecture Decision Records (ADRs)
│ ├── diagrams/ # Visual architecture representations
│ └── patterns/ # Design pattern documentation
├── guides/ # User and developer guides path
│ ├── README.md # Guide overview
│ ├── quick-start.md # Rapid setup and first steps
│ ├── installation.md # Detailed installation instructions
│ ├── configuration.md # Configuration options and examples
│ ├── development.md # Development workflow and practices
│ ├── deployment.md # Deployment strategies and procedures
│ ├── troubleshooting.md # Common issues and solutions
│ └── best-practices.md # Recommended practices and patterns
├── api/ # API documentation path
│ ├── README.md # API overview
│ ├── reference/ # Detailed API reference
│ ├── examples/ # Usage examples and tutorials
│ └── schemas/ # Data schemas and models
├── tutorials/ # Step-by-step learning path
│ ├── README.md # Tutorial overview
│ ├── beginner/ # Beginner-friendly tutorials
│ ├── intermediate/ # Intermediate complexity
│ └── advanced/ # Advanced topics and patterns
├── reference/ # Technical reference path
│ ├── README.md # Reference overview
│ ├── cli/ # Command-line interface documentation
│ ├── configuration/ # Configuration reference
│ └── glossary.md # Terms and definitions
├── examples/ # Code examples and demos path
│ ├── README.md # Examples overview
│ ├── basic/ # Simple usage examples
│ ├── advanced/ # Complex implementation examples
│ └── integrations/ # Third-party integration examples
└── generated/ # Auto-generated documentation path
├── README.md # Generated docs overview
├── api-docs/ # Auto-generated API documentation
├── code-coverage/ # Test coverage reports
└── path-analysis/ # Path performance and usage reports
Documentation Standards and Conventions
File Naming and Structure
Naming Conventions
- Use lowercase with hyphens for file names:
quick-start.md,api-reference.md - Prefix numbered sequences:
01-setup.md,02-configuration.md - Use descriptive names that indicate content and position in learning path
- Include version or date for time-sensitive documentation:
deployment-2025.md
Document Structure Template
---
title: "Document Title: Clear and Descriptive"
description: "Brief description of document purpose and scope"
author: "Author Name <email@domain.com>"
created: "YYYY-MM-DD"
lastModified: "YYYY-MM-DD"
version: "1.0.0"
tags: ["tag1", "tag2", "tag3"]
difficulty: "beginner|intermediate|advanced"
estimatedTime: "15 minutes"
prerequisites: ["Prerequisite 1", "Prerequisite 2"]
relatedDocs:
- "[Related Doc 1](./related-doc-1.md)"
- "[Related Doc 2](./related-doc-2.md)"
paths:
- "learning-path-name: Brief description of this document's role in the path"
- "implementation-path: How this fits into implementation workflow"
---
# Document Title
Brief introduction that explains what the reader will learn and why it's important.
## Table of Contents
- [Overview](#overview)
- [Prerequisites](#prerequisites)
- [Step-by-Step Instructions](#step-by-step-instructions)
- [Examples](#examples)
- [Troubleshooting](#troubleshooting)
- [Next Steps](#next-steps)
## Overview
Provide context and explain the document's place in the overall system or workflow.
### Learning Objectives
By the end of this document, readers will be able to:
- [ ] Objective 1
- [ ] Objective 2
- [ ] Objective 3
## Prerequisites
List and link to required knowledge or setup:
- [Required Knowledge](./prerequisite-doc.md)
- [System Requirements](./system-requirements.md)
## Step-by-Step Instructions
### Step 1: Clear Action Title
Explanation of what this step accomplishes and why it's necessary.
```bash
# Example command with explanation
command --with-parameters
Expected Output:
Example output with explanations
Path Context: Explain how this step fits into the overall workflow path.
Step 2: Next Action
Continue with clear, actionable steps...
Examples
Basic Example
Provide simple, working examples that readers can follow:
// Path: basic-implementation const example = new ExampleClass(); const result = example.performAction(); console.log('Result:', result);
Advanced Example
More complex scenarios for experienced users:
// Path: advanced-implementation-with-error-handling class AdvancedExample {
async performComplexAction() {
try {
const result = await this.complexOperation();
return this.processResult(result);
} catch (error) {
this.handleError(error);
throw new CustomError('Operation failed', error);
}
}
}
Troubleshooting
Common Issues
Issue: Descriptive Problem Title
Symptoms:
- List observable symptoms
- Include error messages
Causes:
- Explain potential root causes
Solutions:
- Step-by-step solution
- Alternative approaches
- Prevention strategies
Path Impact: Explain how this issue affects workflow paths.
Next Steps
Guide readers to their next logical step in the learning or implementation path:
- If you're new to this topic: Beginner Tutorial
- If you want to dive deeper: Advanced Guide
- If you're ready to implement: Implementation Guide
Related Resources
Feedback and Contributions
This documentation follows our contribution guidelines. To improve this document:
- Report Issues: Create an issue for errors or unclear content
- Suggest Improvements: Submit a pull request with proposed changes
- Request Content: Request new documentation
Last updated: YYYY-MM-DD | Next review: YYYY-MM-DD
### Content Quality Standards
#### Writing Style Guidelines
- **Clarity First**: Use simple, direct language over complex terminology
- **Active Voice**: Prefer active voice for clearer instructions
- **Consistent Terminology**: Use the same terms throughout all documentation
- **Path Context**: Always explain how content fits into larger workflows
- **Progressive Disclosure**: Start simple, layer in complexity gradually
#### Technical Accuracy Requirements
- **Tested Examples**: All code examples must be tested and working
- **Version Specificity**: Include version numbers for tools and dependencies
- **Platform Consistency**: Test instructions across different environments
- **Link Validation**: Regularly check and update external links
- **Container Context**: Include container-specific setup when relevant
#### Accessibility and Inclusivity
- **Screen Reader Friendly**: Use proper heading hierarchy and alt text
- **Multiple Learning Styles**: Include visual, textual, and interactive elements
- **Inclusive Language**: Use welcoming, non-discriminatory language
- **Cultural Sensitivity**: Avoid culture-specific references or idioms
- **Skill Level Awareness**: Clearly indicate difficulty and prerequisites
## Automated Documentation Generation
### AI-Assisted Documentation Workflows
#### Documentation Generation Pipeline
```javascript
// Path: automated-documentation-generation
// File: scripts/generate-docs.js
import { pathTracker } from '../src/utils/path-tracker.js';
import { DocumentationGenerator } from '../src/utils/doc-generator.js';
import { CodeAnalyzer } from '../src/utils/code-analyzer.js';
import { logger } from '../src/config/logger.js';
/**
* Automated documentation generation system
*/
class DocumentationPipeline {
constructor() {
this.generator = new DocumentationGenerator();
this.analyzer = new CodeAnalyzer();
this.outputPath = './docs/generated';
}
/**
* Generate comprehensive documentation from codebase
*/
async generateDocumentation() {
return pathTracker.executeInPath('documentation_generation', async () => {
// Path: code-analysis
const codeAnalysis = await pathTracker.executeInPath('code_analysis',
() => this.analyzer.analyzeCodebase('./src')
);
// Path: api-documentation-generation
const apiDocs = await pathTracker.executeInPath('api_documentation',
() => this.generator.generateApiDocs(codeAnalysis.apiRoutes)
);
// Path: example-generation
const examples = await pathTracker.executeInPath('example_generation',
() => this.generator.generateCodeExamples(codeAnalysis.functions)
);
// Path: path-analysis-documentation
const pathDocs = await pathTracker.executeInPath('path_documentation',
() => this.generatePathDocumentation()
);
// Path: documentation-compilation
await pathTracker.executeInPath('documentation_compilation', async () => {
await this.compileDocumentation({
api: apiDocs,
examples,
paths: pathDocs,
analysis: codeAnalysis
});
});
logger.info('Documentation generation completed successfully');
});
}
/**
* Generate path-specific documentation
*/
async generatePathDocumentation() {
const pathMetrics = pathTracker.getMetrics();
const pathReport = pathTracker.generatePerformanceReport();
const pathDocumentation = {
overview: this.generatePathOverview(pathMetrics),
detailedMetrics: pathReport,
flowDiagrams: await this.generatePathFlowDiagrams(pathMetrics),
optimizationSuggestions: this.generateOptimizationSuggestions(pathReport)
};
return pathDocumentation;
}
/**
* Generate path overview documentation
*/
generatePathOverview(pathMetrics) {
const paths = Object.keys(pathMetrics);
return {
totalPaths: paths.length,
mostUsedPaths: this.getMostUsedPaths(pathMetrics, 10),
criticalPaths: this.getCriticalPaths(pathMetrics),
pathHierarchy: this.buildPathHierarchy(paths)
};
}
/**
* Compile all documentation into organized structure
*/
async compileDocumentation(docs) {
const compiledDocs = {
timestamp: new Date().toISOString(),
version: process.env.npm_package_version || '1.0.0',
...docs
};
// Generate markdown files
await this.writeMarkdownFiles(compiledDocs);
// Generate interactive documentation
await this.generateInteractiveDocs(compiledDocs);
// Update index files
await this.updateDocumentationIndex(compiledDocs);
}
/**
* Write generated documentation to markdown files
*/
async writeMarkdownFiles(docs) {
const files = [
{
path: `${this.outputPath}/api-reference.md`,
content: this.generator.formatApiReference(docs.api)
},
{
path: `${this.outputPath}/code-examples.md`,
content: this.generator.formatCodeExamples(docs.examples)
},
{
path: `${this.outputPath}/path-analysis.md`,
content: this.generator.formatPathAnalysis(docs.paths)
},
{
path: `${this.outputPath}/README.md`,
content: this.generator.formatGeneratedDocsIndex(docs)
}
];
for (const file of files) {
await this.generator.writeFile(file.path, file.content);
logger.debug(`Generated documentation file: ${file.path}`);
}
}
}
// Command-line interface for documentation generation
if (import.meta.url === `file://${process.argv[1]}`) {
const pipeline = new DocumentationPipeline();
pipeline.generateDocumentation()
.then(() => {
console.log('Documentation generation completed successfully');
process.exit(0);
})
.catch((error) => {
console.error('Documentation generation failed:', error);
process.exit(1);
});
}
export { DocumentationPipeline };
AI-Powered Content Enhancement
// Path: ai-powered-documentation-enhancement
// File: src/utils/doc-generator.js
/**
* AI-powered documentation generator with path awareness
*/
export class DocumentationGenerator {
constructor() {
this.aiService = new AIDocumentationService();
this.templateEngine = new TemplateEngine();
this.markdownProcessor = new MarkdownProcessor();
}
/**
* Generate API documentation with AI enhancement
*/
async generateApiDocs(apiRoutes) {
return pathTracker.executeInPath('api_docs_generation', async () => {
const enhancedDocs = [];
for (const route of apiRoutes) {
// Path: route-analysis
const routeAnalysis = await pathTracker.executeInPath('route_analysis',
() => this.analyzeRoute(route)
);
// Path: ai-enhancement
const aiEnhanced = await pathTracker.executeInPath('ai_enhancement',
() => this.aiService.enhanceApiDocumentation(route, routeAnalysis)
);
// Path: example-generation
const examples = await pathTracker.executeInPath('example_generation',
() => this.generateRouteExamples(route, aiEnhanced)
);
enhancedDocs.push({
route,
analysis: routeAnalysis,
enhanced: aiEnhanced,
examples
});
}
return enhancedDocs;
});
}
/**
* Generate comprehensive code examples
*/
async generateCodeExamples(functions) {
return pathTracker.executeInPath('code_examples_generation', async () => {
const examples = {};
for (const func of functions) {
// Path: function-analysis
const analysis = await pathTracker.executeInPath('function_analysis',
() => this.analyzeFunctionSignature(func)
);
// Path: usage-example-generation
const usageExamples = await pathTracker.executeInPath('usage_examples',
() => this.generateUsageExamples(func, analysis)
);
// Path: test-example-generation
const testExamples = await pathTracker.executeInPath('test_examples',
() => this.generateTestExamples(func, analysis)
);
examples[func.name] = {
function: func,
analysis,
usage: usageExamples,
tests: testExamples
};
}
return examples;
});
}
/**
* Format API reference documentation
*/
formatApiReference(apiDocs) {
const template = `
# API Reference
*Auto-generated on ${new Date().toISOString()}*
This documentation provides comprehensive information about all API endpoints, including usage examples, request/response schemas, and implementation guidance.
## Table of Contents
{{#each routes}}
- [{{method}} {{path}}](#{{anchor}})
{{/each}}
## Endpoints
{{#each routes}}
### {{method}} {{path}}
{{description}}
**Path Context:** {{pathContext}}
#### Request
\`\`\`http
{{method}} {{path}}
{{#if headers}}
{{#each headers}}
{{name}}: {{value}}
{{/each}}
{{/if}}
\`\`\`
#### Parameters
{{#if parameters}}
| Name | Type | Required | Description |
|------|------|----------|-------------|
{{#each parameters}}
| {{name}} | {{type}} | {{required}} | {{description}} |
{{/each}}
{{/if}}
#### Response
\`\`\`json
{{responseExample}}
\`\`\`
#### Examples
{{#each examples}}
##### {{title}}
\`\`\`{{language}}
{{code}}
\`\`\`
{{#if explanation}}
**Explanation:** {{explanation}}
{{/if}}
{{/each}}
#### Error Handling
{{#each errors}}
- **{{code}}**: {{description}}
{{/each}}
---
{{/each}}
`;
return this.templateEngine.compile(template, { routes: apiDocs });
}
/**
* Format path analysis documentation
*/
formatPathAnalysis(pathDocs) {
const template = `
# Path Analysis Report
*Generated on ${new Date().toISOString()}*
This document provides detailed analysis of execution paths within the application, including performance metrics, usage patterns, and optimization recommendations.
## Executive Summary
- **Total Paths:** {{overview.totalPaths}}
- **Analysis Period:** {{analysisPeriod}}
- **Most Critical Path:** {{overview.criticalPaths.0.name}}
- **Average Execution Time:** {{overview.averageExecutionTime}}ms
## Path Performance Overview
### Most Used Paths
{{#each overview.mostUsedPaths}}
1. **{{name}}** - {{executions}} executions ({{averageTime}}ms avg)
{{/each}}
### Critical Paths
Critical paths are those that significantly impact system performance or user experience.
{{#each overview.criticalPaths}}
#### {{name}}
- **Average Execution Time:** {{averageTime}}ms
- **Error Rate:** {{errorRate}}%
- **Performance Impact:** {{performanceImpact}}
- **Optimization Priority:** {{optimizationPriority}}
{{/each}}
## Detailed Metrics
{{#each detailedMetrics.paths}}
### {{@key}}
| Metric | Value |
|--------|-------|
| Total Executions | {{executions}} |
| Average Time | {{averageTime}}ms |
| Min Time | {{minTime}}ms |
| Max Time | {{maxTime}}ms |
| Success Rate | {{successRate}}% |
| Error Rate | {{errorRate}}% |
#### Performance Trend
\`\`\`
{{performanceTrend}}
\`\`\`
{{/each}}
## Optimization Recommendations
{{#each optimizationSuggestions}}
### {{category}}
{{description}}
**Recommended Actions:**
{{#each actions}}
- {{this}}
{{/each}}
**Expected Impact:**
- Performance: {{expectedPerformanceGain}}
- Reliability: {{expectedReliabilityGain}}
{{/each}}
## Path Flow Diagrams
{{#each flowDiagrams}}
### {{name}}
\`\`\`mermaid
{{diagram}}
\`\`\`
{{description}}
{{/each}}
`;
return this.templateEngine.compile(template, pathDocs);
}
}
Documentation Maintenance and Evolution
Automated Content Validation
Link Checking and Content Validation
#!/bin/bash
# Path: documentation-validation-automation
# File: scripts/validate-docs.sh
set -euo pipefail
# Path: script-initialization
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../" && pwd)"
readonly DOCS_DIR="${PROJECT_ROOT}/docs"
# Load libraries
source "${SCRIPT_DIR}/lib/logging.sh"
source "${SCRIPT_DIR}/lib/path_management.sh"
# Path: documentation-validation-workflow
validate_documentation() {
enter_path "documentation_validation"
log_info "Starting comprehensive documentation validation" "docs_validation"
# Path: markdown-syntax-validation
execute_in_path "markdown_syntax_validation" \
"validate_markdown_syntax"
# Path: link-validation
execute_in_path "link_validation" \
"validate_all_links"
# Path: code-example-validation
execute_in_path "code_example_validation" \
"validate_code_examples"
# Path: consistency-validation
execute_in_path "consistency_validation" \
"validate_content_consistency"
# Path: accessibility-validation
execute_in_path "accessibility_validation" \
"validate_accessibility_standards"
exit_path "documentation_validation"
log_info "Documentation validation completed successfully" "docs_validation"
}
# Path: markdown-syntax-checking
validate_markdown_syntax() {
log_info "Validating Markdown syntax across all documentation" "syntax_validation"
local errors_found=false
while IFS= read -r -d '' file; do
if ! markdownlint "$file"; then
log_error "Markdown syntax errors found in: $file" "syntax_validation"
errors_found=true
else
log_debug "Markdown syntax valid: $file" "syntax_validation"
fi
done < <(find "$DOCS_DIR" -name "*.md" -print0)
if [[ "$errors_found" = true ]]; then
log_error "Markdown syntax validation failed" "syntax_validation"
return 1
fi
log_info "All Markdown files have valid syntax" "syntax_validation"
}
# Path: comprehensive-link-validation
validate_all_links() {
log_info "Validating all links in documentation" "link_validation"
# Internal links validation
validate_internal_links
# External links validation
validate_external_links
# Cross-reference validation
validate_cross_references
}
validate_internal_links() {
log_info "Checking internal links" "internal_links"
local broken_links=()
while IFS= read -r -d '' file; do
log_debug "Checking internal links in: $file" "internal_links"
# Extract internal links (relative paths)
local links
links=$(grep -oP '\[.*?\]\(\K[^)]*(?=\))' "$file" | grep -v '^http' || true)
while IFS= read -r link; do
if [[ -n "$link" ]]; then
local target_file
target_file=$(resolve_relative_path "$file" "$link")
if [[ ! -f "$target_file" ]]; then
broken_links+=("$file: $link -> $target_file")
log_warning "Broken internal link: $link in $file" "internal_links"
fi
fi
done <<< "$links"
done < <(find "$DOCS_DIR" -name "*.md" -print0)
if [[ ${#broken_links[@]} -gt 0 ]]; then
log_error "Found ${#broken_links[@]} broken internal links" "internal_links"
printf '%s\n' "${broken_links[@]}"
return 1
fi
log_info "All internal links are valid" "internal_links"
}
validate_external_links() {
log_info "Checking external links (may take several minutes)" "external_links"
local external_links_file="${PROJECT_ROOT}/tmp/external_links.txt"
mkdir -p "$(dirname "$external_links_file")"
# Extract all external links
find "$DOCS_DIR" -name "*.md" -exec grep -oP '\[.*?\]\(\K[^)]*(?=\))' {} \; | \
grep '^http' | sort -u > "$external_links_file"
local broken_external_links=()
local total_links
total_links=$(wc -l < "$external_links_file")
local current=0
while IFS= read -r url; do
((current++))
log_debug "Checking external link ($current/$total_links): $url" "external_links"
if ! curl --silent --head --fail --max-time 10 "$url" > /dev/null 2>&1; then
broken_external_links+=("$url")
log_warning "Broken external link: $url" "external_links"
fi
done < "$external_links_file"
if [[ ${#broken_external_links[@]} -gt 0 ]]; then
log_warning "Found ${#broken_external_links[@]} potentially broken external links" "external_links"
printf '%s\n' "${broken_external_links[@]}"
# Don't fail on external links as they might be temporarily unavailable
fi
log_info "External link validation completed" "external_links"
}
# Path: code-example-testing
validate_code_examples() {
log_info "Validating code examples in documentation" "code_validation"
local temp_dir="${PROJECT_ROOT}/tmp/code_validation"
mkdir -p "$temp_dir"
local validation_errors=()
while IFS= read -r -d '' file; do
log_debug "Extracting code examples from: $file" "code_validation"
# Extract code blocks and validate them
if ! extract_and_validate_code_blocks "$file" "$temp_dir"; then
validation_errors+=("$file")
fi
done < <(find "$DOCS_DIR" -name "*.md" -print0)
# Cleanup
rm -rf "$temp_dir"
if [[ ${#validation_errors[@]} -gt 0 ]]; then
log_error "Code validation failed in ${#validation_errors[@]} files" "code_validation"
printf '%s\n' "${validation_errors[@]}"
return 1
fi
log_info "All code examples are valid" "code_validation"
}
# Path: main-validation-execution
main() {
local start_time=$(date +%s.%N)
log_info "Starting documentation validation process" "main"
# Ensure required tools are available
check_validation_tools || {
log_fatal "Required validation tools are not available" "main"
}
# Run validation
validate_documentation || {
log_fatal "Documentation validation failed" "main"
}
# Generate validation report
generate_validation_report
local end_time=$(date +%s.%N)
local total_time=$(echo "$end_time - $start_time" | bc -l)
log_performance_metric "docs_validation_time" "$total_time" "seconds" "validation"
log_info "Documentation validation completed successfully in ${total_time}s" "main"
}
# Execute main function if script is run directly
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi
Documentation Analytics and Metrics
Usage Tracking and Content Optimization
// Path: documentation-analytics-system
// File: src/utils/docs-analytics.js
/**
* Documentation analytics and optimization system
*/
export class DocumentationAnalytics {
constructor() {
this.metricsCollector = new MetricsCollector();
this.contentAnalyzer = new ContentAnalyzer();
this.optimizationEngine = new OptimizationEngine();
}
/**
* Collect comprehensive documentation metrics
*/
async collectDocumentationMetrics() {
return pathTracker.executeInPath('docs_metrics_collection', async () => {
const metrics = {
usage: await this.collectUsageMetrics(),
content: await this.collectContentMetrics(),
quality: await this.collectQualityMetrics(),
accessibility: await this.collectAccessibilityMetrics(),
performance: await this.collectPerformanceMetrics()
};
return metrics;
});
}
/**
* Analyze content effectiveness and suggest improvements
*/
async analyzeContentEffectiveness() {
return pathTracker.executeInPath('content_effectiveness_analysis', async () => {
const metrics = await this.collectDocumentationMetrics();
const analysis = {
readabilityScores: await this.analyzeReadability(),
completenessScores: await this.analyzeCompleteness(),
accuracyScores: await this.analyzeAccuracy(),
userSatisfactionScores: await this.analyzeUserSatisfaction(metrics.usage)
};
const recommendations = await this.generateContentRecommendations(analysis);
return {
analysis,
recommendations
};
});
}
/**
* Generate content recommendations based on analysis
*/
async generateContentRecommendations(analysis) {
const recommendations = [];
// Readability improvements
if (analysis.readabilityScores.average < 70) {
recommendations.push({
type: 'readability',
priority: 'high',
description: 'Improve content readability',
actions: [
'Simplify complex sentences',
'Use more common vocabulary',
'Add more examples and illustrations',
'Break up long paragraphs'
]
});
}
// Completeness improvements
const incompleteAreas = analysis.completenessScores.filter(area => area.score < 80);
if (incompleteAreas.length > 0) {
recommendations.push({
type: 'completeness',
priority: 'medium',
description: 'Address content gaps',
actions: incompleteAreas.map(area => `Add content for: ${area.topic}`)
});
}
// User experience improvements
if (analysis.userSatisfactionScores.average < 75) {
recommendations.push({
type: 'user_experience',
priority: 'high',
description: 'Enhance user experience',
actions: [
'Add more interactive examples',
'Improve navigation structure',
'Provide clearer step-by-step instructions',
'Add troubleshooting sections'
]
});
}
return recommendations;
}
/**
* Generate automated documentation improvement tasks
*/
async generateImprovementTasks() {
return pathTracker.executeInPath('improvement_tasks_generation', async () => {
const effectiveness = await this.analyzeContentEffectiveness();
const tasks = [];
for (const recommendation of effectiveness.recommendations) {
const task = {
id: `docs-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
type: recommendation.type,
priority: recommendation.priority,
title: recommendation.description,
description: recommendation.actions.join('\n'),
estimatedEffort: this.estimateEffort(recommendation),
expectedImpact: this.estimateImpact(recommendation),
assignedTo: 'documentation-team',
status: 'open',
createdAt: new Date().toISOString()
};
tasks.push(task);
}
return tasks;
});
}
}
Integration with Development Workflow
Documentation-First Development
Requirement Documentation Templates
<!-- Path: requirement-documentation-template -->
<!-- File: docs/templates/requirement.md -->
# Requirement: [Requirement Name]
## Overview
### Problem Statement
Brief description of the problem this requirement addresses.
### Success Criteria
- [ ] Measurable outcome 1
- [ ] Measurable outcome 2
- [ ] Measurable outcome 3
## Detailed Requirements
### Functional Requirements
1. **Requirement ID: FR-001**
- Description: Detailed description of functional requirement
- Priority: High/Medium/Low
- Dependencies: List of dependencies
- Acceptance Criteria: Specific, testable criteria
### Non-Functional Requirements
1. **Requirement ID: NFR-001**
- Type: Performance/Security/Usability/etc.
- Description: Detailed description
- Metrics: Quantifiable metrics
- Testing Approach: How to verify
## Implementation Path
### Development Workflow
1. **Analysis Phase**: Understanding and planning
2. **Design Phase**: Architecture and detailed design
3. **Implementation Phase**: Coding and testing
4. **Validation Phase**: User acceptance and performance testing
5. **Deployment Phase**: Production deployment and monitoring
### Documentation Requirements
- [ ] API documentation updates
- [ ] User guide sections
- [ ] Developer documentation
- [ ] Deployment documentation
- [ ] Troubleshooting guides
## Risk Assessment
### Technical Risks
| Risk | Probability | Impact | Mitigation |
|------|-------------|--------|------------|
| Risk description | High/Medium/Low | High/Medium/Low | Mitigation strategy |
### Project Risks
| Risk | Probability | Impact | Mitigation |
|------|-------------|--------|------------|
| Risk description | High/Medium/Low | High/Medium/Low | Mitigation strategy |
## Timeline and Milestones
### Development Phases
- **Phase 1**: [Start Date] - [End Date]
- Deliverables: List of deliverables
- Documentation: Required documentation
- **Phase 2**: [Start Date] - [End Date]
- Deliverables: List of deliverables
- Documentation: Required documentation
### Documentation Milestones
- [ ] Initial documentation draft
- [ ] Technical review completion
- [ ] User testing feedback integration
- [ ] Final documentation publication
## Validation and Testing
### Testing Strategy
- Unit Testing: Coverage requirements and approach
- Integration Testing: Cross-component testing approach
- User Acceptance Testing: User validation criteria
- Performance Testing: Performance criteria and benchmarks
### Documentation Testing
- Content accuracy validation
- Example code testing
- Link validation
- Accessibility testing
## Success Metrics
### Quantitative Metrics
- Performance benchmarks
- Error rates
- User adoption rates
- Documentation usage statistics
### Qualitative Metrics
- User feedback scores
- Developer experience ratings
- Documentation quality assessments
- Support ticket reduction
## Related Documentation
- [Related Requirement 1](./related-requirement-1.md)
- [Architecture Decision Record](../architecture/decisions/adr-xxx.md)
- [API Specification](../api/specification.md)
- [Implementation Guide](../guides/implementation.md)
---
**Document Metadata:**
- Created: [Date]
- Last Updated: [Date]
- Version: [Version]
- Status: Draft/Review/Approved/Implemented
- Stakeholders: [List of stakeholders]
- Review Date: [Next review date]
MCP-Specific Documentation Patterns
MCP Server Documentation Template
# MCP Server: [Server Name]
## Overview
Brief description of the MCP server's purpose and capabilities.
### Server Capabilities
- **Resources**: [List of resource types exposed]
- **Tools**: [List of available tools]
- **Prompts**: [List of supported prompts]
## Configuration
### Environment Variables
| Variable | Description | Default | Required |
|----------|-------------|---------|----------|
| `MCP_SERVER_NAME` | Server identifier | `server-name` | Yes |
| `MCP_LOG_LEVEL` | Logging level | `INFO` | No |
### Container Configuration
```yaml
version: '3.8' services: mcp-server:
build: ./mcp-servers/[server-name]
environment:
- MCP_SERVER_NAME=[server-name]
volumes:
- ./data:/data:ro
Resource Access
Available Resources
Resource Type: [Type Name]
- URI Pattern:
[type]://[path] - Description: [What this resource provides]
- Access Level: Read-only/Read-write
- Example:
file:///workspace/src/main.py
Resource Examples
# Python client example
async def list_resources():
client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-[server-name]"])
await client.connect()
resources = await client.listResources()
for resource in resources:
print(f"URI: {resource.uri}")
print(f"Name: {resource.name}")
print(f"Description: {resource.description}")
await client.disconnect()
Tool Usage
Available Tools
Tool: [tool_name]
- Description: [What the tool does]
- Parameters:
param1(string, required): [Description]param2(number, optional): [Description]
- Returns: [Description of return value]
Tool Examples
// TypeScript client example const client = new PathAwareMCPClient("docker", ["exec", "-i", "mcp-[server-name]"]); await client.connect();
const result = await client.callTool("[tool_name]", {
param1: "example_value",
param2: 42
});
console.log("Tool result:", result); await client.disconnect();
Prompt Templates
Available Prompts
Prompt: [prompt_name]
- Description: [What the prompt generates]
- Arguments:
arg1(string, required): [Description]arg2(boolean, optional): [Description]
- Output: [Description of generated prompt]
Prompt Examples
# Using MCP client to get prompt
./scripts/mcp/get-prompt.sh [prompt_name] --arg1 "value" --arg2 true
Health Monitoring
Health Check Endpoint
The server provides health status at: /health
Monitoring Commands
# Check server health
docker exec mcp-[server-name] python -c "import asyncio; from src.health_check import check_server_health; asyncio.run(check_server_health())"
# View server logs
docker logs mcp-[server-name]
# Restart server
docker-compose -f docker-compose.mcp.yml restart mcp-[server-name]
Troubleshooting
Common Issues
Issue: Server Connection Failed
Symptoms: Client cannot connect to MCP server
Solutions:
- Verify server container is running:
docker ps | grep mcp-[server-name] - Check server logs:
docker logs mcp-[server-name] - Validate network connectivity
- Restart server if needed
Issue: Resource Access Denied
Symptoms: Cannot read/write resources
Solutions:
- Check file/directory permissions
- Verify container volume mounts
- Review security settings
- Validate resource URI format
Development
Local Development Setup
# Clone repository
git clone [repository-url] cd [repository-name]
# Start development environment
docker-compose -f docker-compose.mcp.yml up -d mcp-[server-name]
# Run tests
python -m pytest tests/mcp/[server-name]/
Testing
# Unit tests
python -m pytest tests/unit/mcp/[server-name]/
# Integration tests
python -m pytest tests/integration/mcp/[server-name]/
# End-to-end tests
./scripts/mcp/test-integrations.sh --server [server-name]
Security Considerations
Access Control
- [Describe access control mechanisms]
- [List security boundaries]
- [Document authentication requirements]
Data Privacy
- [Describe data handling practices]
- [List sensitive data types]
- [Document privacy controls]
Performance
Benchmarks
| Operation | Average Time | Throughput |
|---|---|---|
| List Resources | [X]ms | [Y] ops/sec |
| Read Resource | [X]ms | [Y] MB/sec |
| Execute Tool | [X]ms | [Y] ops/sec |
Optimization Tips
- [Performance optimization recommendations]
- [Scaling considerations]
- [Resource usage guidelines]
API Reference
Complete API Documentation
See MCP Protocol Specification for detailed protocol information.
Server-Specific Extensions
- [Document any protocol extensions]
- [List custom capabilities]
- [Describe non-standard features]
Maintainers: [List of maintainers] Last Updated: [Date] Version: [Server version]
#### MCP Integration Guide Template
```markdown
# MCP Integration Guide
This guide provides comprehensive information about integrating Model Context Protocol (MCP) capabilities into your AI applications.
## Quick Start
### Prerequisites
- Docker and Docker Compose
- Python 3.11+ or Node.js 18+
- Basic understanding of AI application architecture
### Installation
```bash
# Clone the MCP-enabled repository
git clone [repository-url] cd [repository-name]
# Start MCP server infrastructure
docker-compose -f docker-compose.mcp.yml up -d
# Verify servers are healthy
./scripts/mcp/monitor-servers.sh --health-check-all
Basic Usage
from src.mcp.clients.mcp_client import PathAwareMCPClient
# Connect to filesystem MCP server
client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-filesystem"]) await client.connect()
# List available resources
resources = await client.listResources() print(f"Found {len(resources)} resources")
# Read a specific file
content = await client.readResource("file://src/main.py") print("File content:", content[:100], "...")
await client.disconnect()
Available MCP Servers
$(cat config/mcp/discovered_servers.json | jq -r '.servers[] | "- " + . + ": [Server description]"')
Server Capabilities
$(cat config/mcp/server_capabilities.json | jq -r '.servers | to_entries[] | "### " + .key + "\n\n" + "Status: " + .value.status + "\n"')
Advanced Integration Patterns
Context Aggregation
# Collect context from multiple MCP servers
async def collect_comprehensive_context():
contexts = {}
# Filesystem context
fs_client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-filesystem"])
await fs_client.connect()
contexts['filesystem'] = await fs_client.listResources()
await fs_client.disconnect()
# Database context
db_client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-database"])
await db_client.connect()
contexts['database'] = await db_client.listResources()
await db_client.disconnect()
return contexts
Tool Orchestration
# Chain multiple MCP tool executions
async def automated_workflow():
client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-filesystem"])
await client.connect()
# Step 1: List directory
dir_contents = await client.callTool("list_directory", {"path": "./src"})
# Step 2: Process each file
for file_info in parse_directory_output(dir_contents):
file_content = await client.readResource(f"file://{file_info['path']}")
# Process file content...
await client.disconnect()
Configuration Management
Client Configuration
The MCP client configuration is managed in config/mcp/client_config.json:
{
"mcpVersion": "2025-06-18",
"servers": {
"filesystem": {
"command": "docker",
"args": ["exec", "-i", "mcp-filesystem", "python", "-m", "mcp_servers.filesystem"],
"enabled": true
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
MCP_PROTOCOL_VERSION |
MCP protocol version | 2025-06-18 |
MCP_LOG_LEVEL |
Logging level for MCP operations | INFO |
MCP_TIMEOUT |
Default timeout for MCP operations | 30000 |
Monitoring and Observability
Health Monitoring
# Check all MCP server health
./scripts/mcp/monitor-servers.sh --health-check-all
# Monitor specific server
./scripts/mcp/monitor-servers.sh --server filesystem
# Generate health report
./scripts/mcp/monitor-servers.sh --generate-report
Performance Metrics
View current performance metrics:
cat config/mcp/validation_report.json | jq '.summary'
Logging
MCP operations are logged with path context:
[2025-07-19 10:30:15] [INFO] [mcp_client] [resource_reading] Reading resource: file://src/main.py [2025-07-19 10:30:15] [INFO] [mcp_client] [tool_execution_list_directory] Executing tool: list_directory
Best Practices
Resource Management
- Always close MCP client connections
- Use connection pooling for high-frequency operations
- Implement retry logic for network operations
- Cache frequently accessed resources
Error Handling
from src.mcp.clients.mcp_client import PathAwareMCPClient
async def robust_mcp_operation():
client = PathAwareMCPClient("docker", ["exec", "-i", "mcp-filesystem"])
try:
await client.connect()
# Use retry mechanism for critical operations
result = await client.withRetry(
lambda: client.readResource("file://important.txt"),
maxRetries=3,
delay=1000
)
return result
except Exception as e:
logger.error(f"MCP operation failed: {e}")
raise
finally:
await client.disconnect()
Security
- Validate all resource URIs
- Implement proper access controls
- Use least-privilege principles
- Monitor for suspicious activity
Troubleshooting
Common Issues
Connection Failures
Problem: Cannot connect to MCP server Solution:
- Verify server container is running
- Check network connectivity
- Validate server configuration
Performance Issues
Problem: Slow MCP operations Solution:
- Enable connection pooling
- Implement caching
- Optimize resource access patterns
Resource Access Errors
Problem: Cannot access specific resources Solution:
- Check file permissions
- Verify volume mounts
- Validate URI format
Development and Testing
Local Development
# Start development environment
docker-compose -f docker-compose.mcp.yml up -d
# Run MCP server tests
python -m pytest tests/mcp/ -v
# Test specific integration
./scripts/mcp/test-integrations.sh --server filesystem
Creating Custom MCP Servers
See the MCP Server Development Guide for details on creating custom servers.
API Reference
Client API
Complete API documentation for the MCP client library.
Server Protocols
Documentation of server-specific protocol extensions and capabilities.
This guide is automatically updated by the MCP discovery and configuration workflows.
## Integration with Other Instructions
This documentation instruction file works in conjunction with:
- **space.instructions.md**: Foundational path-based principles and container-first development
- **project.instructions.md**: AI-seed specific requirements and documentation standards
- **mcp.instructions.md**: Model Context Protocol integration and documentation patterns
- **python.instructions.md**: Python-specific documentation patterns
- **javascript.instructions.md**: JavaScript/Node.js documentation standards
- **bash.instructions.md**: Shell script documentation requirements
- **test.instructions.md**: Test documentation and reporting standards
- **ci-cd.instructions.md**: Automated documentation generation and deployment
## Future Evolution
### Advanced Documentation Features
- **Interactive Documentation**: Executable code examples and live demonstrations
- **Multi-Language Support**: Automated translation and localization
- **Personalized Learning Paths**: AI-driven content customization based on user expertise
- **Real-Time Collaboration**: Live editing and review capabilities
### AI-Enhanced Documentation
- **Content Generation**: Automated first-draft generation from code analysis
- **Quality Assessment**: AI-powered content quality evaluation and improvement suggestions
- **User Experience Optimization**: AI-driven content structure and presentation optimization
- **Predictive Content Needs**: Anticipating documentation requirements based on development patterns