24 KiB
Self Document - Auto-Documentation System
Purpose: Automatically generate and update documentation to reflect current system state, capabilities, and improvements.
Usage
/self-document [scope] [detail_level]
Parameters
scope: What to document - "commands", "specs", "improvements", "architecture", "all" (default: "all")detail_level: Documentation depth - "brief", "standard", "comprehensive" (default: "standard")
Examples
# Update all documentation with standard detail
/self-document all standard
# Brief documentation of commands only
/self-document commands brief
# Comprehensive architecture documentation
/self-document architecture comprehensive
# Document recent improvements
/self-document improvements standard
Command Implementation
You are the Self-Documentation System. Your role is to analyze the current state and generate accurate, helpful documentation automatically.
Phase 1: System Analysis
-
Scan System Components
Based on
{{scope}}:Commands:
- Read all
.claude/commands/*.mdfiles - Extract purpose, parameters, capabilities
- Identify interdependencies
- Document recent changes
Specs:
- Read all
specs/*.mdfiles - Categorize by type and purpose
- Document patterns and frameworks
- Track auto-generated vs. manual
Improvements:
- Read
improvement_log/directory - Extract evolution history
- Summarize performance trends
- Highlight key achievements
Architecture:
- Analyze overall system structure
- Map component relationships
- Document data flows
- Identify meta-level capabilities
- Read all
-
Extract Key Information
For each component:
- Purpose: What it does
- Capabilities: What it can accomplish
- Usage: How to use it
- Integration: How it connects to other components
- Evolution: How it has improved
- Meta-Properties: Self-improvement capabilities
Phase 2: Meta-Prompting Analysis
-
Identify Meta-Patterns
Structure-oriented documentation:
- What architectural patterns are used?
- What abstract frameworks enable capabilities?
- How do components enable self-improvement?
- What meta-level properties exist?
-
Extract Documentation Principles
From meta-prompting:
- Focus on structure over specific examples
- Document patterns, not just functions
- Enable understanding through abstraction
- Show evolution and improvement potential
Phase 3: Documentation Generation
-
Generate/Update README.md
# Meta-Level Self-Improvement System **Version:** {{version}} **Last Updated:** {{timestamp}} **Status:** {{system_health_status}} ## Overview This is an advanced infinite loop variant with **meta-level self-improvement capabilities**. The system can analyze its own performance, improve its commands, generate new specifications, and evolve its orchestration strategy. ### Core Philosophy Built on **meta-prompting principles** from [promptingguide.ai](https://www.promptingguide.ai/techniques/meta-prompting): - **Structure-oriented:** Emphasizes patterns over content - **Abstract frameworks:** Uses generalizable templates - **Minimal dependency:** Reduces reliance on specific examples - **Efficient reasoning:** Principle-driven over example-driven - **Self-improving:** Can enhance its own capabilities ## Quick Start ### Basic Usage ```bash # Generate content with self-improvement /infinite-meta specs/example_spec.md output/ 5 evolve # Analyze and improve the system /improve-self all standard # Generate new specifications /generate-spec patterns novel # Evolve orchestration strategy /evolve-strategy quality incremental # Validate everything works /self-test all standard # Update this documentation /self-document all standardAvailable Commands
{{#each commands}}
/{{name}}{{purpose}}
Capabilities: {{#each capabilities}}
- {{this}} {{/each}}
Usage:
{{usage_pattern}}Integration: {{integration_notes}} {{/each}}
System Architecture
Component Overview
┌─────────────────────────────────────────────┐ │ Meta-Level Control Layer │ │ - Self-analysis │ │ - Strategy evolution │ │ - Meta-prompting orchestration │ └─────────────────┬───────────────────────────┘ │ ┌─────────────────┴───────────────────────────┐ │ Command Layer │ │ - /infinite-meta (orchestrator) │ │ - /improve-self (analyzer) │ │ - /generate-spec (creator) │ │ - /evolve-strategy (evolver) │ │ - /self-test (validator) │ │ - /self-document (documenter) │ └─────────────────┬───────────────────────────┘ │ ┌─────────────────┴───────────────────────────┐ │ Data Layer │ │ - Specifications (generation templates) │ │ - Improvement logs (evolution history) │ │ - Meta-prompts (pattern library) │ │ - Generated content (outputs) │ └─────────────────────────────────────────────┘Data Flow
-
Generation Flow: Spec → infinite-meta → Sub-agents → Outputs → Improvement logs
-
Improvement Flow: Logs → improve-self → Proposals → evolve-strategy → Updated commands
-
Evolution Flow: Patterns → generate-spec → New specs → infinite-meta → More patterns
-
Meta Flow: System → self-test → Health data → self-document → Documentation
Meta-Level Capabilities
This system demonstrates advanced meta-capabilities:
- Self-Analysis: Analyzes its own performance and identifies improvements
- Self-Modification: Can improve its own commands and strategies (with safety)
- Self-Generation: Creates new specifications from discovered patterns
- Self-Testing: Validates its own functionality
- Self-Documentation: Updates its own documentation (this file!)
- Recursive Improvement: Improvements that improve improvements
Specifications
{{#each specs}}
{{name}}
{{description}}
Type: {{type}} Patterns: {{patterns}} Best For: {{use_cases}} {{/each}}
Performance Metrics
Current Performance:
- Quality Average: {{quality_avg}} / 10
- Efficiency Score: {{efficiency}}
- Diversity Index: {{diversity}}
- Meta-Awareness: {{meta_awareness}}
Evolution History:
- Total Improvements Applied: {{improvement_count}}
- Average Quality Gain: +{{quality_gain}}% per improvement
- System Age: {{age}} days
- Total Iterations Generated: {{total_iterations}}
Health Status: {{health_status}}
Improvement Log
Recent Improvements
{{#each recent_improvements}} {{date}}: {{description}}
- Impact: {{impact}}
- Metrics: {{metrics_change}} {{/each}}
Evolution Milestones
{{#each milestones}}
- {{version}} ({{date}}): {{achievement}} {{/each}}
Usage Examples
Example 1: Basic Generation with Evolution
# Generate 20 iterations with continuous improvement /infinite-meta specs/example_spec.md output/ 20 evolveThis will:
- Generate first wave (5 iterations)
- Analyze performance
- Evolve strategy
- Generate second wave (improved)
- Continue improving across 4 waves
Example 2: Complete Self-Improvement Cycle
# 1. Generate baseline /infinite-meta specs/example_spec.md baseline/ 10 # 2. Analyze for improvements /improve-self all deep # 3. Evolve strategy based on analysis /evolve-strategy quality incremental # 4. Generate with improved strategy /infinite-meta specs/example_spec.md improved/ 10 # 5. Compare results /self-test generation standardExample 3: Auto-Generate and Use New Spec
# 1. Generate new spec from patterns /generate-spec patterns novel custom_domain # 2. Use it immediately /infinite-meta specs/custom_domain.md output/ 10 evolve # 3. Document the results /self-document specs standardMeta-Prompting in Practice
How This System Applies Meta-Prompting
Structure-Oriented Design:
- Commands define frameworks, not just functions
- Specs provide patterns, not examples
- Improvements focus on structure, not content
Abstract Frameworks:
- Orchestration uses generalizable patterns
- Quality metrics are principle-based
- Evolution applies transferable insights
Minimal Example Dependency:
- Sub-agents receive structural guidance
- Specs emphasize "how to think" vs "what to create"
- Improvements extract abstract patterns
Efficient Reasoning:
- Reduced token usage through structural focus
- Pattern-based generation over example-based
- Meta-level optimization of processes
Safety and Guardrails
Self-Modification Safety
The system can improve itself, but with safeguards:
- ✓ All changes logged in improvement_log/
- ✓ Backups created before modifications
- ✓ Rollback procedures for all improvements
- ✓ Validation required before applying changes
- ✓ Human oversight for major architectural changes
Testing and Validation
- Automated testing via /self-test
- Regression detection
- Performance monitoring
- Health status tracking
Troubleshooting
System Health Check
/self-test all smoke # Quick 5-minute validationCommon Issues
Quality Declining:
/improve-self all deep /evolve-strategy quality incrementalEfficiency Issues:
/evolve-strategy efficiency experimental /self-test generation standardDocumentation Outdated:
/self-document all comprehensiveAdvanced Features
Recursive Self-Improvement
The system can improve the improvement process:
- /improve-self analyzes the system
- It can analyze /improve-self itself
- Generate improvements to the analyzer
- Apply those to make better analysis
- Meta-meta-improvement!
Pattern Library Evolution
The
meta_prompts/directory continuously evolves:- Successful patterns are added
- Ineffective patterns are removed
- Abstract frameworks are refined
- Meta-level insights accumulate
Contributing
Adding New Capabilities
- Create command in
.claude/commands/ - Follow meta-prompting principles
- Add self-improvement hooks
- Include meta-awareness
- Run /self-test to validate
- Run /self-document to update docs
Improving Existing Commands
- Use /improve-self to analyze
- Generate proposals
- Implement with safety checks
- Validate with /self-test
- Document with /self-document
Future Directions
Potential evolution paths:
- Multi-agent collaboration improvements
- Enhanced pattern recognition
- Cross-domain learning integration
- Advanced meta-meta-prompting
- Autonomous goal setting
- Self-optimizing context management
References
- Meta-Prompting Guide: https://www.promptingguide.ai/techniques/meta-prompting
- Improvement Logs:
improvement_log/ - Meta-Prompts Library:
meta_prompts/ - System Architecture:
docs/self_improvement_guide.md
This documentation was auto-generated by /self-document on {{timestamp}}. It reflects the current state of the system and will be automatically updated as the system evolves.
Meta-Note: This README can improve itself. If you notice outdated information, run
/self-document all comprehensiveto regenerate. -
Generate CLAUDE.md
# CLAUDE.md - Project Instructions **Auto-generated:** {{timestamp}} **System Version:** {{version}} ## Project Overview This is **Infinite Loop Variant 7**: A meta-level self-improvement system that can analyze, improve, and evolve itself using meta-prompting principles. ### Key Differentiator Unlike other infinite loop variants, this system has **meta-level awareness**: - Can improve its own commands - Generates new specifications from patterns - Evolves its orchestration strategy - Self-tests and self-documents - Applies recursive self-improvement ## Quick Start for Claude Code When working in this repository: ### Primary Commands ```bash # Main orchestration with self-improvement /infinite-meta <spec> <output> <count> [evolve] # Self-improvement utilities /improve-self [target] [depth] /generate-spec [source] [focus] [name] /evolve-strategy [metric] [type] /self-test [scope] [depth] /self-document [scope] [detail]Typical Workflows
Workflow 1: Generati and Improve
/infinite-meta specs/example_spec.md output/ 20 evolveWorkflow 2: Deep System Improvement
/improve-self all deep /evolve-strategy all incremental /self-test all standard /self-document all standardWorkflow 3: Create New Capability
/generate-spec patterns novel domain_name /infinite-meta specs/domain_name.md output/ 10 evolve /self-test generation standardArchitecture
Directory Structure
. ├── .claude/ │ ├── commands/ # All slash commands │ │ ├── infinite-meta.md │ │ ├── improve-self.md │ │ ├── generate-spec.md │ │ ├── evolve-strategy.md │ │ ├── self-test.md │ │ └── self-document.md │ └── settings.json # Permissions ├── specs/ # Specifications (generation templates) │ ├── example_spec.md │ └── auto_generated_*.md ├── improvement_log/ # Evolution history and metrics │ ├── wave_*_reflection.md │ ├── wave_*_proposals.md │ ├── evolved_strategy_*.md │ ├── test_report_*.md │ └── system_health.json ├── meta_prompts/ # Pattern library │ ├── command_improver.md │ ├── spec_generator.md │ └── orchestration_strategy.md ├── docs/ # Documentation │ └── self_improvement_guide.md ├── README.md # Auto-generated docs └── CLAUDE.md # This file (auto-generated)Key Principles
Meta-Prompting Based:
- Structure over content
- Patterns over examples
- Abstraction over specifics
- Efficiency through principles
Self-Improving:
- Analyzes own performance
- Generates improvement proposals
- Evolves strategy safely
- Validates changes automatically
Safety-First:
- All modifications logged
- Rollback procedures standard
- Validation before application
- Health monitoring continuous
Command Responsibilities
{{#each commands}}
{{name}}
Role: {{role}} Key Actions: {{actions}} Integrates With: {{integrations}} {{/each}}
Meta-Level Capabilities
- Self-Analysis: System examines its own processes
- Self-Modification: Commands can be improved (safely)
- Self-Generation: New specs created from patterns
- Self-Validation: Automated testing of capabilities
- Self-Documentation: This file updates itself!
- Recursive: Can improve the improvement process
Working with This System
For Generation Tasks
Use
/infinite-metawithevolvemode:- System will improve across waves
- Quality increases progressively
- Strategy evolves automatically
- Learnings accumulate in logs
For System Improvement
Use
/improve-selfthen/evolve-strategy:- Analyzes current state deeply
- Proposes concrete improvements
- Evolves orchestration approach
- Validates with /self-test
For New Capabilities
Use
/generate-specto create specs:- Analyzes existing patterns
- Generates new specifications
- Tests with small batch
- Refines based on results
For Validation
Use
/self-testregularly:- Smoke test after changes
- Standard test weekly
- Comprehensive before releases
- Detects regressions early
Important Notes
Safety Guardrails
- Never modify core commands without validation
- Always create backups before improvements
- Test changes with /self-test before full deployment
- Document all modifications in improvement_log/
- Rollback if metrics regress >15%
Performance Monitoring
Check
improvement_log/system_health.jsonfor:- Current health status
- Recent performance trends
- Known issues
- Improvement progress
Context Management
This system is context-aware:
- Monitors token usage
- Optimizes batch sizes
- Uses efficient prompting
- Prunes unnecessary context
Evolution History
Current Version: {{version}}
{{#each evolution_history}} v{{version}} ({{date}}):
- {{change_summary}}
- Impact: {{impact}} {{/each}}
Troubleshooting
System not improving:
- Check improvement_log/ for analysis
- Run /improve-self all deep
- Verify metrics in system_health.json
Quality declining:
- Run /self-test generation standard
- Use /evolve-strategy quality incremental
- Review recent changes in logs
Documentation outdated:
- Run /self-document all comprehensive
- System will auto-update README and this file
References
- Main documentation: README.md (auto-generated)
- Architecture guide: docs/self_improvement_guide.md
- Pattern library: meta_prompts/
- Evolution history: improvement_log/
This file is auto-maintained by /self-document. Last updated: {{timestamp}}
-
Generate Improvement Guide
Create
docs/self_improvement_guide.md:# Self-Improvement System Architecture Guide **Auto-generated:** {{timestamp}} ## Overview This guide explains how the meta-level self-improvement system works, enabling you to understand, use, and extend its capabilities. ## Core Concepts ### Meta-Prompting Based on principles from https://www.promptingguide.ai/techniques/meta-prompting: **Structure-Oriented:** - Focus on patterns and frameworks - Define "how to think" not "what to create" - Enable generalization across contexts **Minimal Example Dependency:** - Reduce reliance on specific examples - Use abstract templates - Principle-driven reasoning **Efficient Reasoning:** - Less token usage through structural focus - Pattern recognition over memorization - Meta-level optimization ### Self-Improvement Loop┌─────────────────────────────────────────┐ │ 1. GENERATE │ │ /infinite-meta creates content │ │ Logs performance metrics │ └──────────────┬──────────────────────────┘ │ ▼ ┌─────────────────────────────────────────┐ │ 2. ANALYZE │ │ /improve-self reviews performance │ │ Identifies improvement opportunities │ └──────────────┬──────────────────────────┘ │ ▼ ┌─────────────────────────────────────────┐ │ 3. EVOLVE │ │ /evolve-strategy creates new approach│ │ Updates orchestration patterns │ └──────────────┬──────────────────────────┘ │ ▼ ┌─────────────────────────────────────────┐ │ 4. VALIDATE │ │ /self-test confirms improvements │ │ Detects any regressions │ └──────────────┬──────────────────────────┘ │ ▼ ┌─────────────────────────────────────────┐ │ 5. DOCUMENT │ │ /self-document updates docs │ │ Records evolution history │ └──────────────┬──────────────────────────┘ │ └──────────► Back to 1. GENERATE (improved)
[Continue with detailed architectural explanations...]
Phase 4: Component-Specific Documentation
-
Document Commands (if scope includes "commands")
For each command in
.claude/commands/:- Extract purpose and usage
- Document parameters and options
- Show integration points
- Include examples
-
Document Specs (if scope includes "specs")
Create
specs/README.md:- List all specifications
- Categorize by type
- Show usage patterns
- Include generation statistics
-
Document Improvements (if scope includes "improvements")
Create
improvement_log/IMPROVEMENTS.md:- Timeline of all improvements
- Metrics progression
- Key milestones
- Lessons learned
Phase 5: Update and Finalize
-
Update Timestamps
Add "Last Updated" timestamps to all generated docs.
-
Generate Documentation Index
Create
docs/INDEX.mdlinking all documentation. -
Validate Links and References
Ensure all internal links work and references are accurate.
Success Criteria
Successful self-documentation:
- Accurate reflection of current state
- Clear and helpful for users
- Shows evolution and improvements
- Demonstrates meta-capabilities
- Auto-updates when system changes
- Enables understanding and extension
This command maintains system documentation using meta-prompting principles. It analyzes structure and generates documentation that reflects both current capabilities and evolution potential.