Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:00:50 +08:00
commit c5931553a6
106 changed files with 49995 additions and 0 deletions

View File

@@ -0,0 +1,671 @@
---
name: analyze:dependencies
description: Scan dependencies for CVE vulnerabilities across 11 package managers with fix recommendations
delegates-to: autonomous-agent:orchestrator
---
# Dependency Vulnerability Scanner
Comprehensive dependency vulnerability scanning across 11 package managers and ecosystems, with CVE database integration and automated fix recommendations.
## Usage
```bash
/analyze:dependencies [PATH] [OPTIONS]
```
**Examples**:
```bash
/analyze:dependencies # Scan current project
/analyze:dependencies backend/ # Scan specific directory
/analyze:dependencies --critical-only # Show only critical vulnerabilities
/analyze:dependencies --with-fixes # Include upgrade recommendations
```
## Supported Ecosystems
### Python (pip, pipenv, poetry)
**Tools**: pip-audit, safety
**Manifests**: requirements.txt, Pipfile, pyproject.toml, poetry.lock
### JavaScript/Node.js (npm, yarn, pnpm)
**Tools**: npm audit, yarn audit, pnpm audit
**Manifests**: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml
### Ruby (bundler)
**Tools**: bundle-audit
**Manifests**: Gemfile, Gemfile.lock
### PHP (composer)
**Tools**: local-php-security-checker
**Manifests**: composer.json, composer.lock
### Go (go modules)
**Tools**: govulncheck
**Manifests**: go.mod, go.sum
### Rust (cargo)
**Tools**: cargo-audit
**Manifests**: Cargo.toml, Cargo.lock
### Java (maven, gradle)
**Tools**: dependency-check
**Manifests**: pom.xml, build.gradle, build.gradle.kts
### .NET (nuget)
**Tools**: dotnet list package --vulnerable
**Manifests**: packages.config, *.csproj
## How It Works
### 1. Ecosystem Detection
Automatically detects package managers:
```
Detecting Ecosystems...
✅ Python (requirements.txt)
✅ JavaScript (package.json, yarn.lock)
✅ Go (go.mod)
```
### 2. Vulnerability Scanning
Runs appropriate scanners for each ecosystem:
```
Scanning Dependencies...
[████████████] Python (pip-audit) - 2.3s
[████████████] npm (npm audit) - 4.1s
[████████████] Go (govulncheck) - 1.8s
Results:
✅ Python: 5 vulnerabilities (2 critical)
✅ npm: 12 vulnerabilities (0 critical)
✅ Go: 0 vulnerabilities
```
### 3. Result Aggregation
Deduplicates and synthesizes results:
```
Aggregating Results...
- Total Vulnerabilities: 15 unique
- Duplicates Removed: 2
- Vulnerable Dependencies: 12/187
```
### 4. Risk Assessment
```
Risk Score (0-100) =
Critical × 25 +
High × 15 +
Medium × 8 +
Low × 3 +
Info × 1
Example:
- Critical: 2 -> 50 points
- High: 3 -> 45 points
- Medium: 7 -> 56 points
- Low: 3 -> 9 points
---
-----------------------
Total: 160 (capped at 100)
Risk Score: 100/100 (EXTREME)
```
**Risk Levels**:
- 70-100: Extreme/High Risk
- 40-69: Medium Risk
- 0-39: Low Risk
## Output Format
### Terminal Output (Tier 1: Concise Summary)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DEPENDENCY VULNERABILITY SCAN COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 Risk Score: 78/100 (HIGH RISK)
📊 Overview
Total Vulnerabilities: 15
Vulnerable Dependencies: 12/187 (6.4%)
Ecosystems: Python, npm, Go
🚨 Vulnerabilities by Severity
🔴 Critical: 2
🟠 High: 3
🟡 Medium: 7
🔵 Low: 3
⚪ Info: 0
📦 By Ecosystem
Python: 5 vulnerabilities
npm: 10 vulnerabilities
Go: 0 vulnerabilities
[WARN] Top 3 Vulnerable Packages
1. requests (Python) - 2 vulnerabilities
2. axios (npm) - 3 vulnerabilities
3. lodash (npm) - 2 vulnerabilities
🔴 Critical Vulnerabilities (2)
1. CVE-2023-12345 - requests 2.25.1
SQL injection vulnerability
Fix: Upgrade to 2.31.0+
2. CVE-2023-67890 - axios 0.21.1
Server-side request forgery
Fix: Upgrade to 1.6.0+
📄 Detailed Report: .data/reports/dependency-scan-2025-01-15.md
⏱️ Scan completed in 8.2s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### File Report (Tier 2: Comprehensive)
Saved to `.data/reports/dependency-scan-{DATE}.md`:
```markdown
# Dependency Vulnerability Scan Report
**Generated**: 2025-01-15 16:45:23
**Project**: /project
**Risk Score**: 78/100 (HIGH RISK)
---
## Executive Summary
**Total Vulnerabilities**: 15 unique
**Vulnerable Dependencies**: 12 out of 187 total (6.4%)
**Ecosystems Scanned**: Python, npm, Go
**Scan Duration**: 8.2s
**Risk Assessment**: HIGH RISK
- Immediate action required for 2 critical vulnerabilities
- 3 high-severity issues should be addressed soon
- 7 medium-severity issues for next sprint
- 3 low-severity issues can be deferred
---
## Vulnerabilities by Severity
| Severity | Count | Percentage |
|----------|-------|-----------|
| 🔴 Critical | 2 | 13.3% |
| 🟠 High | 3 | 20.0% |
| 🟡 Medium | 7 | 46.7% |
| 🔵 Low | 3 | 20.0% |
| ⚪ Info | 0 | 0.0% |
---
## Vulnerabilities by Ecosystem
### Python (5 vulnerabilities)
- **Critical**: 1
- **High**: 1
- **Medium**: 2
- **Low**: 1
### npm (10 vulnerabilities)
- **Critical**: 1
- **High**: 2
- **Medium**: 5
- **Low**: 2
### Go (0 vulnerabilities)
- No vulnerabilities detected
---
## Top 10 Vulnerable Packages
| Package | Ecosystem | Vulnerabilities | Severity |
|---------|-----------|----------------|----------|
| axios | npm | 3 | 1 Critical, 2 Medium |
| requests | Python | 2 | 1 Critical, 1 High |
| lodash | npm | 2 | 2 Medium |
| urllib3 | Python | 2 | 1 High, 1 Low |
| ws | npm | 1 | 1 High |
| express | npm | 1 | 1 Medium |
| jinja2 | Python | 1 | 1 Medium |
| moment | npm | 1 | 1 Low |
| pyyaml | Python | 1 | 1 Low |
| react-dom | npm | 1 | 1 Medium |
---
## Critical Vulnerabilities (IMMEDIATE ACTION REQUIRED)
### CVE-2023-12345: SQL Injection in requests
**Package**: requests (Python)
**Installed Version**: 2.25.1
**Severity**: 🔴 CRITICAL
**CVSS Score**: 9.8
**Description**:
SQL injection vulnerability in the `requests` library allows remote attackers to execute arbitrary SQL commands via crafted HTTP requests.
**Impact**:
- Database compromise
- Data exfiltration
- Unauthorized access
**CWE**: CWE-89 (SQL Injection)
**Fixed Versions**: 2.31.0, 2.32.0+
**Remediation**:
```bash
# Python (pip)
pip install --upgrade requests>=2.31.0
# Python (poetry)
poetry update requests
```
**References**:
- https://nvd.nist.gov/vuln/detail/CVE-2023-12345
- https://github.com/psf/requests/security/advisories/GHSA-xxxx
---
### CVE-2023-67890: SSRF in axios
**Package**: axios (npm)
**Installed Version**: 0.21.1
**Severity**: 🔴 CRITICAL
**CVSS Score**: 9.1
**Description**:
Server-side request forgery (SSRF) vulnerability allows attackers to make the server perform requests to arbitrary destinations.
**Impact**:
- Internal network scanning
- Access to internal services
- Data exfiltration from internal endpoints
**CWE**: CWE-918 (SSRF)
**Fixed Versions**: 1.6.0+
**Remediation**:
```bash
# npm
npm install axios@latest
# yarn
yarn upgrade axios@latest
```
**References**:
- https://nvd.nist.gov/vuln/detail/CVE-2023-67890
- https://github.com/axios/axios/security/advisories/GHSA-yyyy
---
## High Severity Vulnerabilities
### CVE-2023-11111: XSS in urllib3
**Package**: urllib3 (Python)
**Installed Version**: 1.26.5
**Severity**: 🟠 HIGH
**CVSS Score**: 7.5
**Description**:
Cross-site scripting vulnerability in URL parsing logic.
**Fixed Versions**: 1.26.18+, 2.0.7+
**Remediation**:
```bash
pip install --upgrade urllib3>=1.26.18
```
---
### CVE-2023-22222: DoS in ws
**Package**: ws (npm)
**Installed Version**: 7.4.5
**Severity**: 🟠 HIGH
**CVSS Score**: 7.5
**Description**:
Denial of service vulnerability via regular expression DoS in WebSocket implementation.
**Fixed Versions**: 7.5.10+, 8.17.1+
**Remediation**:
```bash
npm install ws@latest
```
---
### CVE-2023-33333: Path Traversal in express
**Package**: express (npm)
**Installed Version**: 4.17.1
**Severity**: 🟠 HIGH
**CVSS Score**: 7.3
**Description**:
Path traversal vulnerability allows access to files outside webroot.
**Fixed Versions**: 4.19.2+
**Remediation**:
```bash
npm install express@latest
```
---
## Medium Severity Vulnerabilities
[... 7 medium-severity vulnerabilities with similar detail ...]
---
## Low Severity Vulnerabilities
[... 3 low-severity vulnerabilities with similar detail ...]
---
## Upgrade Recommendations
### Python
```bash
# Upgrade all vulnerable packages
pip install --upgrade \
requests>=2.31.0 \
urllib3>=1.26.18 \
jinja2>=3.1.3 \
pyyaml>=6.0.1
# Or use requirements file
pip install -r requirements-secure.txt
```
**requirements-secure.txt** (generated):
```
requests>=2.31.0
urllib3>=1.26.18
jinja2>=3.1.3
pyyaml>=6.0.1
```
---
### npm
```bash
# Upgrade all vulnerable packages
npm install \
axios@latest \
lodash@latest \
ws@latest \
express@latest \
moment@latest \
react-dom@latest
# Or auto-fix with npm audit
npm audit fix --force
```
---
## Automated Fix Options
### Safe Auto-Upgrades (Recommended)
These upgrades are backward-compatible (semver minor/patch):
```bash
# Python
pip install --upgrade requests urllib3 pyyaml
# npm
npm audit fix
```
### Manual Review Required
These upgrades may have breaking changes (semver major):
- **axios**: 0.21.1 -> 1.6.0 (major version bump)
- Review: Breaking changes in request config
- Test: All HTTP client code
- **express**: 4.17.1 -> 4.19.2 (minor bump, but middleware changes)
- Review: Middleware compatibility
- Test: All routes and error handlers
---
## Dependency Health Summary
### Total Dependencies: 187
**By Ecosystem**:
- Python: 45 packages
- npm: 142 packages
- Go: 0 packages
**Security Status**:
- ✅ Secure: 175 packages (93.6%)
- [WARN] Vulnerable: 12 packages (6.4%)
**Freshness**:
- Up-to-date: 120 packages (64.2%)
- Minor updates available: 45 packages (24.1%)
- Major updates available: 22 packages (11.8%)
---
## License Compliance
**Detected Licenses**:
- MIT: 95 packages
- Apache-2.0: 32 packages
- BSD-3-Clause: 18 packages
- ISC: 25 packages
- GPL-3.0: 2 packages [WARN] (Review required)
- Unknown: 15 packages [WARN] (Investigate)
---
## Risk Score Breakdown
```
Component Scores:
- Critical Vulnerabilities (2 × 25): 50 points
- High Vulnerabilities (3 × 15): 45 points
- Medium Vulnerabilities (7 × 8): 56 points
- Low Vulnerabilities (3 × 3): 9 points
--------------------------------------------
Total: 160 points (capped at 100)
Final Risk Score: 100/100 -> Normalized: 78/100
```
**Risk Level**: 🔴 HIGH RISK
**Mitigation**:
1. Fix 2 critical vulnerabilities immediately
2. Fix 3 high vulnerabilities within 48 hours
3. Schedule medium vulnerabilities for next sprint
4. Low vulnerabilities can be deferred
**Estimated Time to Secure**:
- Critical fixes: 2-4 hours
- High fixes: 4-6 hours
- Testing: 8-12 hours
- **Total**: 1-2 days
---
## Action Plan
### Phase 1: Emergency Fixes (Today)
1. Upgrade `requests` to 2.31.0+ (30 min)
2. Upgrade `axios` to 1.6.0+ (45 min + testing)
3. Run test suite (30 min)
4. Deploy hotfix (30 min)
**Total**: 2-3 hours
### Phase 2: High Priority (This Week)
1. Upgrade `urllib3`, `ws`, `express` (2 hours)
2. Run comprehensive tests (4 hours)
3. QA validation (2 hours)
4. Deploy to production (1 hour)
**Total**: 9 hours
### Phase 3: Medium Priority (Next Sprint)
1. Upgrade remaining 7 packages (3 hours)
2. Testing (4 hours)
3. Documentation updates (1 hour)
**Total**: 8 hours
---
## Continuous Monitoring
**Recommendations**:
1. **CI/CD Integration**: Add dependency scanning to pipeline
2. **Weekly Scans**: Schedule automated vulnerability scans
3. **Dependency Updates**: Review updates monthly
4. **Security Alerts**: Subscribe to security advisories
**GitHub Actions Example**:
```yaml
name: Dependency Scan
on:
schedule:
- cron: '0 0 * * 0' # Weekly
pull_request:
branches: [main]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Scan Dependencies
run: /analyze:dependencies --format=sarif --output=results.sarif
- name: Upload Results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
```
---
## Next Steps
1.**Review this report** with development team
2. [WARN] **Create tickets** for each critical/high vulnerability
3. [WARN] **Schedule fixes** according to action plan
4. [WARN] **Set up CI/CD** scanning for future PRs
5. [WARN] **Subscribe** to security advisories for critical packages
---
**End of Report**
```
## Advanced Features
### Critical-Only Mode
```bash
/analyze:dependencies --critical-only
```
Shows only critical vulnerabilities for rapid triage.
### With Fix Recommendations
```bash
/analyze:dependencies --with-fixes
```
Includes detailed upgrade commands and compatibility notes.
### JSON Output for CI/CD
```bash
/analyze:dependencies --format=json --output=scan-results.json
```
Machine-readable format for automation.
### SARIF Output
```bash
/analyze:dependencies --format=sarif
```
Standard format for security tools integration.
## Integration with Learning System
The dependency scanner integrates with pattern learning:
```python
# After each scan
learning_engine.store_pattern({
"task_type": "dependency_scan",
"context": {
"ecosystems": ["python", "npm"],
"total_dependencies": 187,
"vulnerable_count": 12
},
"outcome": {
"risk_score": 78,
"critical_count": 2,
"high_count": 3
},
"trends": {
"risk_score_delta": -5, # Improved from last scan
"new_vulnerabilities": 3,
"fixed_vulnerabilities": 8
}
})
```
## Performance Expectations
| Ecosystem | Dependencies | Scan Time |
|-----------|-------------|-----------|
| Python | <50 | 5-15s |
| Python | 50-200 | 15-45s |
| npm | <100 | 10-30s |
| npm | 100-500 | 30-90s |
| Go | <50 | 5-10s |
| Rust | <50 | 10-20s |
| Multi | Mixed | 30-120s |
## Best Practices
1. **Scan Before Deploy**: Always scan before production deployment
2. **Fix Critical First**: Prioritize by severity and exploitability
3. **Test After Upgrade**: Run full test suite after security updates
4. **Monitor Trends**: Track risk score over time
5. **Automate Scanning**: Integrate into CI/CD pipeline
6. **Stay Updated**: Review security advisories weekly
7. **Document Decisions**: Record why certain vulnerabilities are accepted
---
This command provides comprehensive dependency vulnerability scanning with minimal setup and maximum actionable insight.

543
commands/analyze/explain.md Normal file
View File

@@ -0,0 +1,543 @@
---
name: analyze:explain
description: Explain and analyze task, event, or code without making modifications - read-only review
delegates-to: autonomous-agent:orchestrator
---
# Analyze-Explain Command
## Command: `/analyze:explain`
**Read-only analysis and explanation** - Reviews and explains tasks, events, code, or issues without making any modifications. Perfect for understanding what needs to be done before committing to changes.
**🔍 Pure Analysis Mode:**
- **Zero Modifications**: Absolutely no code changes, no fixes, no commits
- **Comprehensive Explanation**: Detailed breakdown of what, why, and how
- **Impact Analysis**: What would change if task were implemented
- **Risk Assessment**: Potential issues and concerns
- **Recommendation Generation**: Suggested approaches without implementation
- **Learning Integration**: Learns from analysis patterns
## How It Works
1. **Task Understanding**: Analyzes the request or code in detail
2. **Context Gathering**: Examines relevant code, files, and dependencies
3. **Impact Assessment**: Identifies what would be affected by changes
4. **Risk Analysis**: Evaluates potential problems and edge cases
5. **Approach Recommendation**: Suggests optimal implementation strategies
6. **Pattern Learning**: Stores analysis patterns for future reference
## Usage
### Basic Usage
```bash
# Explain a feature request
/analyze:explain "add user authentication with JWT"
# Explain existing code or issue
/analyze:explain "why is the login endpoint failing"
# Explain error or bug
/analyze:explain "investigate memory leak in data processing"
# Explain architectural decision
/analyze:explain "should we use microservices or monolith for this project"
```
### With Context
```bash
# Explain with specific file context
/analyze:explain "how does authentication work in auth/login.py"
# Explain with repository URL
/analyze:explain "analyze authentication approach in https://github.com/user/repo"
# Explain test failures
/analyze:explain "why are these 5 tests failing in test_auth.py"
# Explain performance issue
/analyze:explain "what's causing slow response times in API endpoints"
```
### Advanced Options
```bash
# Detailed technical explanation
/analyze:explain "explain JWT implementation" --detail-level technical
# High-level overview
/analyze:explain "explain authentication system" --detail-level overview
# Include code examples in explanation
/analyze:explain "how to implement caching" --include-examples
# Compare multiple approaches
/analyze:explain "Redis vs Memcached for caching" --compare-approaches
```
## Output Format
### Terminal Output (Concise Summary)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 ANALYSIS COMPLETE - READ-ONLY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Task: "add user authentication with JWT"
Complexity: Medium | Estimated Time: 3-4 hours | Risk Level: Medium
Key Findings:
* No existing authentication system detected
* 8 endpoints would need protection
* JWT library not in dependencies
Critical Considerations:
1. Token storage strategy (localStorage vs httpOnly cookies)
2. Refresh token implementation required
3. Password hashing strategy needed
Recommended Approach:
1. Install python-jose and passlib
2. Implement token generation/validation
3. Add authentication middleware
📄 Full analysis: .claude/data/reports/explain-auth-jwt-2025-10-29.md
⏱ Analysis completed in 45 seconds
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Next Steps:
* Review full analysis report
* Use /dev:auto "add JWT auth" to implement
* Use /analyze:quality to validate after implementation
```
### Detailed Report (.claude/data/reports/)
```markdown
=======================================================
TASK ANALYSIS REPORT - READ-ONLY
=======================================================
Generated: 2025-10-29 16:30:00
Task: "add user authentication with JWT"
Status: ANALYSIS ONLY - NO MODIFICATIONS MADE
+- Task Understanding ---------------------------------+
| Request: Implement JWT-based authentication system |
| |
| Requirements Breakdown: |
| 1. User registration endpoint |
| 2. Login endpoint with JWT token generation |
| 3. Token validation middleware |
| 4. Token refresh mechanism |
| 5. Logout functionality (token invalidation) |
| 6. Protected route implementation |
| |
| Technical Components: |
| * JWT token generation and validation |
| * Password hashing (bcrypt/argon2) |
| * Token storage strategy |
| * Middleware for route protection |
| * Refresh token rotation |
+-------------------------------------------------------+
+- Current State Analysis -----------------------------+
| Project Type: FastAPI/Flask application |
| Current Auth: None detected |
| |
| Affected Files (would be modified): |
| * main.py - Add auth middleware |
| * models.py - Add User model |
| * routes/auth.py - New file for auth endpoints |
| * utils/security.py - New file for JWT/hashing |
| * requirements.txt - Add dependencies |
| |
| Protected Endpoints (would need auth): |
| * POST /api/users/profile |
| * GET /api/users/me |
| * PUT /api/users/update |
| * DELETE /api/users/delete |
| * GET /api/admin/* |
| * [3 more endpoints] |
+-------------------------------------------------------+
+- Implementation Impact ------------------------------+
| Estimated Changes: |
| * Files Created: 4 new files |
| * Files Modified: 6 existing files |
| * Lines Added: ~450-600 lines |
| * Dependencies: 3 new packages |
| |
| Breaking Changes: |
| * All protected endpoints require auth header |
| * Clients must implement token storage |
| * Login flow changes for existing users |
| |
| Database Changes: |
| * New 'users' table required |
| * New 'refresh_tokens' table required |
| * Migration scripts needed |
+-------------------------------------------------------+
+- Risk Assessment ------------------------------------+
| Security Risks: |
| * [HIGH] Token storage vulnerabilities |
| * [HIGH] Password hashing strength |
| * [MED] Token expiration strategy |
| * [MED] Refresh token rotation |
| * [LOW] CORS configuration for auth |
| |
| Technical Risks: |
| * [MED] Breaking existing API clients |
| * [MED] Token validation performance impact |
| * [LOW] Database migration complexity |
| |
| Operational Risks: |
| * [MED] User migration to new auth system |
| * [LOW] Monitoring and logging requirements |
+-------------------------------------------------------+
+- Recommended Approaches -----------------------------+
| Approach 1: Standard JWT (Recommended) |
| +- Pros: |
| | * Industry standard |
| | * Well-tested libraries available |
| | * Good documentation |
| | * Stateless authentication |
| +- Cons: |
| | * Token revocation complexity |
| | * Larger token size |
| +- Libraries: |
| | * python-jose[cryptography] |
| | * passlib[bcrypt] |
| | * python-multipart |
| +- Estimated Time: 3-4 hours |
| +- Complexity: Medium |
| |
| Approach 2: JWT + Redis for Token Blacklist |
| +- Pros: |
| | * Token revocation support |
| | * Better security |
| | * Session management |
| +- Cons: |
| | * Additional infrastructure (Redis) |
| | * More complex setup |
| | * Stateful authentication |
| +- Estimated Time: 5-6 hours |
| +- Complexity: Medium-High |
| |
| Approach 3: OAuth2 with JWT |
| +- Pros: |
| | * OAuth2 standard compliance |
| | * Third-party provider support |
| | * Flexible scope management |
| +- Cons: |
| | * More complex implementation |
| | * Requires additional setup |
| +- Estimated Time: 6-8 hours |
| +- Complexity: High |
+-------------------------------------------------------+
+- Implementation Steps (if you proceed) --------------+
| Phase 1: Setup & Dependencies (30 min) |
| 1. Install required packages |
| 2. Configure environment variables |
| 3. Set up database models |
| |
| Phase 2: Core Auth Logic (90 min) |
| 4. Implement password hashing utilities |
| 5. Create JWT token generation |
| 6. Implement token validation |
| 7. Add refresh token mechanism |
| |
| Phase 3: Endpoints (60 min) |
| 8. Create registration endpoint |
| 9. Create login endpoint |
| 10. Create token refresh endpoint |
| 11. Create logout endpoint |
| |
| Phase 4: Middleware & Protection (45 min) |
| 12. Implement authentication middleware |
| 13. Protect existing endpoints |
| 14. Add role-based access control (optional) |
| |
| Phase 5: Testing & Documentation (45 min) |
| 15. Write unit tests |
| 16. Write integration tests |
| 17. Update API documentation |
| 18. Add usage examples |
+-------------------------------------------------------+
+- Code Examples (Reference Only) ---------------------+
| Token Generation Example: |
| |
| ```python |
| from jose import jwt |
| from datetime import datetime, timedelta |
| |
| def create_access_token(data: dict): |
| to_encode = data.copy() |
| expire = datetime.utcnow() + timedelta(minutes=15)|
| to_encode.update({"exp": expire}) |
| return jwt.encode(to_encode, SECRET_KEY, ALGO) |
| ``` |
| |
| Middleware Example: |
| |
| ```python |
| from fastapi import Depends, HTTPException |
| |
| async def get_current_user(token: str = Depends(...)):|
| try: |
| payload = jwt.decode(token, SECRET_KEY, ALGO)|
| return payload.get("sub") |
| except JWTError: |
| raise HTTPException(401, "Invalid token") |
| ``` |
+-------------------------------------------------------+
+- Configuration Requirements -------------------------+
| Environment Variables Needed: |
| * SECRET_KEY - JWT signing key (strong random) |
| * ALGORITHM - "HS256" (default) or "RS256" |
| * ACCESS_TOKEN_EXPIRE_MINUTES - 15-30 recommended |
| * REFRESH_TOKEN_EXPIRE_DAYS - 7-30 recommended |
| |
| Database Schema: |
| * users table: id, username, email, password_hash |
| * refresh_tokens table: token, user_id, expires_at |
+-------------------------------------------------------+
+- Testing Strategy -----------------------------------+
| Unit Tests Required: |
| * Token generation with valid data |
| * Token validation with valid/invalid tokens |
| * Password hashing and verification |
| * Token expiration handling |
| |
| Integration Tests Required: |
| * User registration flow |
| * Login and token retrieval |
| * Protected endpoint access with valid token |
| * Protected endpoint rejection without token |
| * Token refresh flow |
| * Logout and token invalidation |
+-------------------------------------------------------+
+- Pattern Learning Insights --------------------------+
| Similar Tasks Found: 3 previous auth implementations |
| |
| Common Success Patterns: |
| * Using python-jose over PyJWT (92% success rate) |
| * Implementing refresh tokens from start (87%) |
| * Using httpOnly cookies for tokens (84%) |
| |
| Common Pitfalls to Avoid: |
| * Weak SECRET_KEY generation (found in 23% of cases) |
| * Missing token expiration (found in 18% of cases) |
| * No refresh token rotation (found in 31% of cases) |
| |
| Learned Optimizations: |
| * Cache token validation results (15% faster) |
| * Use background tasks for token cleanup |
| * Implement rate limiting on auth endpoints |
+-------------------------------------------------------+
+- Recommendations Summary ----------------------------+
| 1. [RECOMMENDED] Use Approach 1 (Standard JWT) |
| - Best balance of simplicity and security |
| - Well-documented and tested |
| - 3-4 hour implementation time |
| |
| 2. Add refresh token mechanism from start |
| - Prevents need for later refactoring |
| - Better user experience |
| |
| 3. Use httpOnly cookies instead of localStorage |
| - More secure against XSS attacks |
| - Industry best practice |
| |
| 4. Implement rate limiting on auth endpoints |
| - Prevents brute force attacks |
| - Add from the start |
| |
| 5. Write comprehensive tests |
| - Auth is security-critical |
| - 90%+ coverage recommended |
+-------------------------------------------------------+
=======================================================
NEXT STEPS
=======================================================
Ready to Implement?
* Use: /dev:auto "add JWT authentication with refresh tokens"
* Review: Read this report carefully first
* Prepare: Backup database before migration
Need More Analysis?
* Security review: /validate:security
* Architecture review: /analyze:project
* Compare with existing repos: /analyze:repository <url>
Questions or Concerns?
* Review pattern learning insights above
* Check similar implementations in patterns database
* Consult team for security-critical decisions
=======================================================
Analysis Time: 45 seconds
Pattern Matches: 3 similar tasks
Confidence Level: High (92%)
Recommendation Strength: Strong
NO MODIFICATIONS WERE MADE TO ANY FILES
This is a read-only analysis report.
```
## Integration with Learning System
The `/analyze:explain` command integrates with pattern learning:
**Learning from Analysis**:
- Common task patterns and requirements
- Effective explanation structures
- Risk assessment accuracy
- Recommendation quality
- User follow-through rates
**Pattern Storage**:
```json
{
"explain_patterns": {
"task_type": "authentication_jwt",
"analysis_approach": {
"breakdown_depth": "detailed",
"risk_assessment": "comprehensive",
"approaches_compared": 3,
"code_examples_included": true
},
"outcome": {
"user_implemented": true,
"implementation_success": true,
"analysis_accuracy": 0.95,
"time_estimate_accuracy": 0.88
},
"reuse_count": 8,
"effectiveness_score": 0.92
}
}
```
## Agent Delegation
`/analyze:explain` delegates to:
- **orchestrator**: Main analysis coordinator
- **code-analyzer**: Code structure and impact analysis
- **security-auditor**: Security risk assessment
- **pattern-learning**: Similar task pattern matching
## Skills Integration
Auto-loads relevant skills:
- **code-analysis**: For code understanding
- **pattern-learning**: For similar task identification
- **security-patterns**: For security considerations
- **documentation-best-practices**: For clear explanations
## Use Cases
### Before Implementation
```bash
# Understand requirements before coding
/analyze:explain "implement real-time notifications"
# Review the analysis
# Then implement: /dev:auto "implement real-time notifications"
```
### Understanding Existing Code
```bash
# Understand how something works
/analyze:explain "how does the caching system work in cache.py"
```
### Troubleshooting
```bash
# Understand what's wrong before fixing
/analyze:explain "why is the API returning 500 errors"
# Review the analysis
# Then fix: /dev:auto "fix API 500 errors"
```
### Decision Making
```bash
# Compare approaches
/analyze:explain "should we use GraphQL or REST for the new API"
```
### Learning
```bash
# Learn from external repositories
/analyze:explain "how does authentication work in https://github.com/fastapi/fastapi"
```
## Best Practices
### Good Explain Requests
```bash
# Specific and focused
/analyze:explain "explain JWT token refresh mechanism in auth/token.py"
# Clear context provided
/analyze:explain "why are tests failing after adding authentication"
# Decision-oriented
/analyze:explain "compare WebSocket vs Server-Sent Events for real-time updates"
```
### Poor Explain Requests
```bash
# Too vague
/analyze:explain "explain the code"
# Too broad
/analyze:explain "explain everything about the project"
# Not analysis-focused
/analyze:explain "fix all bugs" # Use /dev:auto instead
```
## Output Options
### Detail Levels
- **overview**: High-level summary (default)
- **technical**: Detailed technical analysis
- **comparison**: Compare multiple approaches
- **security**: Focus on security considerations
### Include Examples
```bash
# With code examples
/analyze:explain "JWT implementation" --include-examples
# Without code examples (faster)
/analyze:explain "JWT implementation" --no-examples
```
## Performance Metrics
- **Analysis Time**: 30-90 seconds typically
- **Accuracy**: 90-95% for requirement understanding
- **Time Estimates**: ±20% accuracy
- **Risk Identification**: 85-90% of critical risks identified
---
**Version**: 1.0.0
**Integration**: Uses orchestrator, code-analyzer, security-auditor agents
**Skills**: code-analysis, pattern-learning, security-patterns
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Full integration with pattern learning system
**Mode**: READ-ONLY - No modifications ever made

685
commands/analyze/groups.md Normal file
View File

@@ -0,0 +1,685 @@
---
name: analyze:groups
description: Deep analysis of four-tier group behavior, collaboration patterns, and optimization recommendations
version: 7.0.0
category: analysis
---
# Analyze Groups Command
Perform comprehensive deep analysis of all four agent groups including collaboration patterns, bottlenecks, optimization opportunities, and actionable recommendations for improving group coordination and performance.
## What This Command Does
**Analyzes**:
1. **Group Collaboration Patterns** - How groups work together, communication patterns, handoff quality
2. **Performance Bottlenecks** - Where delays occur, which groups need optimization
3. **Specialization Effectiveness** - Whether groups are specializing appropriately
4. **Knowledge Flow Analysis** - How knowledge transfers between groups
5. **Decision Quality Analysis** - Group 2 decision-making effectiveness
6. **Validation Effectiveness** - Group 4 validation impact on quality
**Delivers**:
- Root cause analysis of performance issues
- Specific optimization recommendations
- Communication improvement strategies
- Specialization guidance
- Actionable next steps
## Execution Steps
### Step 1: Load Comprehensive Data
```python
from lib.group_collaboration_system import get_group_collaboration_stats, analyze_workflow_efficiency
from lib.group_performance_tracker import get_group_performance, compare_groups, analyze_workflow_efficiency as group_workflow
from lib.inter_group_knowledge_transfer import get_knowledge_transfer_stats, get_transfer_effectiveness
from lib.group_specialization_learner import get_specialization_profile, get_recommended_group_for_task, get_learning_insights
from lib.agent_feedback_system import get_feedback_stats
from lib.decision_explainer import get_all_explanations
from lib.proactive_suggester import get_statistics as get_suggestion_stats
# Gather all data for last 100 tasks
collaboration_stats = get_group_collaboration_stats()
workflow_efficiency = analyze_workflow_efficiency()
knowledge_effectiveness = get_transfer_effectiveness()
learning_insights = get_learning_insights()
suggestion_stats = get_suggestion_stats()
```
### Step 2: Analyze Group Collaboration Patterns
```python
def analyze_collaboration_patterns(collab_stats):
"""Identify collaboration patterns and issues"""
patterns_found = []
issues_found = []
# Pattern 1: Sequential Flow (Normal)
if collab_stats['group_1_to_2']['success_rate'] > 0.9 and \
collab_stats['group_2_to_3']['success_rate'] > 0.9 and \
collab_stats['group_3_to_4']['success_rate'] > 0.9:
patterns_found.append({
"pattern": "healthy_sequential_flow",
"description": "Groups collaborate sequentially with high success",
"status": "excellent"
})
# Pattern 2: Feedback Loop Effectiveness
feedback_loops = [
collab_stats.get('group_4_to_1', {}),
collab_stats.get('group_4_to_2', {}),
collab_stats.get('group_4_to_3', {})
]
avg_feedback_effectiveness = sum(loop.get('effectiveness', 0) for loop in feedback_loops) / 3
if avg_feedback_effectiveness < 0.7:
issues_found.append({
"issue": "weak_feedback_loops",
"severity": "medium",
"description": "Group 4 feedback not effectively improving other groups",
"recommendation": "Review feedback quality and actionability"
})
# Pattern 3: Bottleneck Detection
communication_times = {
"G1->G2": collab_stats['group_1_to_2'].get('avg_time_seconds', 0),
"G2->G3": collab_stats['group_2_to_3'].get('avg_time_seconds', 0),
"G3->G4": collab_stats['group_3_to_4'].get('avg_time_seconds', 0)
}
max_time = max(communication_times.values())
for flow, time in communication_times.items():
if time > max_time * 0.7: # More than 70% of max
issues_found.append({
"issue": "communication_bottleneck",
"severity": "high",
"location": flow,
"description": f"Communication delay in {flow}: {time}s",
"recommendation": f"Optimize {flow.split('->')[0]} output preparation"
})
return patterns_found, issues_found
```
### Step 3: Analyze Performance Bottlenecks
```python
def identify_bottlenecks():
"""Identify which groups are performance bottlenecks"""
bottlenecks = []
for group_num in [1, 2, 3, 4]:
perf = get_group_performance(group_num)
# Check success rate
if perf.get('success_rate', 1.0) < 0.8:
bottlenecks.append({
"group": group_num,
"issue": "low_success_rate",
"value": perf['success_rate'],
"severity": "high",
"recommendation": "Review group training and specialization"
})
# Check execution time
if perf.get('avg_execution_time', 0) > 300: # 5 minutes
bottlenecks.append({
"group": group_num,
"issue": "slow_execution",
"value": perf['avg_execution_time'],
"severity": "medium",
"recommendation": "Profile and optimize slow operations"
})
# Check quality output
if perf.get('avg_quality_score', 100) < 75:
bottlenecks.append({
"group": group_num,
"issue": "low_quality_output",
"value": perf['avg_quality_score'],
"severity": "high",
"recommendation": "Improve group capabilities or adjust expectations"
})
return bottlenecks
```
### Step 4: Analyze Specialization Effectiveness
```python
def analyze_specialization():
"""Check if groups are developing appropriate specializations"""
specialization_analysis = {}
for group_num in [1, 2, 3, 4]:
profile = get_specialization_profile(group_num)
specializations = profile.get('specializations', [])
task_count = profile.get('total_tasks', 0)
# Ideal: 3-5 clear specializations after 100+ tasks
if task_count < 50:
status = "insufficient_data"
recommendation = f"Need {50 - task_count} more tasks to identify specializations"
elif len(specializations) == 0:
status = "no_specialization"
recommendation = "Group not developing specializations - may need more diverse tasks"
elif len(specializations) < 3:
status = "emerging"
recommendation = "Specializations emerging - continue diverse task exposure"
elif len(specializations) <= 5:
status = "optimal"
recommendation = "Good specialization balance - maintain current task distribution"
else:
status = "over_specialized"
recommendation = "Too many specializations - may indicate lack of focus"
specialization_analysis[f"Group {group_num}"] = {
"status": status,
"specializations": specializations,
"task_count": task_count,
"recommendation": recommendation
}
return specialization_analysis
```
### Step 5: Analyze Knowledge Flow
```python
def analyze_knowledge_flow(knowledge_stats):
"""Analyze how knowledge flows between groups"""
flow_analysis = {
"total_knowledge": knowledge_stats.get('total_knowledge', 0),
"successful_transfers": knowledge_stats.get('successful_transfers', 0),
"transfer_success_rate": knowledge_stats.get('transfer_success_rate', 0),
"flow_patterns": []
}
# Identify dominant knowledge sources
sources = {}
for transfer in knowledge_stats.get('transfers', []):
source = transfer.get('source_group')
sources[source] = sources.get(source, 0) + 1
# Check if knowledge is distributed or concentrated
if sources:
max_source = max(sources.values())
if max_source > sum(sources.values()) * 0.6:
flow_analysis['flow_patterns'].append({
"pattern": "concentrated_source",
"description": f"Group {max(sources, key=sources.get)} is primary knowledge source ({max_source} items)",
"recommendation": "Encourage knowledge sharing from other groups"
})
else:
flow_analysis['flow_patterns'].append({
"pattern": "distributed_sources",
"description": "Knowledge well-distributed across groups",
"status": "healthy"
})
# Check transfer effectiveness
if flow_analysis['transfer_success_rate'] < 0.7:
flow_analysis['flow_patterns'].append({
"pattern": "low_transfer_effectiveness",
"severity": "medium",
"description": f"Knowledge transfer success rate: {flow_analysis['transfer_success_rate']:.1%}",
"recommendation": "Improve knowledge quality, context, and applicability"
})
return flow_analysis
```
### Step 6: Decision Quality Analysis (Group 2)
```python
def analyze_decision_quality():
"""Analyze Group 2 decision-making effectiveness"""
group2_perf = get_group_performance(2)
explanations = get_all_explanations() # Get recent decision explanations
analysis = {
"total_decisions": group2_perf.get('total_tasks', 0),
"decision_accuracy": group2_perf.get('success_rate', 0),
"avg_confidence": group2_perf.get('avg_confidence', 0),
"user_alignment": 0, # From user_preference_learner
"issues": [],
"strengths": []
}
# Check decision accuracy
if analysis['decision_accuracy'] < 0.85:
analysis['issues'].append({
"issue": "low_decision_accuracy",
"value": analysis['decision_accuracy'],
"severity": "high",
"description": "Decisions not leading to successful outcomes",
"recommendation": "Review decision criteria and incorporate more historical data"
})
else:
analysis['strengths'].append("High decision accuracy")
# Check confidence calibration
if analysis['avg_confidence'] > 0.9 and analysis['decision_accuracy'] < 0.85:
analysis['issues'].append({
"issue": "overconfident_decisions",
"severity": "medium",
"description": "Confidence higher than actual success rate",
"recommendation": "Calibrate confidence scoring - add uncertainty factors"
})
# Check explanation quality
if len(explanations) > 0:
avg_explanation_completeness = sum(
len(e.get('why_chosen', [])) + len(e.get('why_not_alternatives', []))
for e in explanations
) / len(explanations)
if avg_explanation_completeness < 5:
analysis['issues'].append({
"issue": "sparse_explanations",
"severity": "low",
"description": "Decision explanations lack detail",
"recommendation": "Enhance decision_explainer to provide more comprehensive reasoning"
})
return analysis
```
### Step 7: Validation Effectiveness Analysis (Group 4)
```python
def analyze_validation_effectiveness():
"""Analyze Group 4 validation impact"""
group4_perf = get_group_performance(4)
analysis = {
"total_validations": group4_perf.get('total_tasks', 0),
"go_rate": 0, # Percentage of GO decisions
"nogo_rate": 0, # Percentage of NO-GO decisions
"avg_quality_score": group4_perf.get('avg_quality_score', 0),
"feedback_effectiveness": 0,
"issues": [],
"impact": []
}
# Ideal GO rate: 70-85% (too high = not catching issues, too low = too strict)
# This data would come from validation results
# For now, use placeholders
if analysis['go_rate'] > 0.9:
analysis['issues'].append({
"issue": "validation_too_lenient",
"severity": "medium",
"description": f"GO rate too high ({analysis['go_rate']:.1%}) - may miss quality issues",
"recommendation": "Review validation thresholds and criteria"
})
elif analysis['go_rate'] < 0.6:
analysis['issues'].append({
"issue": "validation_too_strict",
"severity": "low",
"description": f"GO rate too low ({analysis['go_rate']:.1%}) - may cause unnecessary iterations",
"recommendation": "Consider relaxing validation thresholds or improving Group 3 output quality"
})
# Check if validation is improving quality
# Compare quality scores before/after validation feedback
# This would require analysis of quality trends after Group 4 feedback
return analysis
```
### Step 8: Generate Comprehensive Analysis Report
**Report Structure**:
```markdown
# Four-Tier Group Analysis Report
Generated: {timestamp}
Analysis Period: Last {n} tasks
## Executive Summary
**Overall Health**: {score}/100 ({status})
**Key Findings**:
1. {finding_1}
2. {finding_2}
3. {finding_3}
**Critical Issues**: {critical_count}
**Optimization Opportunities**: {opportunity_count}
---
## 1. Collaboration Pattern Analysis
### Identified Patterns
#### Pattern: {pattern_name}
**Status**: {excellent/good/needs_attention}
**Description**: {description}
**Impact**: {impact_description}
### Collaboration Issues
#### Issue: {issue_name}
**Severity**: {high/medium/low}
**Location**: {group_flow}
**Description**: {detailed_description}
**Root Cause Analysis**:
- {cause_1}
- {cause_2}
**Recommendation**:
- {recommendation_1}
- {recommendation_2}
**Expected Improvement**: {improvement_description}
---
## 2. Performance Bottleneck Analysis
### Bottlenecks Identified
#### Bottleneck: {bottleneck_name}
**Group**: Group {group_num} ({group_name})
**Type**: {slow_execution/low_success/poor_quality}
**Severity**: {high/medium/low}
**Metrics**:
- Current Performance: {metric_value}
- Expected Performance: {target_value}
- Gap: {gap_value}
**Impact on System**:
{impact_description}
**Root Cause**:
{root_cause_analysis}
**Optimization Strategy**:
1. **Immediate Actions** (Next 1-5 tasks):
- {action_1}
- {action_2}
2. **Short-term Improvements** (Next 10-20 tasks):
- {improvement_1}
- {improvement_2}
3. **Long-term Optimization** (Next 50+ tasks):
- {strategy_1}
- {strategy_2}
**Expected Results**:
- Performance Improvement: {improvement}%
- Time Savings: {time} per task
- Quality Impact: +{points} points
---
## 3. Specialization Analysis
### Group Specialization Status
#### Group 1 (Strategic Analysis & Intelligence)
**Status**: {optimal/emerging/no_specialization/over_specialized}
**Task Count**: {count}
**Current Specializations**:
1. {specialization_1}: {success_rate}% success, {count} tasks
2. {specialization_2}: {success_rate}% success, {count} tasks
3. {specialization_3}: {success_rate}% success, {count} tasks
**Analysis**:
{analysis_description}
**Recommendation**:
{recommendation}
---
(Repeat for Groups 2, 3, 4)
---
## 4. Knowledge Flow Analysis
### Knowledge Transfer Effectiveness
**Total Knowledge Base**: {count} items
**Successful Transfers**: {success_count} ({success_rate}%)
**Knowledge Sources**:
- Group 1: {count} items
- Group 2: {count} items
- Group 3: {count} items
- Group 4: {count} items
### Flow Patterns
#### Pattern: {pattern_name}
**Description**: {description}
**Impact**: {positive/negative}
**Recommendation**: {recommendation}
### Knowledge Gaps
**Identified Gaps**:
1. {gap_description} - Missing knowledge in {area}
2. {gap_description} - Underutilized knowledge from {source}
**Impact**: {impact_description}
**Actions**:
- {action_1}
- {action_2}
---
## 5. Decision Quality Analysis (Group 2)
### Decision-Making Effectiveness
**Total Decisions**: {count}
**Decision Accuracy**: {accuracy}%
**Average Confidence**: {confidence}
**User Alignment**: {alignment}%
### Strengths
- {strength_1}
- {strength_2}
### Areas for Improvement
#### Issue: {issue_name}
**Severity**: {severity}
**Description**: {description}
**Analysis**:
{detailed_analysis}
**Recommendation**:
{actionable_recommendation}
**Expected Impact**:
- Decision Accuracy: +{improvement}%
- User Satisfaction: +{improvement}%
---
## 6. Validation Effectiveness Analysis (Group 4)
### Validation Impact
**Total Validations**: {count}
**GO Rate**: {rate}%
**NO-GO Rate**: {rate}%
**Average Quality Score**: {score}/100
### Five-Layer Performance
- Functional (30 pts): {avg}/30 ({status})
- Quality (25 pts): {avg}/25 ({status})
- Performance (20 pts): {avg}/20 ({status})
- Integration (15 pts): {avg}/15 ({status})
- UX (10 pts): {avg}/10 ({status})
### Validation Effectiveness
**Feedback Impact**:
- Quality Improvements Driven: +{points} avg
- Issues Prevented: {count}
- Iterations Saved: {count}
### Issues & Recommendations
{issue_analysis}
---
## 7. Optimization Roadmap
### Immediate Actions (Implement Now)
#### Action 1: {action_name}
**Priority**: High
**Group(s) Affected**: {groups}
**Implementation**: {steps}
**Expected Impact**: {impact}
**Effort**: {hours} hours
---
(Additional immediate actions)
---
### Short-Term Improvements (Next 10-20 Tasks)
#### Improvement 1: {improvement_name}
**Objective**: {objective}
**Implementation Strategy**: {strategy}
**Success Metrics**: {metrics}
**Timeline**: {timeline}
---
### Long-Term Strategic Changes (Next 50+ Tasks)
#### Strategy 1: {strategy_name}
**Vision**: {vision_statement}
**Approach**: {approach_description}
**Milestones**: {milestones}
**Expected Transformation**: {transformation_description}
---
## 8. Success Metrics & KPIs
### Target Metrics (30-day goals)
| Metric | Current | Target | Gap |
|--------|---------|--------|-----|
| Overall Quality Score | {current} | {target} | {gap} |
| Average Iterations | {current} | {target} | {gap} |
| Decision Accuracy | {current}% | {target}% | {gap}% |
| Communication Success | {current}% | {target}% | {gap}% |
| GO Rate | {current}% | {target}% | {gap}% |
### Tracking Plan
**Weekly Checkpoints**:
- Run `/monitor:groups` weekly
- Track KPI progress
- Adjust strategies as needed
**Monthly Reviews**:
- Run `/analyze:groups` monthly
- Comprehensive performance review
- Strategic adjustments
---
## Conclusion
**System Status**: {status}
**Key Takeaways**:
1. {takeaway_1}
2. {takeaway_2}
3. {takeaway_3}
**Next Steps**:
1. {next_step_1}
2. {next_step_2}
3. {next_step_3}
**Confidence in Recommendations**: {confidence}%
---
Report Path: .claude/data/reports/group-analysis-{date}.md
```
## Result Presentation
**Terminal Output (15-20 lines max)**:
```
+==============================================================+
| FOUR-TIER GROUP ANALYSIS REPORT |
+==============================================================+
Overall Health: {score}/100 ({status})
Analysis Period: Last {n} tasks
KEY FINDINGS:
[PASS] {finding_1}
[WARN] {finding_2}
[FAIL] {finding_3}
CRITICAL ISSUES: {count}
* {issue_1}
* {issue_2}
OPTIMIZATION OPPORTUNITIES: {count}
* {opportunity_1}
* {opportunity_2}
TOP RECOMMENDATIONS:
1. [{priority}] {recommendation_1}
2. [{priority}] {recommendation_2}
📄 Detailed Analysis: .claude/data/reports/group-analysis-{date}.md
⏱️ Execution Time: {time}s
```
**File Report**: Save complete analysis to `.claude/data/reports/group-analysis-YYYY-MM-DD.md`
## Notes
- **Deep Analysis**: Goes beyond monitoring to identify root causes
- **Actionable**: Every issue comes with specific recommendations
- **Prioritized**: Clear immediate, short-term, and long-term actions
- **Data-Driven**: Based on comprehensive metrics across all systems
- **Run Monthly**: Or when performance issues are observed
- **Complements**: `/monitor:groups` (real-time) vs `/analyze:groups` (deep dive)
## Integration
Uses all four-tier learning systems:
- `lib/group_collaboration_system.py`
- `lib/group_performance_tracker.py`
- `lib/inter_group_knowledge_transfer.py`
- `lib/group_specialization_learner.py`
- `lib/agent_performance_tracker.py`
- `lib/agent_feedback_system.py`
- `lib/decision_explainer.py`
- `lib/proactive_suggester.py`

145
commands/analyze/project.md Normal file
View File

@@ -0,0 +1,145 @@
---
name: analyze:project
description: Autonomously analyze the project with automatic skill selection and pattern learning
delegates-to: autonomous-agent:orchestrator
# Auto-Analyze Command
Analyze the current project autonomously using the orchestrator agent. This will:
- Auto-detect project type and technologies
- Load relevant skills based on project context
- Run code analysis in background
- Generate comprehensive quality report
- Store learned patterns for future use
The orchestrator will make all decisions autonomously without requiring confirmation at each step.
## How It Works
1. **Project Detection**: Analyzes project structure, files, and configuration
2. **Context Analysis**: Determines project type, languages, and frameworks
3. **Skill Loading**: Auto-selects relevant skills based on context
4. **Analysis Execution**: Runs comprehensive code analysis
5. **Pattern Learning**: Stores successful approaches for future similar projects
6. **Report Generation**: Creates detailed analysis report
**IMPORTANT**: When delegating this command to the orchestrator agent, the agent MUST:
1. Show concise terminal output (15-20 lines max) with top 3 findings and recommendations
2. Save detailed report to `.claude/data/reports/auto-analyze-YYYY-MM-DD.md` with ALL findings
3. Include file path in terminal output
4. Never complete silently, never show 50+ lines in terminal
## Usage
```bash
/analyze:project
```
## Example Output
The orchestrator MUST use two-tier presentation:
### Terminal Output (Concise)
```
[PASS] Auto-Analyze Complete - Quality: 88/100
Key Findings:
* Python/FastAPI project, 127 files analyzed
* 4 failing tests in auth module
* 12 functions missing docstrings
Top Recommendations:
1. [HIGH] Fix failing auth tests -> +4 quality points
2. [MED] Add docstrings to public APIs
3. [MED] Refactor high-complexity functions
📄 Full report: .claude/data/reports/analyze-project-2025-10-21.md
⏱ Completed in 2.3 minutes
```
### File Report (Detailed)
Saved to `.claude/data/reports/analyze-project-2025-10-21.md`:
```
=======================================================
AUTO-ANALYZE DETAILED REPORT
=======================================================
Generated: 2025-10-21 14:30:00
+- Project Context ------------------------------------+
| Type: Python project with FastAPI framework |
| Languages: Python 3.9+ |
| Frameworks: FastAPI, SQLAlchemy, Pydantic |
| Total Files: 127 |
| Lines of Code: 12,450 |
+-------------------------------------------------------+
+- Quality Assessment ---------------------------------+
| Overall Score: 88/100 [PASS] |
| Tests: 45 tests, 92% passing (41/45) |
| Coverage: 82% |
| Standards: 89% compliant |
| Documentation: 85% complete |
| Pattern Adherence: 95% |
+-------------------------------------------------------+
+- Strengths ------------------------------------------+
| * Well-structured API endpoints |
| * Good test coverage on core modules |
| * Consistent coding style |
| * Clear separation of concerns |
| * Effective use of Pydantic for validation |
+-------------------------------------------------------+
+- Issues Found ---------------------------------------+
| Tests: |
| * test_user_login() - AssertionError (auth.py:45) |
| * test_token_refresh() - Timeout (auth.py:89) |
| * test_logout() - Connection error (auth.py:112) |
| * test_password_reset() - Invalid state (auth.py:145)|
| |
| Documentation: |
| * 12 functions missing docstrings |
| * API endpoint documentation incomplete |
| |
| Complexity: |
| * get_user_permissions() - Cyclomatic: 18 (auth.py) |
| * validate_token() - Cyclomatic: 16 (auth.py) |
| * process_payment() - Cyclomatic: 15 (payment.py) |
+-------------------------------------------------------+
+- All Recommendations --------------------------------+
| 1. [HIGH] Fix 4 failing tests in auth module |
| -> Expected quality impact: +4 points |
| -> Run /quality-check for auto-fix |
| |
| 2. [MED] Add docstrings to 12 public functions |
| -> Improves maintainability and API documentation |
| -> Expected quality impact: +2 points |
| |
| 3. [MED] Refactor 3 high-complexity functions |
| -> Target: get_user_permissions(), validate_token()|
| -> Expected quality impact: +2 points |
| |
| 4. [LOW] Complete API endpoint documentation |
| -> Add OpenAPI descriptions |
| -> Expected quality impact: +1 point |
+-------------------------------------------------------+
Skills Loaded: code-analysis, quality-standards, pattern-learning
Agents Used: autonomous-agent:code-analyzer, autonomous-agent:background-task-manager
Patterns Stored: 1 new pattern in .claude-patterns/
Analysis Time: 2.3 minutes
=======================================================
```
## See Also
- `/analyze:quality` - Comprehensive quality control with auto-fix
- `/learn:init` - Initialize pattern learning database
---

158
commands/analyze/quality.md Normal file
View File

@@ -0,0 +1,158 @@
---
name: analyze:quality
description: Run comprehensive quality control with autonomous auto-fixing
delegates-to: autonomous-agent:orchestrator
---
# Quality Check Command
## 🚨 CRITICAL: RESPONSE SAFETY REQUIREMENTS
**SYSTEM-WIDE FAILURE PREVENTION**: When generating ANY response content for this command, you MUST ensure:
1. **NEVER generate empty text blocks** - All content blocks must have non-empty text
2. **NEVER use Unicode box characters** (=, |, +, +, etc.) - Use safe ASCII alternatives
3. **ALWAYS provide fallback content** for any section that might be empty
4. **VALIDATE all content blocks** before finalizing response
5. **NEVER leave sections empty** - Provide default values for missing data
**SAFE RESPONSE PATTERN**:
- Use ASCII characters instead of Unicode box drawing
- Ensure every score section has actual numeric values
- Provide default content when data is missing
- Never return empty strings or whitespace-only content
- Always include actionable recommendations
**FAILURE TO COMPLY**: Will cause `cache_control cannot be set for empty text blocks` errors and break ALL Claude functionality.
Run comprehensive quality control check with autonomous fixing. This will:
- Run all tests and analyze coverage
- Check code standards compliance
- Verify documentation completeness
- Validate pattern adherence
- Auto-fix issues when possible
- Generate quality report with trends
## How It Works
1. **Test Execution**: Runs all tests and calculates coverage
2. **Standards Check**: Validates code against style and standards
3. **Documentation Review**: Checks for missing or incomplete docs
4. **Pattern Validation**: Verifies adherence to learned patterns
5. **Auto-Fix Loop**: Automatically fixes issues (repeats if needed)
6. **Quality Assessment**: Calculates overall quality score (0-100)
7. **Trend Analysis**: Compares against historical data
**IMPORTANT**: This command delegates to `autonomous-agent:orchestrator` which MUST present a detailed quality report to the user showing scores, test results, auto-fix actions, and specific recommendations. Silent completion is not acceptable.
## Usage
```bash
/analyze:quality
```
## Quality Scoring
- **Test Coverage**: 30 points (aim for >80%)
- **Code Standards**: 25 points (style, conventions)
- **Documentation**: 20 points (completeness)
- **Pattern Adherence**: 15 points (learned patterns)
- **Code Metrics**: 10 points (complexity, maintainability)
**Pass Threshold**: 70/100
If score < 70, auto-fix loop is triggered automatically.
## Example Output
The orchestrator MUST present results in this format:
```
============================================================
QUALITY CHECK COMPLETED
============================================================
+-------------------------------------------------------+
| OVERALL QUALITY SCORE
+-------------------------------------------------------+
| Current Score: 88/100 [PASS] |
| Previous Score: 83/100 |
| Trend: +5 points (improving) |
| Status: Above threshold (70+) |
+-------------------------------------------------------+
+-------------------------------------------------------+
| QUALITY BREAKDOWN
+-------------------------------------------------------+
| Tests (30 pts): 26/30 [PASS] |
| 45 passed, 2 failed | 88% coverage |
| |
| Standards (25 pts): 18/25 [WARN] |
| 18 style violations found |
| |
| Documentation (20 pts): 19/20 [PASS] |
| 97% of public APIs documented |
| |
| Patterns (15 pts): 15/15 [PASS] |
| Adheres to 8/8 learned patterns |
| |
| Metrics (10 pts): 10/10 [PASS] |
| Acceptable complexity levels |
+-------------------------------------------------------+
+-------------------------------------------------------+
| AUTO-FIX ACTIONS TAKEN
+-------------------------------------------------------+
| * Fixed 12 style violations (auto-formatted) |
| * Added 3 missing docstrings |
| * Updated 1 outdated dependency |
| * Quality improved from 83 -> 88 (+5 points) |
+-------------------------------------------------------+
+-------------------------------------------------------+
| REMAINING ISSUES
+-------------------------------------------------------+
| Tests: |
| * test_user_login() - AssertionError (auth.py:45) |
| * test_token_refresh() - Timeout (auth.py:89) |
| |
| Standards: |
| * 6 violations require manual review |
| (complex refactoring needed) |
+-------------------------------------------------------+
+-------------------------------------------------------+
| RECOMMENDATIONS
+-------------------------------------------------------+
| 1. [HIGH] Fix 2 failing tests in auth module |
| -> Expected +4 quality points |
| 2. [MED] Refactor complex functions flagged |
| -> Expected +2 quality points |
| 3. [LOW] Review 6 manual style violations |
| -> Expected +1 quality point |
+-------------------------------------------------------+
Skills Loaded: quality-standards, testing-strategies
Agents Used: autonomous-agent:quality-controller, autonomous-agent:test-engineer
Auto-Fix Iterations: 2 (converged)
Patterns Stored: Quality pattern updated in .claude-patterns/
Check Time: 1.8 minutes
============================================================
```
## Auto-Fix Details
When quality < 70, the plugin will:
1. Run failing tests individually
2. Fix style violations
3. Generate missing documentation
4. Suggest pattern improvements
5. Re-check quality
6. Iterate up to 3 times
## See Also
- `/analyze:project` - Autonomous project analysis
- `/learn:init` - Initialize pattern learning database

View File

@@ -0,0 +1,661 @@
---
name: analyze:repository
description: Analyze external GitHub/GitLab repo for insights, patterns, and improvement opportunities
delegates-to: autonomous-agent:orchestrator
---
# Analyze-Repository Command
## Command: `/analyze:repository`
**Deep analysis of external repositories** - Explores and analyzes GitHub/GitLab repositories (by URL or local path) to identify strengths, weaknesses, features, and generate specific recommendations for enhancing this plugin based on discovered capabilities.
**🔍 Comprehensive Repository Analysis:**
- **Feature Discovery**: Identifies all major features and capabilities
- **Quality Assessment**: Evaluates code quality, structure, and design
- **Strength/Weakness Analysis**: What the repository does well and poorly
- **Plugin Enhancement Recommendations**: How to improve THIS plugin based on discoveries
- **Pattern Learning**: Learns successful patterns from external projects
- **Comparative Analysis**: Compares with similar projects
## How It Works
1. **Repository Access**: Clones or accesses repository (URL or local path)
2. **Structure Analysis**: Maps project architecture and organization
3. **Feature Extraction**: Identifies key features and capabilities
4. **Quality Assessment**: Evaluates code quality and design patterns
5. **Strength/Weakness Evaluation**: Analyzes what works well and what doesn't
6. **Plugin Enhancement Analysis**: Determines how to enhance THIS plugin
7. **Pattern Learning**: Stores successful patterns for future use
## Usage
### Basic Usage
```bash
# Analyze GitHub repository by URL
/analyze:repository https://github.com/username/repo
# Analyze local repository
/analyze:repository /path/to/local/repo
# Analyze GitLab repository
/analyze:repository https://gitlab.com/username/repo
```
### With Specific Focus
```bash
# Focus on architecture and design
/analyze:repository https://github.com/user/repo --focus architecture
# Focus on testing strategies
/analyze:repository https://github.com/user/repo --focus testing
# Focus on documentation approach
/analyze:repository https://github.com/user/repo --focus documentation
# Focus on CI/CD and automation
/analyze:repository https://github.com/user/repo --focus automation
```
### Advanced Options
```bash
# Deep analysis with all metrics
/analyze:repository https://github.com/user/repo --deep-analysis
# Compare with current project
/analyze:repository https://github.com/user/repo --compare-with-current
# Focus on plugin enhancement opportunities
/analyze:repository https://github.com/user/repo --plugin-enhancement-focus
# Include dependency analysis
/analyze:repository https://github.com/user/repo --analyze-dependencies
# Generate implementation roadmap
/analyze:repository https://github.com/user/repo --generate-roadmap
```
## Output Format
### Terminal Output (Concise Summary)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 REPOSITORY ANALYSIS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Repository: fastapi/fastapi
Type: Python Web Framework | Stars: 68.5k | Quality: 94/100
Key Features Discovered:
* Automatic API documentation generation (OpenAPI/Swagger)
* Dependency injection system
* Async request handling with type validation
Top Strengths:
1. Excellent type hint usage throughout
2. Comprehensive test coverage (96%)
3. Outstanding documentation with examples
Plugin Enhancement Opportunities:
1. [HIGH] Add automatic OpenAPI schema generation for analyzed APIs
2. [MED] Implement dependency injection pattern in agents
3. [MED] Enhanced async operation support in background tasks
📄 Full report: .claude/data/reports/analyze-repo-fastapi-2025-10-29.md
⏱ Analysis completed in 3.2 minutes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Detailed Report (.claude/data/reports/)
```markdown
=======================================================
REPOSITORY ANALYSIS REPORT
=======================================================
Generated: 2025-10-29 16:45:00
Repository: https://github.com/fastapi/fastapi
Branch: main | Commit: abc1234 | Stars: 68,500
+- Repository Overview --------------------------------+
| Project: FastAPI |
| Type: Python Web Framework |
| Language: Python 3.7+ |
| License: MIT |
| |
| Statistics: |
| * Files: 487 |
| * Lines of Code: 45,230 |
| * Contributors: 487 |
| * Commits: 3,892 |
| * Stars: 68,500 |
| * Forks: 5,742 |
| * Open Issues: 234 |
| |
| Main Technologies: |
| * Python 3.7+ with type hints |
| * Pydantic for validation |
| * Starlette for async support |
| * OpenAPI/Swagger for documentation |
+-------------------------------------------------------+
+- Key Features Discovered ----------------------------+
| 1. Automatic API Documentation |
| * OpenAPI schema auto-generation |
| * Interactive Swagger UI |
| * ReDoc alternative documentation |
| * JSON Schema exports |
| Implementation: /fastapi/openapi/utils.py |
| |
| 2. Dependency Injection System |
| * Type-based dependency resolution |
| * Nested dependency support |
| * Async dependency handling |
| * Automatic request parameter injection |
| Implementation: /fastapi/dependencies/ |
| |
| 3. Type-Safe Request/Response Handling |
| * Pydantic model integration |
| * Automatic validation |
| * Type hint-based parameter extraction |
| * Response model enforcement |
| Implementation: /fastapi/routing/ |
| |
| 4. Async/Await Support |
| * Full async request handlers |
| * Background task execution |
| * Streaming responses |
| * WebSocket support |
| Implementation: /fastapi/concurrency.py |
| |
| 5. Advanced Testing Infrastructure |
| * Comprehensive test suite (96% coverage) |
| * Test client with async support |
| * Fixture-based testing |
| * Integration and unit test separation |
| Implementation: /tests/ |
+-------------------------------------------------------+
+- Strengths Analysis ---------------------------------+
| Code Quality (94/100): |
| ✅ Exceptional type hint coverage (99%) |
| ✅ Comprehensive docstrings with examples |
| ✅ Consistent code style throughout |
| ✅ Low cyclomatic complexity (avg: 4.2) |
| ✅ DRY principles well applied |
| |
| Testing (96/100): |
| ✅ 96% test coverage |
| ✅ 2,145 tests, all passing |
| ✅ Fast test execution (<30s) |
| ✅ Clear test organization |
| ✅ Property-based testing for edge cases |
| |
| Documentation (98/100): |
| ✅ Outstanding main documentation |
| ✅ Extensive tutorials and guides |
| ✅ Real-world examples included |
| ✅ Multi-language documentation (10+ languages) |
| ✅ Auto-generated API docs from code |
| |
| Architecture (92/100): |
| ✅ Clean separation of concerns |
| ✅ Modular design with clear boundaries |
| ✅ Extensible plugin system |
| ✅ Minimal external dependencies |
| ✅ Performance-optimized core |
| |
| Developer Experience (95/100): |
| ✅ Intuitive API design |
| ✅ Excellent error messages |
| ✅ Fast development iteration |
| ✅ Auto-complete friendly (type hints) |
| ✅ Minimal boilerplate required |
+-------------------------------------------------------+
+- Weaknesses Analysis --------------------------------+
| Areas for Improvement: |
| |
| [WARN] Complex Dependency Resolution (Medium) |
| * Nested dependencies can be hard to debug |
| * Circular dependency detection limited |
| * Error messages sometimes unclear |
| Impact: Developer Experience |
| Files: /fastapi/dependencies/utils.py:234-567 |
| |
| [WARN] Limited Built-in Caching (Medium) |
| * No built-in response caching mechanism |
| * Requires external libraries |
| * Cache invalidation strategy not documented |
| Impact: Performance |
| Workaround: Use third-party libraries |
| |
| [WARN] WebSocket Documentation (Low) |
| * WebSocket examples limited |
| * Advanced patterns not well documented |
| * Error handling examples missing |
| Impact: Feature Adoption |
| Files: /docs/advanced/websockets.md |
| |
| [WARN] Middleware Ordering (Low) |
| * Middleware execution order not intuitive |
| * Documentation could be clearer |
| * Debugging middleware chain difficult |
| Impact: Developer Experience |
| Files: /fastapi/middleware/ |
+-------------------------------------------------------+
+- Design Patterns Observed ---------------------------+
| 1. Dependency Injection Pattern |
| Usage: Core architectural pattern |
| Implementation: Type-based resolution |
| Quality: Excellent (95/100) |
| Reusability: High |
| |
| 2. Decorator Pattern |
| Usage: Route definition and middleware |
| Implementation: Python decorators |
| Quality: Excellent (94/100) |
| Reusability: High |
| |
| 3. Factory Pattern |
| Usage: Application and router creation |
| Implementation: Builder-style API |
| Quality: Good (87/100) |
| Reusability: Medium |
| |
| 4. Observer Pattern (Events) |
| Usage: Startup/shutdown hooks |
| Implementation: Event handlers |
| Quality: Good (85/100) |
| Reusability: Medium |
| |
| 5. Strategy Pattern (Validation) |
| Usage: Customizable validation strategies |
| Implementation: Pydantic validators |
| Quality: Excellent (92/100) |
| Reusability: High |
+-------------------------------------------------------+
+- Technology Stack Analysis --------------------------+
| Core Dependencies: |
| * Starlette - ASGI framework (excellent choice) |
| * Pydantic - Data validation (industry standard) |
| * python-multipart - File uploads (necessary) |
| |
| Development Dependencies: |
| * pytest - Testing framework (standard) |
| * black - Code formatter (excellent) |
| * mypy - Type checking (essential) |
| * ruff - Fast linting (modern choice) |
| |
| Optional Dependencies: |
| * uvicorn - ASGI server (recommended) |
| * orjson - Fast JSON (performance) |
| * ujson - Alternative JSON (compatibility) |
| |
| Dependency Management: |
| ✅ Minimal required dependencies |
| ✅ Clear optional dependency groups |
| ✅ Version constraints well defined |
| ✅ Regular security updates |
+-------------------------------------------------------+
+- Plugin Enhancement Recommendations -----------------+
| CRITICAL recommendations for THIS plugin: |
| |
| 1. [HIGH PRIORITY] Automatic Schema Generation |
| Learning: FastAPI auto-generates OpenAPI schemas |
| | |
| Recommendation for This Plugin: |
| * Add agent: api-schema-generator.md |
| * Auto-analyze API endpoints in projects |
| * Generate OpenAPI/Swagger documentation |
| * Validate API contracts automatically |
| * Integrate with /validate:fullstack |
| | |
| Implementation Approach: |
| * Create skills/api-documentation/ skill |
| * Add schema generation to api-contract-validator |
| * Store API patterns in pattern database |
| * Learn from successful API designs |
| | |
| Expected Impact: HIGH |
| * Better API analysis capabilities |
| * Automatic documentation generation |
| * Improved validation accuracy |
| Estimated Effort: 6-8 hours |
| |
| 2. [HIGH PRIORITY] Enhanced Dependency Injection |
| Learning: Type-based dependency resolution |
| | |
| Recommendation for This Plugin: |
| * Implement dependency injection for agents |
| * Auto-resolve agent dependencies |
| * Share context between agents efficiently |
| * Reduce agent coupling |
| | |
| Implementation Approach: |
| * Add dependency resolution to orchestrator |
| * Create agent dependency registry |
| * Implement type-based agent injection |
| * Cache resolved dependencies |
| | |
| Expected Impact: MEDIUM-HIGH |
| * Cleaner agent architecture |
| * Better performance (caching) |
| * Easier agent development |
| Estimated Effort: 8-10 hours |
| |
| 3. [MEDIUM PRIORITY] Advanced Async Operations |
| Learning: Full async/await support throughout |
| | |
| Recommendation for This Plugin: |
| * Enhance background-task-manager with async |
| * Add parallel agent execution |
| * Implement async skill loading |
| * Add WebSocket support for real-time updates |
| | |
| Implementation Approach: |
| * Update background-task-manager to async |
| * Add async execution pool |
| * Implement task priority queuing |
| * Add progress streaming support |
| | |
| Expected Impact: MEDIUM |
| * Faster execution times (parallel) |
| * Better resource utilization |
| * Real-time progress updates |
| Estimated Effort: 10-12 hours |
| |
| 4. [MEDIUM PRIORITY] Type-Safe Agent Communication |
| Learning: Pydantic models for type safety |
| | |
| Recommendation for This Plugin: |
| * Define agent input/output schemas |
| * Validate agent communication automatically |
| * Generate agent interfaces from schemas |
| * Add type checking to agent delegation |
| | |
| Implementation Approach: |
| * Create agent schema definitions |
| * Add Pydantic models for agent I/O |
| * Integrate validation in orchestrator |
| * Add schema versioning support |
| | |
| Expected Impact: MEDIUM |
| * Fewer agent communication errors |
| * Better debugging |
| * Self-documenting agent interfaces |
| Estimated Effort: 6-8 hours |
| |
| 5. [LOW-MEDIUM PRIORITY] Enhanced Error Messages |
| Learning: Descriptive, actionable error messages |
| | |
| Recommendation for This Plugin: |
| * Improve error message clarity |
| * Add suggested fixes to errors |
| * Include relevant context in errors |
| * Add error recovery suggestions |
| | |
| Implementation Approach: |
| * Create error message templates |
| * Add context capture to all agents |
| * Implement error pattern detection |
| * Store error resolution patterns |
| | |
| Expected Impact: LOW-MEDIUM |
| * Better developer experience |
| * Faster debugging |
| * Reduced support needs |
| Estimated Effort: 4-6 hours |
+-------------------------------------------------------+
+- Implementation Roadmap ------------------------------+
| Phase 1: High-Priority Enhancements (2-3 weeks) |
| Week 1-2: API Schema Generation |
| +- Create api-schema-generator agent |
| +- Implement OpenAPI schema extraction |
| +- Add to /validate:fullstack command |
| +- Test with multiple API frameworks |
| |
| Week 2-3: Dependency Injection System |
| +- Design agent dependency system |
| +- Implement type-based resolution |
| +- Update orchestrator for DI support |
| +- Refactor existing agents to use DI |
| |
| Phase 2: Medium-Priority Enhancements (2-3 weeks) |
| Week 4-5: Async Operations Enhancement |
| +- Upgrade background-task-manager to async |
| +- Add parallel agent execution |
| +- Implement task priority queue |
| +- Add real-time progress updates |
| |
| Week 5-6: Type-Safe Communication |
| +- Define agent schemas |
| +- Add Pydantic validation |
| +- Update all agent interfaces |
| +- Add schema versioning |
| |
| Phase 3: Quality Improvements (1 week) |
| Week 7: Error Message Enhancement |
| +- Create error message templates |
| +- Add context capture |
| +- Implement pattern detection |
| +- Test and refine messages |
+-------------------------------------------------------+
+- Learning Patterns to Store -------------------------+
| 1. Type Hint Usage Pattern |
| * Comprehensive type hints improve maintainability|
| * Type checking catches 73% of bugs early |
| * IDE support improves developer productivity 40% |
| Store in: .claude-patterns/typing-patterns.json |
| |
| 2. Auto-Documentation Pattern |
| * Documentation from code reduces sync issues |
| * Examples in docstrings improve understanding |
| * API docs generated from type hints save time |
| Store in: .claude-patterns/documentation.json |
| |
| 3. Dependency Injection Pattern |
| * DI reduces coupling between components |
| * Type-based resolution is intuitive |
| * Caching dependencies improves performance |
| Store in: .claude-patterns/architecture.json |
| |
| 4. Async-First Architecture |
| * Async from start easier than refactoring later |
| * Background tasks improve responsiveness |
| * Parallel execution increases throughput |
| Store in: .claude-patterns/async-patterns.json |
| |
| 5. Comprehensive Testing Strategy |
| * High coverage (90%+) catches regressions |
| * Fast tests encourage frequent running |
| * Integration tests complement unit tests |
| Store in: .claude-patterns/testing-patterns.json |
+-------------------------------------------------------+
+- Comparative Analysis -------------------------------+
| Comparing FastAPI with This Plugin: |
| |
| Similarities: |
| ✅ Both emphasize code quality |
| ✅ Both have comprehensive testing |
| ✅ Both use Python 3.7+ features |
| ✅ Both focus on developer experience |
| ✅ Both have modular architecture |
| |
| Differences: |
| This Plugin vs FastAPI |
| * Markdown-based config -> Python code config |
| * Agent-based execution -> Request-based exec |
| * File-based skills -> Import-based modules |
| * Pattern learning -> No learning system |
| * Auto skill selection -> Manual dependency def |
| |
| What This Plugin Does Better: |
| ✅ Automatic pattern learning |
| ✅ No-code agent configuration |
| ✅ Autonomous decision making |
| ✅ Cross-project pattern sharing |
| |
| What FastAPI Does Better: |
| ✅ Type-based dependency injection |
| ✅ Automatic documentation generation |
| ✅ Async-first architecture |
| ✅ Comprehensive error messages |
| ✅ Type-safe interfaces |
+-------------------------------------------------------+
=======================================================
NEXT STEPS
=======================================================
Ready to Implement Enhancements?
* Start with Phase 1, High Priority items
* Use: /dev:auto "implement API schema generation agent"
* Track progress with: /learn:analytics
Want More Analysis?
* Analyze similar repositories for comparison
* Deep-dive into specific features
* Review implementation details
Questions or Feedback?
* Review recommendations carefully
* Prioritize based on your project needs
* Consider resource constraints
=======================================================
Analysis Time: 3.2 minutes
Files Analyzed: 487
Quality Score: 94/100
Enhancement Opportunities: 5 high-value recommendations
This analysis has been stored in pattern database for future reference.
```
## Integration with Learning System
The `/analyze:repository` command integrates with pattern learning:
**Learning from External Repos**:
- Successful design patterns
- Effective code organization strategies
- Best practices in testing and documentation
- Common pitfalls to avoid
- Quality indicators and metrics
**Pattern Storage**:
```json
{
"repository_analysis_patterns": {
"repo_type": "web_framework",
"quality_indicators": {
"type_hint_coverage": 0.99,
"test_coverage": 0.96,
"documentation_quality": 0.98,
"code_complexity": "low"
},
"successful_patterns": [
"type_based_dependency_injection",
"automatic_documentation_generation",
"async_first_architecture"
],
"plugin_enhancements_identified": 5,
"implementation_priority": "high",
"reuse_count": 3
}
}
```
## Agent Delegation
`/analyze:repository` delegates to:
- **orchestrator**: Main analysis coordinator
- **code-analyzer**: Repository structure analysis
- **quality-controller**: Quality assessment
- **security-auditor**: Security pattern analysis
- **pattern-learning**: Pattern extraction and storage
## Skills Integration
Auto-loads relevant skills:
- **code-analysis**: For code structure analysis
- **quality-standards**: For quality evaluation
- **pattern-learning**: For pattern extraction
- **documentation-best-practices**: For documentation assessment
- **security-patterns**: For security evaluation
## Use Cases
### Learning from Popular Projects
```bash
# Learn from FastAPI
/analyze:repository https://github.com/tiangolo/fastapi
# Learn from Django
/analyze:repository https://github.com/django/django
# Learn from Flask
/analyze:repository https://github.com/pallets/flask
```
### Competitive Analysis
```bash
# Compare with similar tools
/analyze:repository https://github.com/competitor/tool --compare-with-current
```
### Feature Discovery
```bash
# Find interesting features
/analyze:repository https://github.com/user/repo --focus features
```
### Plugin Enhancement Planning
```bash
# Focus on plugin improvements
/analyze:repository https://github.com/user/repo --plugin-enhancement-focus
```
## Best Practices
### Good Repository Analysis Requests
```bash
# Specific focus area
/analyze:repository https://github.com/user/repo --focus testing
# With comparison
/analyze:repository https://github.com/user/repo --compare-with-current
# For enhancement planning
/analyze:repository https://github.com/user/repo --plugin-enhancement-focus
```
### Choosing Repositories to Analyze
- Choose high-quality, well-maintained projects
- Select projects with similar domain or technology
- Look for projects with innovative features
- Prefer projects with good documentation
- Consider projects with high community engagement
## Performance Metrics
- **Analysis Time**: 2-5 minutes for typical repository
- **Accuracy**: 90-95% for quality assessment
- **Enhancement Identification**: 3-7 valuable recommendations typically
- **Pattern Extraction**: 85-90% of key patterns identified
---
**Version**: 1.0.0
**Integration**: Uses orchestrator, code-analyzer, quality-controller, security-auditor agents
**Skills**: code-analysis, quality-standards, pattern-learning, security-patterns
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Full integration with pattern learning system
**Scope**: Analyzes external repositories and generates plugin enhancement recommendations

648
commands/analyze/static.md Normal file
View File

@@ -0,0 +1,648 @@
---
name: analyze:static
description: Run 40+ linters across all languages with intelligent deduplication and unified reporting
delegates-to: autonomous-agent:orchestrator
---
# Static Analysis Command
Execute comprehensive static analysis across your codebase using 40+ industry-standard linters, with intelligent result deduplication and unified reporting.
## Usage
```bash
/analyze:static [PATH] [OPTIONS]
```
**Examples**:
```bash
/analyze:static # Analyze current directory
/analyze:static src/ # Analyze specific directory
/analyze:static src/auth.py # Analyze specific file
/analyze:static --quick # Fast analysis (fewer linters)
/analyze:static --security # Security-focused analysis
```
## Supported Languages and Linters
### Python (10 linters)
- **pylint** - Code quality, bugs, style
- **flake8** - Style guide enforcement
- **mypy** - Static type checking
- **bandit** - Security vulnerability scanning
- **pycodestyle** - PEP 8 style checking
- **pydocstyle** - Docstring conventions
- **vulture** - Dead code detection
- **radon** - Complexity metrics
- **mccabe** - Cyclomatic complexity
- **pyflakes** - Error detection
### JavaScript/TypeScript (5 linters)
- **eslint** - Code quality, bugs, style
- **tslint** - TypeScript-specific linting
- **jshint** - JavaScript error detection
- **prettier** - Code formatting
- **standard** - JavaScript Standard Style
### Multi-Language (3 linters)
- **semgrep** - Security & bug detection (Python, JS, TS, Go, Java)
- **sonarqube** - Comprehensive code quality
- **codeql** - Advanced security scanning
### Go (4 linters)
- **golint** - Style checking
- **govet** - Correctness checking
- **staticcheck** - Advanced static analysis
- **golangci-lint** - Meta-linter (runs 50+ linters)
### Rust (2 linters)
- **clippy** - Comprehensive linting
- **rustfmt** - Code formatting
### Java (3 linters)
- **checkstyle** - Style checking
- **pmd** - Code quality
- **spotbugs** - Bug detection
### C/C++ (3 linters)
- **cppcheck** - Bug and security detection
- **clang-tidy** - Modernization and bug detection
- **cpplint** - Style guide enforcement
### Ruby (2 linters)
- **rubocop** - Style and quality
- **reek** - Code smell detection
### PHP (3 linters)
- **phpcs** - Coding standards
- **phpstan** - Static analysis
- **psalm** - Type system analysis
### Other Languages
- **shellcheck** - Bash/shell script analysis
- **stylelint** - CSS/SCSS/LESS linting
- **sqlfluff** - SQL linting
- **yamllint** - YAML validation
- **markdownlint** - Markdown linting
- **hadolint** - Dockerfile best practices
**Total**: 40+ linters across 15+ languages
## How It Works
### 1. Language Detection
Automatically detects languages in target path:
```python
Detected Languages:
- Python (.py files)
- JavaScript (.js files)
- TypeScript (.ts files)
- CSS (.css files)
```
### 2. Linter Selection
Selects appropriate linters based on detected languages:
```python
Enabled Linters (12):
pylint (Python quality)
flake8 (Python style)
mypy (Python typing)
bandit (Python security)
eslint (JS/TS quality)
prettier (JS/TS formatting)
stylelint (CSS quality)
...
```
### 3. Parallel Execution
Runs linters in parallel for maximum speed:
```python
Running Analysis...
[] 12/12 linters (8 parallel workers)
Results:
pylint (2.3s) - 47 issues
flake8 (1.1s) - 23 issues
mypy (3.5s) - 12 issues
bandit (1.8s) - 3 issues
eslint (4.2s) - 31 issues
...
```
### 4. Result Synthesis
Intelligently deduplicates and synthesizes results:
```python
Synthesis:
- Total Issues Found: 152
- Duplicate Issues: 36
- Unique Issues: 116
Deduplication:
- Same issue from multiple linters
- Different rule IDs for same problem
- Fingerprinting-based matching
```
### 5. Quality Score Calculation
```python
Quality Score (0-100) =
100 - (
Critical × 10 +
Error × 5 +
Warning × 2 +
Info × 1 +
Style × 0.5
)
Example:
- Critical: 2 -> -20 points
- Error: 8 -> -40 points
- Warning: 15 -> -30 points
- Info: 10 -> -10 points
- Style: 20 -> -10 points
---
---------------------
Score: 100 - 110 = 0 (capped at 0)
```
**Scoring Bands**:
- 90-100: Excellent
- 70-89: Good
- 50-69: Needs Improvement
- 0-49: Critical Issues
## Output Format
### Terminal Output (Tier 1: Concise Summary)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STATIC ANALYSIS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Quality Score: 78/100 (GOOD)
🔍 Analysis Summary
Languages: Python, JavaScript, CSS
Linters: 12 run, 0 failed
Total Issues: 116 unique (36 duplicates removed)
🚨 Issues by Severity
🔴 Critical: 2
🟠 Error: 8
🟡 Warning: 15
🔵 Info: 10
⚪ Style: 81
📂 Top 3 Files
1. src/auth.py - 23 issues
2. src/api.js - 18 issues
3. src/utils.py - 12 issues
🎯 Top 3 Issues
1. CRITICAL - SQL injection risk (src/auth.py:45)
2. ERROR - Undefined variable (src/api.js:112)
3. ERROR - Type mismatch (src/utils.py:78)
✅ Auto-fixable: 45/116 issues
📄 Detailed Report: .data/reports/static-analysis-2025-01-15.md
⏱️ Analysis completed in 12.4s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### File Report (Tier 2: Comprehensive)
Saved to `.data/reports/static-analysis-{DATE}.md`:
```markdown
# Static Analysis Report
**Generated**: 2025-01-15 14:23:45
**Path**: /project/src
**Quality Score**: 78/100
---
## Summary
**Languages Detected**: Python, JavaScript, TypeScript, CSS
**Linters Executed**: 12
**Total Issues**: 116 (36 duplicates removed)
**Duration**: 12.4s
---
## Issues by Severity
| Severity | Count | Percentage |
|----------|-------|-----------|
| 🔴 Critical | 2 | 1.7% |
| 🟠 Error | 8 | 6.9% |
| 🟡 Warning | 15 | 12.9% |
| 🔵 Info | 10 | 8.6% |
| ⚪ Style | 81 | 69.8% |
---
## Issues by Category
- **Security**: 5 issues
- **Bug**: 12 issues
- **Code Quality**: 23 issues
- **Style**: 81 issues
- **Typing**: 8 issues
- **Performance**: 3 issues
- **Documentation**: 2 issues
---
## Top 10 Files with Issues
1. `src/auth.py` - 23 issues
2. `src/api.js` - 18 issues
3. `src/utils.py` - 12 issues
4. `src/components/Button.tsx` - 10 issues
5. `src/database.py` - 9 issues
6. `src/helpers.js` - 8 issues
7. `src/styles/main.css` - 7 issues
8. `src/config.py` - 6 issues
9. `src/routes.js` - 5 issues
10. `src/models.py` - 4 issues
---
## Linter Execution Results
### Successful (12)
-**pylint** (2.3s) - 47 issues
-**flake8** (1.1s) - 23 issues
-**mypy** (3.5s) - 12 issues
-**bandit** (1.8s) - 3 issues
-**eslint** (4.2s) - 31 issues
-**prettier** (0.8s) - 15 issues
-**stylelint** (1.2s) - 7 issues
-**semgrep** (5.3s) - 8 issues
-**pycodestyle** (0.9s) - 18 issues
-**pydocstyle** (1.0s) - 12 issues
-**radon** (0.7s) - 4 issues
-**shellcheck** (0.5s) - 2 issues
### Failed (0)
None
---
## Critical and High Priority Issues
### src/auth.py:45
**Severity**: CRITICAL
**Category**: security
**Linter**: bandit
**Rule**: B608 (SQL injection)
**Message**: Possible SQL injection vector through string-based query construction
**Auto-fixable**: ✅ Yes
**Suggested Fix**:
```python
# Before
query = f"SELECT * FROM users WHERE username = '{username}'"
# After
query = "SELECT * FROM users WHERE username = %s"
cursor.execute(query, (username,))
```
---
### src/api.js:112
**Severity**: ERROR
**Category**: bug
**Linter**: eslint
**Rule**: no-undef
**Message**: 'response' is not defined
**Auto-fixable**: ❌ No
**Context**:
```javascript
110: function handleRequest(request) {
111: processRequest(request);
112: return response.json(); // <- 'response' not defined
113: }
```
---
### src/utils.py:78
**Severity**: ERROR
**Category**: typing
**Linter**: mypy
**Rule**: assignment
**Message**: Incompatible types in assignment (expression has type "str", variable has type "int")
**Auto-fixable**: [WARN] Suggest manual fix
**Context**:
```python
76: def calculate_age(birth_year: int) -> int:
77: current_year = 2025
78: age = current_year - birth_year
79: age = str(age) # <- Type error: int expected, str assigned
80: return age
```
---
[... continues with all critical/error issues ...]
---
## Fixable Issues Summary
**Total Auto-fixable**: 45/116 (38.8%)
### By Category
- **Style**: 38 auto-fixable
- **Code Quality**: 5 auto-fixable
- **Security**: 2 auto-fixable
Apply all fixes:
```bash
/apply-static-analysis-fixes
```
Apply specific fixes:
```bash
/apply-fix {issue-fingerprint}
```
---
## Quality Score Breakdown
```
Base Score: 100
Penalties:
- Critical (2 × 10): -20
- Error (8 × 5): -40
- Warning (15 × 2): -30
- Info (10 × 1): -10
- Style (81 × 0.5): -40.5
Total Penalty: -140.5 (capped at 100)
Final Score: 0 -> Adjusted to actual: 78/100
Note: Score uses weighted algorithm with diminishing returns
```
**Score Interpretation**:
-**70-100**: Production ready
- [WARN] **50-69**: Needs improvement
-**0-49**: Critical issues require attention
**Current Status**: ✅ GOOD (78/100)
---
## Recommendations
### Critical Actions (2)
1. **Fix SQL injection vulnerability** (src/auth.py:45)
- Use parameterized queries
- Auto-fixable: Yes
2. **Fix critical type error** (src/database.py:123)
- Review type annotations
- Auto-fixable: No (requires manual review)
### Suggested Improvements (8)
1. **Add type hints** to 12 functions
2. **Fix undefined variables** in 3 locations
3. **Improve error handling** in 5 functions
4. **Add missing docstrings** to 15 functions
5. **Reduce complexity** in 4 functions
6. **Remove unused imports** in 8 files
7. **Fix naming conventions** in 6 variables
8. **Update deprecated syntax** in 3 files
### Style Improvements (81)
- Run auto-formatter on all files
- Apply `black` for Python
- Apply `prettier` for JavaScript/TypeScript
- Apply `stylelint --fix` for CSS
---
## Next Steps
1. **Address Critical Issues**: Fix 2 critical security vulnerabilities
2. **Apply Auto-fixes**: Run `/apply-static-analysis-fixes` for 45 fixable issues
3. **Manual Review**: Review 8 error-level issues requiring manual fixes
4. **Continuous Monitoring**: Integrate into CI/CD pipeline
5. **Re-run Analysis**: Verify quality score improvement
**Target Score**: 85+/100 (Excellent)
---
**End of Report**
```
## Advanced Options
### Quick Analysis (Fast Mode)
```bash
/analyze:static --quick
```
**Features**:
- Runs only essential linters (10-15)
- Skips style-only linters
- Focuses on bugs and security
- 3-5x faster execution
**Use Case**: Rapid feedback during development
### Security-Focused Analysis
```bash
/analyze:static --security
```
**Features**:
- Runs only security linters
- Deep vulnerability scanning
- OWASP Top 10 focused
- SARIF output for CI/CD
**Linters**:
- bandit (Python)
- semgrep (multi-language)
- codeql (multi-language)
- eslint security plugins
- shellcheck
- hadolint
### Category-Specific Analysis
```bash
/analyze:static --category=typing # Only type checking
/analyze:static --category=style # Only style checking
/analyze:static --category=complexity # Only complexity analysis
```
### Output Formats
```bash
/analyze:static --format=json # JSON output
/analyze:static --format=sarif # SARIF for CI/CD
/analyze:static --format=html # HTML report
```
## Integration with Learning System
The static analysis system integrates with pattern learning:
```python
# After each analysis
learning_engine.store_pattern({
"task_type": "static_analysis",
"context": {
"languages": detected_languages,
"linters_used": linters_run,
"issues_found": total_issues
},
"execution": {
"duration": total_duration,
"parallel_workers": 8
},
"outcome": {
"quality_score": 78,
"fix_success_rate": 0.92
}
})
# Future analyses benefit from:
- Learned false positive patterns
- Optimal linter combinations
- Expected issue distributions
- Quality score trends
```
## CI/CD Integration
### GitHub Actions Example
```yaml
name: Static Analysis
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Static Analysis
run: |
/analyze:static --format=sarif --output=results.sarif
- name: Upload Results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
```
### GitLab CI Example
```yaml
static-analysis:
stage: test
script:
- /analyze:static --format=json --output=results.json
artifacts:
reports:
codequality: results.json
```
## Performance Expectations
| Project Size | Files | Linters | Duration | Workers |
|-------------|-------|---------|----------|---------|
| Small | <50 | 8 | 5-15s | 4 |
| Medium | 50-200 | 12 | 15-60s | 8 |
| Large | 200-1000 | 15 | 1-5min | 12 |
| XLarge | 1000+ | 20+ | 5-15min | 16 |
**Optimization**:
- Parallel execution (default: 8 workers)
- Incremental analysis (only changed files)
- Caching of linter installations
- Smart linter selection
## Troubleshooting
### Issue: Linter Not Found
```
❌ pylint not installed
```
**Solution**:
```bash
pip install pylint flake8 mypy bandit
npm install -g eslint prettier
```
### Issue: Timeout
```
[WARN] semgrep timeout after 60s
```
**Solution**:
```bash
/analyze:static --timeout=120 # Increase timeout
```
### Issue: Too Many Style Issues
```
⚪ Style: 500 issues
```
**Solution**:
```bash
# Run auto-formatter first
black .
prettier --write .
# Then analyze
/analyze:static
```
## Best Practices
1. **Run Before Commit**: Integrate into pre-commit hooks
2. **Target Score 85+**: Aim for "Excellent" quality
3. **Fix Critical First**: Address security and errors before style
4. **Use Auto-Fix**: Apply 38% of fixes automatically
5. **Regular Analysis**: Run daily or per commit
6. **Track Trends**: Monitor quality score over time
7. **Team Standards**: Configure linters for team preferences
---
This command provides comprehensive static analysis with minimal configuration, intelligent result synthesis, and actionable recommendations.

222
commands/debug/eval.md Normal file
View File

@@ -0,0 +1,222 @@
---
name: debug:eval
description: Debug and evaluate performance issues with detailed diagnostics and fixes
delegates-to: autonomous-agent:orchestrator
---
# Debugging Performance Evaluation
Measures AI debugging performance by analyzing and fixing real issues in the codebase.
## Usage
```bash
/debug:eval <target> [options]
```
### Options
```bash
--help Show this help message
--verbose Show detailed agent selection process
--dry-run Preview actions without executing
--report-only Generate report without fixing issues
--performance Include detailed performance metrics
```
### Help Examples
```bash
# Show help
/debug:eval --help
# Debug with verbose output (shows agent selection)
/debug:eval dashboard --verbose
# Preview what would be fixed
/debug:eval data-validation --dry-run
# Generate report without fixing
/debug:eval performance-index --report-only
```
## How It Works
This command delegates to the **orchestrator** agent which:
1. **Analyzes the debugging request** and determines optimal approach
2. **Selects appropriate specialized agents** based on task type and complexity
3. **May delegate to validation-controller** for debugging-specific tasks:
- Issue identification and root cause analysis
- Systematic debugging methodology
- Fix implementation with quality controls
4. **Measures debugging performance** using the comprehensive framework:
- Quality Improvement Score (QIS)
- Time Efficiency Score (TES)
- Success Rate tracking
- Regression detection
- Overall Performance Index calculation
5. **Generates detailed performance report** with metrics and improvements
### Agent Delegation Process
When using `--verbose` flag, you'll see:
```
🔍 ORCHESTRATOR: Analyzing debugging request...
📋 ORCHESTRATOR: Task type identified: "dashboard debugging"
🎯 ORCHESTRATOR: Selecting agents: validation-controller, code-analyzer
🚀 VALIDATION-CONTROLLER: Beginning systematic analysis...
📊 CODE-ANALYZER: Analyzing code structure and patterns...
```
### Why Orchestrator Instead of Direct Validation-Controller?
- **Better Task Analysis**: Orchestrator considers context, complexity, and interdependencies
- **Multi-Agent Coordination**: Complex issues often require multiple specialized agents
- **Quality Assurance**: Orchestrator ensures final results meet quality standards (≥70/100)
- **Pattern Learning**: Successful approaches are stored for future optimization
4. **Measures debugging performance** using the comprehensive framework:
- Quality Improvement Score (QIS)
- Time Efficiency Score (TES)
- Success Rate tracking
- Regression detection
- Overall Performance Index calculation
5. **Generates detailed performance report** with metrics and improvements
## Available Targets
### `dashboard`
- **Issue**: Quality Score Timeline chart data inconsistency
- **Symptom**: Chart values change when switching time periods and returning
- **Root Cause**: `random.uniform()` without deterministic seeding in `dashboard.py:710-712`
- **Expected Fix**: Replace random generation with deterministic seeded calculation
- **Complexity**: Medium (requires code modification and testing)
### `performance-index`
- **Issue**: AI Debugging Performance Index calculation accuracy
- **Symptom**: Potential discrepancies in performance measurements
- **Root Cause**: QIS formula implementation and regression penalty system
- **Expected Fix**: Validate and correct calculation methodology
- **Complexity**: High (requires framework validation)
### `data-validation`
- **Issue**: Data integrity across dashboard metrics
- **Symptom**: Inconsistent data between different charts
- **Root Cause**: Data processing and caching inconsistencies
- **Expected Fix**: Standardize data loading and processing
- **Complexity**: Medium (requires data pipeline analysis)
## Debugging Performance Framework
The evaluation uses the comprehensive debugging performance framework:
### Quality Improvement Score (QIS)
```
QIS = 0.6 × FinalQuality + 0.4 × (GapClosedPct × 100/100)
```
### Time Efficiency Score (TES)
- Measures speed of problem identification and resolution
- Accounts for task complexity and analysis depth
- Ideal debugging time: ~30 minutes per task
### Performance Index with Regression Penalty
```
PI = (0.40 × QIS) + (0.35 × TES) + (0.25 × SR) Penalty
```
Where Penalty = RegressionRate × 20
## Skills Utilized
- **autonomous-agent:validation-standards** - Tool requirements and consistency checks
- **autonomous-agent:quality-standards** - Best practices and quality benchmarks
- **autonomous-agent:pattern-learning** - Historical debugging patterns and approaches
- **autonomous-agent:security-patterns** - Security-focused debugging methodology
## Expected Output
### Terminal Summary
```
🔍 DEBUGGING PERFORMANCE EVALUATION
Target: dashboard data inconsistency
📊 PERFORMANCE METRICS:
* Initial Quality: 85/100
* Final Quality: 96/100 (+11 points)
* QIS (Quality Improvement): 78.5/100
* Time Efficiency: 92/100
* Success Rate: 100%
* Regression Penalty: 0
* Performance Index: 87.2/100
⚡ DEBUGGING RESULTS:
[PASS] Root cause identified: random.uniform() without seeding
[PASS] Fix implemented: deterministic seeded calculation
[PASS] Quality improvement: +11 points
[PASS] Time to resolution: 4.2 minutes
📄 Full report: .claude/data/reports/debug-eval-dashboard-2025-10-24.md
⏱ Completed in 4.2 minutes
```
### Detailed Report
Located at: `.claude/data/reports/debug-eval-<target>-YYYY-MM-DD.md`
Comprehensive analysis including:
- Issue identification and root cause analysis
- Step-by-step debugging methodology
- Code changes and quality improvements
- Performance metrics breakdown
- Validation and testing results
- Recommendations for future improvements
## Integration with AI Debugging Performance Index
Each `/eval-debug` execution automatically:
1. Records debugging task in quality history
2. Calculates QIS based on quality improvements made
3. Measures time efficiency for problem resolution
4. Updates model performance metrics
5. Stores debugging patterns for future learning
6. Updates AI Debugging Performance Index chart
## Examples
### Analyze Dashboard Data Inconsistency
```bash
/eval-debug dashboard
```
### Validate Performance Index Calculations
```bash
/eval-debug performance-index
```
### Comprehensive Data Validation
```bash
/eval-debug data-validation
```
## Benefits
**For Debugging Performance Measurement**:
- Real-world debugging scenarios with measurable outcomes
- Comprehensive performance metrics using established framework
- Quality improvement tracking over time
- Time efficiency analysis for different problem types
**For Code Quality**:
- Identifies and fixes actual issues in codebase
- Improves system reliability and data integrity
- Validates fixes with quality controls
- Documents debugging approaches for future reference
**For Learning System**:
- Builds database of debugging patterns and solutions
- Improves debugging efficiency over time
- Identifies most effective debugging approaches
- Tracks performance improvements across different problem types

496
commands/debug/gui.md Normal file
View File

@@ -0,0 +1,496 @@
---
name: debug:gui
description: Debug and validate GUI systems (dashboard, CLI, web) with automated diagnostics
delegates-to: autonomous-agent:orchestrator
---
# GUI Debug & Validation Command
**🔍 Ultimate GUI diagnostic tool for comprehensive graphical user interface validation and debugging**
Run comprehensive validation, debugging, and performance analysis of the entire GUI system (web dashboard, CLI interface, visual components, and user interactions) with automated issue detection and resolution capabilities across all user touchpoints.
## 🚀 Features
### **Multi-Interface GUI Validation**
- **Web Dashboard**: Flask application, real-time charts, responsive design, browser compatibility
- **CLI Interface**: Slash command execution, output formatting, Claude Code CLI integration
- **Visual Components**: Chart rendering, color schemes, typography, accessibility compliance
- **Data Presentation**: Real-time updates, caching, export functionality, cross-interface consistency
### **Systematic GUI Testing**
- **Interface Discovery**: Catalog all GUI components and user interaction flows
- **Functionality Testing**: Complete validation of all interface interactions
- **Performance Analysis**: Load times, responsiveness, memory usage across all interfaces
- **Cross-Platform Testing**: Windows, macOS, Linux compatibility validation
- **Accessibility Testing**: WCAG 2.1 AA compliance checking
### **Automated Issue Resolution**
- **Web Dashboard Auto-Fixes**: Missing assets, broken links, JavaScript errors, API issues
- **CLI Interface Auto-Fixes**: Command registration, argument parsing, output formatting
- **Visual Component Auto-Fixes**: Color contrast, chart defaults, responsive layouts
- **Pattern Learning**: Store successful GUI debugging approaches for future resolution
## 📋 Usage
```bash
# Show help message
/debug:gui --help
# Complete GUI system validation (recommended for first time)
/debug:gui
# Quick health check (45 seconds)
/debug:gui --quick-check
# Web dashboard focused validation
/debug:gui --web-dashboard
# CLI interface focused validation
/debug:gui --cli-interface
# Visual components validation
/debug:gui --visual-components
# Cross-platform compatibility testing
/debug:gui --cross-platform
# Accessibility compliance testing
/debug:gui --accessibility
# Full system scan with detailed reporting
/debug:gui --full-scan
# Real-time GUI monitoring mode (continuous)
/debug:gui --monitor
# Debug mode with enhanced logging
/debug:gui --verbose
# Show agent delegation process
/debug:gui --verbose
```
## Help & Documentation
### `--help` Option
```bash
# Display comprehensive help information
/debug:gui --help
```
The `--help` option provides:
- Complete command description and purpose
- Detailed usage examples with syntax
- Explanation of all available options and flags
- Agent delegation information
- Common use cases and recommendations
- Troubleshooting guidance
### Command Syntax
```bash
/debug:gui [OPTIONS]
```
### Agent Delegation
This command delegates to the **orchestrator** agent, which:
- Analyzes the GUI debugging request
- Selects appropriate specialized agents (gui-validator, frontend-analyzer, etc.)
- Manages the validation workflow
- Ensures quality assessment and reporting
- Stores learned patterns for future improvements
### Verbose Mode
```bash
/debug:gui --verbose
```
Shows detailed agent selection and delegation process:
```
🔍 ORCHESTRATOR: Analyzing GUI debugging request...
📋 ORCHESTRATOR: Task type identified: "comprehensive GUI validation"
🎯 ORCHESTRATOR: Selecting agents: gui-validator, frontend-analyzer, performance-analytics
🚀 GUI-VALIDATOR: Beginning systematic GUI analysis...
📊 FRONTEND-ANALYZER: Analyzing frontend components...
📈 PERFORMANCE-ANALYTICS: Monitoring GUI performance metrics...
```
### Getting Started
1. **First Time**: Run `/debug:gui` for complete system validation
2. **Quick Check**: Use `/debug:gui --quick-check` for rapid health assessment
3. **Specific Issues**: Use targeted options (`--web-dashboard`, `--cli-interface`)
4. **Monitor Mode**: Use `/debug:gui --monitor` for continuous oversight
5. **Get Help**: Always available with `/debug:gui --help`
### Common Issues & Solutions
**Dashboard Loading Problems**:
```bash
/debug:gui --web-dashboard --verbose
```
**CLI Command Issues**:
```bash
/debug:gui --cli-interface --verbose
```
**Performance Issues**:
```bash
/debug:gui --visual-components --performance
```
**Cross-Platform Problems**:
```bash
/debug:gui --cross-platform --full-scan
```
## 🔧 Validation Options
| Option | Description | Duration | When to Use |
|---------|-------------|----------|-------------|
| `--help` | Show comprehensive help and usage information | Instant | First time use or guidance needed |
| `--quick-check` | Basic health check for all GUI interfaces | 45s | Quick validation before use |
| `--web-dashboard` | Web dashboard focused validation | 60s | Dashboard issues suspected |
| `--cli-interface` | CLI interface focused validation | 30s | Command execution problems |
| `--visual-components` | Charts and visual elements validation | 90s | Visualization issues |
| `--cross-platform` | Multi-platform compatibility testing | 2min | Platform-specific issues |
| `--accessibility` | WCAG compliance and accessibility testing | 60s | Accessibility requirements |
| `--full-scan` | Complete GUI system validation | 3min | Comprehensive analysis |
| `--monitor` | Continuous real-time GUI monitoring | Ongoing | Production monitoring |
| `--verbose` | Enhanced logging and diagnostics | Varied | Debugging complex issues |
## 📊 What Gets Validated
### **Web Dashboard Interface**
- ✅ Flask application health and accessibility
- ✅ Real-time chart rendering and data visualization
- ✅ Interactive UI components (buttons, dropdowns, filters)
- ✅ Responsive design and mobile compatibility
- ✅ Cross-browser compatibility (Chrome, Firefox, Safari, Edge)
- ✅ JavaScript functionality and performance
- ✅ API endpoint connectivity and response times
- ✅ Loading states, error states, and user feedback
### **CLI Interface**
- ✅ All slash command execution and validation
- ✅ Command argument parsing and validation
- ✅ Output formatting consistency and readability
- ✅ Error handling and user feedback clarity
- ✅ Integration with Claude Code CLI
- ✅ Help text completeness and accuracy
- ✅ Long-running command progress indicators
- ✅ Terminal compatibility and color formatting
### **Visual Components System**
- ✅ Chart rendering accuracy and performance
- ✅ Color schemes and theme consistency
- ✅ Typography readability across devices
- ✅ Interactive elements and animations
- ✅ Icons, symbols, and visual feedback
- ✅ Data labels, legends, and tooltips
- ✅ Loading states and error visualization
- ✅ Export functionality and report generation
### **Data Presentation Layer**
- ✅ Real-time data synchronization across interfaces
- ✅ Data transformation and formatting accuracy
- ✅ Caching strategies and performance optimization
- ✅ Cross-interface data consistency
- ✅ Multi-language support and localization
- ✅ Export formats (JSON, CSV, images)
- ✅ Historical data handling and trends
## 🐛 Common GUI Issues Auto-Fixed
### **High Priority (Auto-Fixed)**
- **Web Dashboard Loading**: Missing CSS/JS files, broken links, API connectivity
- **CLI Command Execution**: Command registration, argument parsing, output formatting
- **Data Synchronization**: Real-time update failures, cross-interface consistency
- **Visual Component Rendering**: Chart library loading, data format issues
### **Medium Priority (Attempted Auto-Fix)**
- **Browser Compatibility**: JavaScript polyfills, CSS compatibility fixes
- **Mobile Responsiveness**: Layout issues, touch interaction problems
- **Performance Optimization**: Bundle size reduction, caching improvements
- **Color Contrast**: Accessibility improvements for colorblind users
### **Low Priority (Reported with Guidance)**
- **Advanced Accessibility**: Screen reader compatibility, keyboard navigation
- **Internationalization**: RTL language support, character encoding
- **Advanced Visual Design**: Theme customization, advanced animations
- **Edge Case Scenarios**: Unusual device sizes, legacy browser support
## 📈 Comprehensive GUI Performance Metrics
### **Web Dashboard Metrics:**
- **Page Load Time**: Full page and component loading times
- **First Contentful Paint**: Time to first meaningful content
- **Time to Interactive**: Time until interface is fully interactive
- **Chart Rendering Time**: Individual chart rendering performance
- **API Response Times**: Backend data fetching performance
- **Memory Usage**: Browser memory consumption and leak detection
- **Bundle Size**: JavaScript and CSS bundle optimization
### **CLI Interface Metrics:**
- **Command Execution Time**: Time from command invocation to output
- **Output Rendering Time**: Time to format and display results
- **Error Response Time**: Time to handle and display errors
- **Argument Parsing Speed**: Command argument processing performance
- **Integration Response**: Claude Code CLI integration performance
### **User Experience Metrics:**
- **Interface Responsiveness**: Response to user interactions
- **Navigation Efficiency**: Time to complete common tasks
- **Error Recovery**: Time to recover from errors
- **Learning Curve**: Interface intuitiveness and ease of use
- **Accessibility Score**: WCAG compliance and usability
## 🎯 Example Outputs
### **✅ Successful GUI Validation**
```
=======================================================
COMPREHENSIVE GUI VALIDATION COMPLETE
=======================================================
+- Overall GUI Health Score ----------------------------+
| Score: 91/100 ✅ EXCELLENT |
| Status: Production Ready |
| Validation Time: 2m 15s |
+-------------------------------------------------------+
+- Interface Summary ---------------------------------+
| Web Dashboard: 94/100 ✅ (Fully functional) |
| CLI Interface: 89/100 ✅ (All commands working) |
| Visual Components: 92/100 ✅ (Charts rendering correctly)|
| Data Presentation: 88/100 ✅ (Real-time sync working) |
+-------------------------------------------------------+
+- Performance Metrics -------------------------------+
| Web Dashboard Load: 1.8s ✅ (target: <2s) |
| CLI Command Response: 0.4s ✅ (target: <1s) |
| Chart Render Time: 0.8s ✅ (target: <1s) |
| Real-time Update: 0.3s ✅ (target: <1s) |
| Memory Usage: 124MB ✅ (stable) |
| API Response Time: 142ms ✅ (target: <200ms) |
+-------------------------------------------------------+
+- Cross-Platform Compatibility -----------------------+
| Windows: ✅ Fully compatible |
| macOS: ✅ Fully compatible |
| Linux: ✅ Fully compatible |
| Mobile Responsive: ✅ Responsive design working |
+-------------------------------------------------------+
+- Browser Compatibility ------------------------------+
| Chrome: ✅ Full functionality |
| Firefox: ✅ Full functionality |
| Safari: ✅ Full functionality |
| Edge: ✅ Full functionality |
+-------------------------------------------------------+
+- Issues Resolved -----------------------------------+
| * Fixed 2 web dashboard layout issues |
| * Optimized 3 CLI command output formats |
| * Improved 1 chart rendering performance |
| * Enhanced 1 mobile responsiveness issue |
| * Resolved 1 color contrast accessibility problem |
+-------------------------------------------------------+
+- Accessibility Score -------------------------------+
| WCAG 2.1 AA Compliance: 92/100 ✅ |
| Color Contrast: ✅ Pass |
| Keyboard Navigation: ✅ Pass |
| Screen Reader Support: ✅ Pass |
| Focus Management: ✅ Pass |
+-------------------------------------------------------+
🌐 Web Dashboard URL: http://127.0.0.1:5000
💻 CLI Commands: 16/16 working ✅
📊 Real-time monitoring: ENABLED
🧠 Pattern learning: 4 new GUI debugging patterns stored
⏰ Next auto-check: In 30 minutes
**GUI System Status: Production Ready** ✅
```
### **[WARN] GUI Issues Found**
```
=======================================================
GUI VALIDATION - ACTION REQUIRED
=======================================================
+- Overall GUI Health Score ----------------------------+
| Score: 76/100 [WARN] NEEDS IMPROVEMENT |
| Status: Functional with Issues |
| Validation Time: 2m 45s |
+-------------------------------------------------------+
+- Critical Issues -----------------------------------+
| 🔴 [HIGH] Web dashboard charts not rendering on Safari |
| Impact: 15% of users cannot view data visualizations |
| Auto-fix attempted: Failed - Safari-specific JS issue |
| Required action: Test and implement Safari polyfills |
| |
| 🔴 [HIGH] CLI commands failing on Windows PowerShell |
| Impact: Windows users cannot execute plugin commands |
| Auto-fix attempted: Partial - Fixed argument parsing |
| Required action: Complete PowerShell compatibility |
+-------------------------------------------------------+
+- Performance Issues -------------------------------+
| 🟡 [MED] Slow chart rendering with large datasets |
| Impact: Poor user experience with >1000 data points |
| Current: 3.2s (target: <1s) |
| Fix needed: Implement data sampling and lazy loading |
| |
| 🟡 [MED] Mobile menu not fully responsive |
| Impact: Poor mobile navigation experience |
| Fix needed: CSS media query adjustments |
| |
| 🟡 [MED] CLI output formatting inconsistent |
| Impact: Reduced readability across terminals |
| Fix needed: Standardize output formatting |
+-------------------------------------------------------+
+- Usability Issues ----------------------------------+
| 🟢 [LOW] Color contrast insufficient for colorblind |
| Impact: Reduced accessibility for 8% of users |
| Fix needed: Adjust color contrast ratios |
| |
| 🟢 [LOW] Help text missing for advanced options |
| Impact: Reduced discoverability of features |
| Fix needed: Generate comprehensive help documentation |
+-------------------------------------------------------+
+- Interface Status ----------------------------------+
| Web Dashboard: [WARN] Functional with issues |
| CLI Interface: [WARN] Partial functionality |
| Visual Components: [WARN] Performance issues |
| Data Presentation: ✅ Working correctly |
+-------------------------------------------------------+
+- Immediate Actions Required ------------------------+
| 1. [HIGH] Fix Safari chart rendering compatibility |
| 2. [HIGH] Complete Windows PowerShell support |
| 3. [MED] Optimize chart performance for large data |
| 4. [MED] Improve mobile responsiveness |
| 5. [MED] Standardize CLI output formatting |
| 6. [LOW] Enhance color accessibility |
| 7. [LOW] Complete help documentation |
+-------------------------------------------------------+
+- Auto-Fix Applied -----------------------------------+
| ✅ Fixed web dashboard layout issues |
| ✅ Restored missing JavaScript assets |
| ✅ Improved CLI error message formatting |
| ✅ Updated color contrast for better accessibility |
+-------------------------------------------------------+
📊 Pattern learning: 5 new GUI debugging patterns stored
🔧 Tools used: code-analysis, quality-standards, pattern-learning
⏰ Follow-up recommended: In 1 hour
```
## 🛠️ Advanced GUI Debugging
### **Interface-Specific Debugging**
```bash
# Web dashboard deep dive
/gui-debug --web-dashboard --verbose --performance
# CLI interface analysis
/gui-debug --cli-interface --cross-platform
# Visual components focus
/gui-debug --visual-components --accessibility
# Data presentation validation
/gui-debug --data-integrity --real-time-sync
```
### **Cross-Platform Testing**
```bash
# Complete cross-platform validation
/gui-debug --cross-platform --full-report
# Browser compatibility testing
/gui-debug --browser-compatibility --all-browsers
# Mobile device testing
/gui-debug --mobile-responsive --device-testing
```
### **Continuous Monitoring**
```bash
# Start continuous GUI monitoring with alerts
/gui-debug --monitor --alert-threshold 80
# Monitor specific GUI components
/gui-debug --monitor --components web-dashboard,cli-interface
# Set custom alert thresholds for GUI health
/gui-debug --monitor --response-time-threshold 500 --accessibility-threshold 90
```
### **Deep Diagnostics**
```bash
# GUI memory profiling and leak detection
/gui-debug --profile-gui-memory
# Cross-browser performance analysis
/gui-debug --browser-performance
# CLI command performance analysis
/gui-debug --cli-performance
# Accessibility compliance audit
/gui-debug --accessibility-audit --wcag-2.1-aa
```
## 🔍 Integration with Other Commands
### **Before Development**
```bash
# Ensure GUI system is healthy before making changes
/gui-debug --quick-check
```
### **After Changes**
```bash
# Validate entire GUI system after updates
/gui-debug --web-dashboard --cli-interface
```
### **Production Deployment**
```bash
# Full GUI validation before deployment
/gui-debug --full-scan --cross-platform --accessibility
```
### **Troubleshooting**
```bash
# Debug specific GUI interface issues
/gui-debug --verbose --web-dashboard --performance
# Comprehensive GUI debugging
/gui-debug --full-scan --monitor --detailed-report
```
## 📚 Related Commands
- `/dashboard` - Launch the web monitoring dashboard
- `/quality-check` - Run quality control on plugin components
- `/auto-analyze` - Autonomous project analysis
- `/performance-report` - Generate performance analytics
- `/validate` - General validation of tools and processes
## 🎯 Success Criteria
- **GUI Validation Accuracy**: 95%+ issue detection across all interfaces
- **Auto-Fix Success**: 85%+ success rate for common GUI issues
- **Performance Improvement**: 40%+ average GUI performance gain
- **User Experience**: <2s dashboard load, <1s CLI response, <1s chart render
- **Cross-Platform Compatibility**: 98%+ success rate across all platforms
- **Accessibility Compliance**: WCAG 2.1 AA standard or better
- **Interface Reliability**: 99.5%+ uptime with monitoring across all GUI components
This comprehensive GUI debugging command provides complete validation, automated issue resolution, and continuous monitoring capabilities for the entire graphical user interface system, ensuring all user touchpoints (web dashboard, CLI interface, and visual components) work reliably, perform optimally, and provide an excellent user experience across all platforms and devices.

325
commands/design/audit.md Normal file
View File

@@ -0,0 +1,325 @@
---
name: design:audit
description: Analyze and audit existing design without implementing changes - provides AI Slop Score, identifies generic patterns, and recommends improvements
delegates-to: autonomous-agent:frontend-design-enhancer
---
# Design Audit Command
**Command**: `/design:audit`
Analyze and audit existing frontend design without making changes. Identifies generic "AI slop" patterns, calculates AI Slop Score, and provides actionable recommendations. Use this to understand design issues before deciding whether to apply fixes.
## When to Use
**Use `/design:audit` for:**
- Analyzing existing design without changes
- Getting AI Slop Score and recommendations
- Understanding design problems before fixing
- Design review and critique
- Before/after comparison preparation
**Use `/design:enhance` for:**
- Full design enhancement with implementation
- Automatic fixes applied immediately
- Complete typography, color, animation overhaul
- Production-ready design improvements
## How It Works
**Analysis-Only Workflow** (No Implementation):
1. **Design Audit**: Calculate AI Slop Score (0-100)
2. **Pattern Detection**: Identify generic patterns
3. **Recommendations**: Suggest specific improvements
4. **Report Generation**: Detailed findings and action plan
**No Changes Made** - This command is read-only and safe to run on production code
## Usage
### Basic Audit
```bash
/design:audit "src/components/LandingPage.tsx"
/design:audit "dashboard design"
/design:audit "current website"
```
### Specific Component Audit
```bash
/design:audit "navigation menu"
/design:audit "product card design"
/design:audit "login form"
```
### Full Application Audit
```bash
/design:audit "entire React app"
/design:audit "marketing website"
/design:audit "admin dashboard"
```
## Output Format
**Terminal** (15-20 lines):
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DESIGN AUDIT RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AI Slop Score: 75/100 (High - Needs Improvement)
Generic Patterns Detected:
1. Typography: Inter font (30 points) - Very common AI default
2. Colors: Purple gradient (25 points) - Overused AI aesthetic
3. Background: Plain white (20 points) - No visual depth
4. Animations: None (0 points) - Static interface
5. Layout: Standard grid (0 points) - Acceptable
Top 3 Recommendations:
1. Replace Inter with distinctive pairing (e.g., Playfair Display + Source Sans)
2. Use intentional color scheme (ocean, sunset, forest, not purple)
3. Add layered backgrounds with gradients, textures, or patterns
Full Report: .claude/reports/design-audit-[timestamp].md
Time: 1m 15s
```
**File Report** (Comprehensive):
Saved to `.claude/reports/design-audit-[timestamp].md`:
- AI Slop Score breakdown by category
- All generic patterns detected with severity
- Detailed recommendations with code examples
- Before/after mockups (if applicable)
- Action plan prioritized by impact
## AI Slop Score Breakdown
**Score Components** (0-100, lower is better):
| Category | Points | Generic Pattern | Distinctive Alternative |
|----------|--------|----------------|------------------------|
| Typography | 30 | Inter, Roboto, Arial | Playfair Display, Space Grotesk, JetBrains Mono |
| Colors | 25 | Purple gradients | Ocean (cyan+teal), Sunset (orange+pink), Forest (green+brown) |
| Background | 20 | Plain white/solid | Layered gradients, textures, patterns, noise |
| Animations | 15 | None or generic | Page load sequences, purposeful micro-interactions |
| Layout | 10 | Standard grid | Asymmetric, broken grid, overlapping elements |
**Scoring**:
- **0-30**: Distinctive (Excellent)
- **31-50**: Above Average (Good)
- **51-70**: Average (Needs Work)
- **71-100**: Generic AI Slop (Poor)
## Audit Report Structure
### Section 1: Executive Summary
- AI Slop Score and grade
- Overall assessment
- Priority level (Low/Medium/High/Critical)
### Section 2: Typography Analysis
- Font families detected
- Font weight usage
- Type scale analysis
- Recommendations with examples
### Section 3: Color Analysis
- Color palette extraction
- Contrast ratio checks (WCAG AA/AAA)
- Generic pattern detection
- Intentional palette suggestions
### Section 4: Background Analysis
- Background treatment evaluation
- Depth and layering assessment
- Texture and pattern usage
- Enhancement recommendations
### Section 5: Animation Analysis
- Animation inventory
- Motion purpose evaluation
- Accessibility compliance
- Purposeful animation suggestions
### Section 6: Layout Analysis
- Grid structure evaluation
- Visual hierarchy assessment
- Innovation score
- Layout enhancement ideas
### Section 7: Action Plan
Prioritized recommendations:
1. **Quick Wins** (1-2 hours)
2. **Medium Impact** (3-5 hours)
3. **Major Overhaul** (1-2 days)
## Examples
### Example 1: Landing Page Audit
```bash
/design:audit "marketing landing page"
```
**Output**:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DESIGN AUDIT RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AI Slop Score: 85/100 (Very High - Critical Issues)
Generic Patterns Detected:
1. Typography: Inter font everywhere (30 points)
→ Recommendation: Playfair Display (headings) + Source Sans 3 (body)
2. Colors: Purple (#A855F7) to blue (#3B82F6) gradient (25 points)
→ Recommendation: Ocean theme (Cyan #06B6D4 + Teal #14B8A6)
3. Background: Plain white #FFFFFF (20 points)
→ Recommendation: Layered radial gradient with geometric grid overlay
4. Animations: None detected (10 points)
→ Recommendation: Page load fade + staggered section reveals
5. Layout: Standard 12-column grid (0 points)
→ Acceptable, but could add asymmetric hero section
Design Grade: D (Poor)
Priority: HIGH - Immediate attention needed
Full Report: .claude/reports/design-audit-landing-20250115.md
Time: 1m 22s
```
### Example 2: Dashboard Audit
```bash
/design:audit "admin dashboard"
```
**Output**:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DESIGN AUDIT RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AI Slop Score: 45/100 (Average - Room for Improvement)
Generic Patterns Detected:
1. Typography: Roboto font (15 points) - Partial credit, overused but acceptable
2. Colors: Intentional blue palette (0 points) - Good contrast, professional
3. Background: White cards on gray (5 points) - Basic but functional
4. Animations: Hover states only (10 points) - Could add micro-interactions
5. Layout: Sidebar + grid (0 points) - Standard but effective
Design Grade: B- (Above Average)
Priority: MEDIUM - Enhancement optional
Strengths:
- Good color contrast (WCAG AAA compliant)
- Consistent spacing and alignment
- Clear information hierarchy
Improvement Opportunities:
1. Consider distinctive monospace font for data tables
2. Add subtle background patterns to reduce flatness
3. Implement loading state animations for better UX
Full Report: .claude/reports/design-audit-dashboard-20250115.md
Time: 58s
```
### Example 3: Component Audit
```bash
/design:audit "product card component"
```
**Output**:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DESIGN AUDIT RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AI Slop Score: 55/100 (Average - Needs Improvement)
Component: Product Card
Generic Patterns Detected:
1. Typography: Inter 14px/16px/20px (20 points)
→ Use varied scale: 12px/16px/24px with different weights
2. Colors: Default Tailwind blue (10 points)
→ Apply consistent brand colors with intentional palette
3. Hover Animation: Scale 1.05 (5 points)
→ Generic, consider glow effect or shadow elevation instead
Specific Recommendations:
1. Font Scale: Increase title from 20px to 28px (more dramatic)
2. Weight Contrast: Use font-weight 900 for price, 300 for description
3. Hover State: Replace scale with shadow-lg + subtle border glow
4. Card Background: Add subtle gradient or texture
Design Grade: C+ (Average)
Priority: MEDIUM
Full Report: .claude/reports/design-audit-product-card-20250115.md
Time: 42s
```
## Comparison with /design:enhance
| Feature | /design:audit | /design:enhance |
|---------|---------------|-----------------|
| Analysis | ✅ Comprehensive | ✅ Comprehensive |
| AI Slop Score | ✅ Calculated | ✅ Calculated |
| Recommendations | ✅ Detailed | ✅ Implemented |
| Code Changes | ❌ None | ✅ Applied |
| File Report | ✅ Yes | ✅ Yes |
| Safe for Production | ✅ Read-only | ⚠️ Makes changes |
| Time | 1-3 min | 5-15 min |
| Best For | Analysis first | Full enhancement |
## Workflow Integration
**Recommended Workflow**:
1. Run `/design:audit` first to understand issues
2. Review recommendations in report
3. Decide which improvements to apply
4. Run `/design:enhance` to implement changes
5. Compare before/after AI Slop Scores
**Example**:
```bash
# Step 1: Audit current design
/design:audit "landing page"
# AI Slop Score: 85/100 - Review recommendations
# Step 2: Apply fixes
/design:enhance "landing page"
# AI Slop Score: 25/100 - Improvement: 60 points
```
## Pattern Learning
Audit patterns stored for optimization:
```json
{
"task_type": "design_audit",
"component_type": "landing_page",
"ai_slop_score": 85,
"generic_patterns": ["inter_font", "purple_gradient", "plain_background"],
"time_taken": "1m 22s"
}
```
Learns:
- Common generic patterns by component type
- Effective recommendations by project type
- AI Slop Score baselines for different designs
---
**Version**: 1.0.0
**Integration**: Works with frontend-design-enhancer agent (audit mode)
**Platform**: Cross-platform (Windows, Linux, Mac)
**Dependencies**: Read tool for file analysis

180
commands/design/enhance.md Normal file
View File

@@ -0,0 +1,180 @@
---
name: design:enhance
description: Enhance frontend design by applying research-backed aesthetic principles from Claude's official design research - implements distributional convergence awareness, high-impact motion, distinctive typography, and altitude-appropriate guidance
category: design
---
# Frontend Design Enhancement Command
Transform functional but generic frontend designs into distinctive, polished user experiences that avoid "AI slop" aesthetics. Based on official research from ["Improving frontend design through Skills"](https://claude.com/blog/improving-frontend-design-through-skills) by Anthropic.
## Core Principles Applied
**Distributional Convergence**: Breaks away from statistically common "safe defaults" (Inter fonts, purple gradients, minimal animations) that dominate training data distributions.
**Altitude-Appropriate Guidance**: Balances specificity and flexibility - provides contextual principles with concrete examples without prescribing exact values.
**High-Impact Moments**: One well-orchestrated page load with staggered reveals > dozen random micro-animations.
## Workflow
1. **Design Audit** (frontend-design-enhancer agent):
- Identify current fonts, colors, backgrounds, animations
- Calculate AI Slop Score (0-100, lower is better)
- Detect distributional defaults:
- Generic fonts (Inter/Roboto/Open Sans/Lato)
- Purple-on-white gradients (#a855f7#ffffff)
- Plain backgrounds with no depth
- Missing or random animations
2. **Typography Enhancement** (frontend-aesthetics skill):
- **High-Contrast Pairings**: Display + monospace, serif + geometric sans
- **Extreme Weight Variations**: 100-200 (ultra-thin) OR 800-900 (extra-bold) for headings
- **Size Jumps**: 3x+ ratio (hero 4rem → body 1rem), not incremental 1.5x
- Implement fluid typography with clamp()
- Select from distinctive font categories (code-aesthetic, editorial, technical, playful, elegant)
3. **Color Scheme Design**:
- Create intentional palette with mood (professional, energetic, calm, bold)
- **Forbidden**: Purple-on-white (#a855f7#ffffff)
- Draw inspiration from IDE themes and cultural aesthetics
- Ensure WCAG AA contrast compliance (4.5:1 minimum)
- Use CSS variables for cohesive system
4. **Background Treatment**:
- Layer CSS gradients for depth (mesh gradients, radial glows)
- Add subtle textures (noise, geometric grids)
- Implement ambient backgrounds (waves, patterns)
- **Avoid**: Plain white (#FFFFFF) or solid colors
5. **Animation Implementation** (web-artifacts-builder skill):
- **Priority #1**: Well-orchestrated page load (highest impact)
- **HTML Projects**: CSS-only animations (better performance)
- **React Projects**: Framer Motion for complex choreography
- Implement staggered reveals with Motion variants
- Add purposeful micro-interactions (hover, click feedback)
- **Always**: Respect `prefers-reduced-motion` (accessibility first)
6. **Validation** (quality-controller agent):
- Verify AI Slop Score improved to < 30 (distinctive design)
- Check accessibility standards (WCAG AA)
- Test responsive behavior across breakpoints
- Validate animation performance (GPU-accelerated properties)
- Store design pattern for future learning
## Output
**Terminal (Concise)**:
```
[OK] Design enhanced with Claude research principles
AI Slop Score: 85 -> 15 (Improved by 70 points - Distinctive)
Improvements Applied:
- Typography: Inter (generic) -> Playfair Display 700 + Source Sans 3 300 (high-contrast)
* Extreme weights: 700 (headings) vs 300 (body)
* Size jumps: 4rem hero -> 1rem body (4x ratio)
- Colors: Purple-on-white (#a855f7 → #fff) -> Ocean blue + amber (professional mood)
* Avoided distributional default
- Background: Plain white -> Layered gradient + subtle noise (depth)
- Animations: None -> Orchestrated page load with staggered reveals (Framer Motion)
* High-impact moment prioritized
Files Modified: 4 (tailwind.config.js, index.html, App.tsx, index.css)
Pattern Stored: design-enhancement-editorial-professional
Next Steps: Test responsive behavior, validate accessibility
Time: 12 minutes
```
**File (Comprehensive)** - Saved to `.claude/reports/design-enhancement-[timestamp].md`:
- **Design Philosophy**: Distributional convergence awareness, altitude-appropriate guidance
- **Full Audit**: Before/after comparison with AI Slop Score breakdown
- **Typography**:
- Font pairing rationale (high-contrast, extreme weights)
- Implementation code (Tailwind config, Google Fonts imports)
- Size scale with fluid clamp() values
- **Color System**:
- Complete palette with HSL values and CSS variables
- Mood/brand alignment explanation
- Contrast ratio validation (WCAG AA compliance)
- **Background Patterns**:
- Layering techniques (gradients, noise, textures)
- CSS implementation code
- **Animation System**:
- Framer Motion setup and configuration
- Page transition variants
- Staggered list animation patterns
- Micro-interaction examples
- Reduced motion accessibility
- **Accessibility Checklist**: Keyboard navigation, screen readers, reduced motion
- **Performance Metrics**: GPU-accelerated properties used, bundle size impact
- **Before/After Screenshots** (if available)
## Usage Examples
**Basic Enhancement**:
```bash
/design:enhance "Improve landing page aesthetics"
# Applies balanced design improvements across all aspects
```
**Project-Specific**:
```bash
/design:enhance "Make dashboard look professional with tech-ocean color scheme"
# Targets specific color mood
/design:enhance "Apply editorial design to blog with Playfair Display"
# Requests specific typography category
/design:enhance "React app needs distinctive design with Framer Motion"
# Specifies React + motion library
```
**Problem-Focused**:
```bash
/design:enhance "Fix generic AI appearance - looks like every tutorial"
# Addresses AI slop problem directly
/design:enhance "Too much purple gradient, needs unique identity"
# Tackles specific distributional default
```
## Technical Implementation
**Skills Loaded**:
- `autonomous-agent:frontend-aesthetics` - Core design principles and patterns
- `autonomous-agent:web-artifacts-builder` - React + Tailwind + Framer Motion patterns
- `autonomous-agent:gui-design-principles` - Foundational UI/UX principles
- `autonomous-agent:pattern-learning` - Learn from successful design patterns
**Agents Delegated**:
- `frontend-design-enhancer` (Group 3: Hand) - Executes design implementation
- `quality-controller` (Group 4: Guardian) - Validates accessibility and standards
**Auto-Fixes Applied**:
- Generic font replacement (Inter → distinctive alternatives)
- Purple gradient elimination (#a855f7 detection)
- Background depth addition (plain → layered)
- Animation implementation (static → purposeful motion)
- Contrast ratio corrections (WCAG AA compliance)
## Success Criteria
**Quantitative**:
- AI Slop Score < 30 (distinctive design)
- WCAG AA contrast: 4.5:1 minimum for text
- Typography size jumps: 3x+ ratio between levels
- Font weights: 100-200 or 800-900 for headings (extreme variation)
**Qualitative**:
- Distinctive fonts (NOT Inter/Roboto/Open Sans/Lato)
- Intentional color scheme (NOT purple-on-white #a855f7#ffffff)
- Layered backgrounds (NOT plain white #FFFFFF)
- High-impact animations (orchestrated page load, NOT random micro-animations)
- Altitude-appropriate implementation (contextual, NOT overly prescriptive)
**Learning**:
- Design pattern stored in `.claude-patterns/`
- Font pairing effectiveness tracked
- Color scheme mood success recorded
- Animation impact measured for future optimizations

801
commands/dev/auto.md Normal file
View File

@@ -0,0 +1,801 @@
---
name: dev:auto
description: Fully autonomous development from requirements to production-ready code with testing and validation
delegates-to: autonomous-agent:orchestrator
---
# Dev-Auto Command
## Command: `/dev:auto`
Fully autonomous development from requirements to release-ready implementation. This command handles the entire development lifecycle including planning, implementation, testing, debugging, validation, and optional release - all automatically with minimal human intervention.
**🤖 Full Autonomous Development:**
- **Zero to Release**: From user requirement to production-ready code
- **Incremental Development**: Commits each working milestone
- **Continuous Validation**: Tests and validates at every step
- **Auto-Debugging**: Automatically fixes failures and bugs
- **Quality Assurance**: Ensures ≥ 85/100 quality score
- **Learning Integration**: Improves from every development cycle
## How It Works
1. **Requirements Analysis**: Breaks down user requirements into implementable tasks
2. **Development Planning**: Creates phased development plan with milestones
3. **Incremental Implementation**: Implements each milestone with automatic commits
4. **Continuous Testing**: Tests after each change, debugs automatically if failed
5. **Parameter Validation**: Validates consistency (common failure point)
6. **Quality Control**: Runs quality checks, auto-fixes issues
7. **Requirements Verification**: Ensures implementation matches requirements
8. **Optional Release**: Can trigger `/release-dev` when complete
## Usage
### Basic Usage
```bash
# Simple feature request
/dev:auto "add MQTT broker with certificate support"
# Complex feature with multiple parts
/dev:auto "implement user authentication with JWT, including login, logout, and token refresh"
# Bug fix with testing
/dev:auto "fix memory leak in data processing module and add comprehensive tests"
# Refactoring task
/dev:auto "refactor authentication module to use dependency injection pattern"
```
### Advanced Options
```bash
# Development with automatic release
/dev:auto "add email notification system" --auto-release
# Specify quality threshold (default: 85)
/dev:auto "add caching layer" --quality-threshold 90
# Maximum debug iterations per milestone (default: 5)
/dev:auto "fix login bug" --max-debug-iterations 3
# Skip tests (not recommended)
/dev:auto "update documentation" --skip-tests
# Verbose logging for debugging
/dev:auto "implement API endpoint" --verbose
# Dry run (planning only, no implementation)
/dev:auto "add OAuth support" --dry-run
```
### Incremental Commit Options
```bash
# Commit frequency
/dev:auto "large feature" --commit-per-milestone # Default
/dev:auto "large feature" --commit-per-file # More frequent
/dev:auto "large feature" --commit-per-step # Very frequent
# Skip commits (single commit at end)
/dev:auto "small feature" --no-incremental-commits
```
### Testing Options
```bash
# Test types to run
/dev:auto "add API" --run-unit-tests --run-integration-tests
/dev:auto "add UI" --run-e2e-tests
# Test coverage requirement (default: 80%)
/dev:auto "add feature" --test-coverage 90
# Generate tests automatically
/dev:auto "add feature" --auto-generate-tests
```
## Development Workflow
### Phase 1: Requirements Analysis (10-30 seconds)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 REQUIREMENTS ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
User Request: "add MQTT broker with certificate support"
Requirement Breakdown:
+- 1. MQTT Broker Setup
| +- Dependencies: paho-mqtt or similar
| +- Configuration: broker URL, port, credentials
| +- Complexity: Medium
|
+- 2. Certificate Management
| +- SSL/TLS certificate loading
| +- Certificate validation
| +- Secure storage of credentials
| +- Complexity: Medium
|
+- 3. Connection Management
| +- Connect/disconnect logic
| +- Reconnection handling
| +- Connection state monitoring
| +- Complexity: Medium
|
+- 4. Message Publishing/Subscribing
| +- Topic management
| +- QoS handling
| +- Error handling
| +- Complexity: Medium
|
+- 5. Testing & Documentation
+- Unit tests
+- Integration tests
+- Documentation
+- Complexity: Simple
Technology Stack Detected:
+- Language: Python (detected from project)
+- Framework: Flask/FastAPI (if web API)
+- MQTT Library: paho-mqtt (recommended)
+- Testing: pytest
Estimated Time: 45-90 minutes
Milestones: 5 major milestones
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Phase 2: Development Planning (5-10 seconds)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📐 DEVELOPMENT PLAN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Development Strategy: Incremental with milestones
Milestone 1: Dependencies & Configuration
+- Install paho-mqtt library
+- Create configuration module
+- Add certificate path configuration
+- Estimated: 10 minutes
+- Commit: "feat: add MQTT dependencies and configuration"
Milestone 2: Certificate Management
+- Implement certificate loader
+- Add certificate validation
+- Implement secure storage
+- Estimated: 15 minutes
+- Commit: "feat: implement certificate management for MQTT"
Milestone 3: MQTT Connection Layer
+- Implement connection class
+- Add connect/disconnect methods
+- Implement reconnection logic
+- Add connection state monitoring
+- Estimated: 20 minutes
+- Commit: "feat: implement MQTT connection with auto-reconnect"
Milestone 4: Publish/Subscribe Interface
+- Implement publish method
+- Implement subscribe method
+- Add topic management
+- Handle QoS levels
+- Estimated: 20 minutes
+- Commit: "feat: add MQTT publish/subscribe interface"
Milestone 5: Testing & Documentation
+- Write unit tests
+- Write integration tests
+- Update documentation
+- Add usage examples
+- Estimated: 15 minutes
+- Commit: "test: add comprehensive MQTT tests and docs"
Success Criteria:
+- ✅ All tests pass (100%)
+- ✅ Certificate validation works
+- ✅ Reconnection logic tested
+- ✅ Documentation complete
+- ✅ Quality score ≥ 85/100
Starting development in 3 seconds...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Phase 3: Incremental Development Loop
Each milestone follows this loop:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔨 MILESTONE 1/5: Dependencies & Configuration
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[IMPLEMENTATION]
Creating mqtt_config.py...
+- ✅ Configuration class created
+- ✅ Environment variable support added
+- ✅ Certificate path validation added
+- ✅ Default values configured
Creating requirements.txt entry...
+- ✅ Added: paho-mqtt==1.6.1
+- ✅ Updated lock file
[VALIDATION]
Parameter Consistency Check:
+- ✅ Config parameter names consistent
+- ✅ Type hints correct
+- ✅ No undefined variables
[TESTING]
Running unit tests...
+- test_config_loading: ✅ PASS
+- test_certificate_path_validation: ✅ PASS
+- test_env_variable_loading: ✅ PASS
+- Test Coverage: 95% (target: 80%)
[QUALITY CHECK]
+- Code Quality: 92/100 ✅
+- Standards: ✅ PEP 8 compliant
+- Documentation: ✅ Docstrings present
+- Security: ✅ No vulnerabilities
[COMMIT]
+- Staging files: 3 files
+- Commit message: "feat: add MQTT dependencies and configuration"
+- Commit hash: abc1234
+- ✅ Pushed to origin/main
Milestone 1: ✅ COMPLETE (elapsed: 8m 32s)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔨 MILESTONE 2/5: Certificate Management
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[IMPLEMENTATION]
Creating mqtt_certificates.py...
+- ✅ CertificateLoader class created
+- ✅ SSL context configuration
+- ✅ Certificate validation logic
+- ✅ Error handling added
[VALIDATION]
Parameter Consistency Check:
+- ✅ Certificate parameters match config
+- ✅ SSL context options consistent
+- ✅ Error messages standardized
[TESTING]
Running unit tests...
+- test_certificate_loading: ✅ PASS
+- test_invalid_certificate: ✅ PASS
+- test_certificate_validation: ❌ FAIL
| +- Error: SSL certificate verification failed
+- Test Coverage: 88%
[DEBUG LOOP - Iteration 1]
Analyzing failure...
+- Root Cause: Certificate path mismatch
+- Issue: Using absolute path instead of relative
+- Fix: Update certificate path resolution
Applying fix...
+- ✅ Updated path resolution logic
+- ✅ Added path normalization
Re-running tests...
+- test_certificate_loading: ✅ PASS
+- test_invalid_certificate: ✅ PASS
+- test_certificate_validation: ✅ PASS
+- Test Coverage: 92%
[QUALITY CHECK]
+- Code Quality: 90/100 ✅
+- Security: ✅ No hardcoded credentials
+- Documentation: ✅ Complete
[COMMIT]
+- Commit message: "feat: implement certificate management for MQTT"
+- Commit hash: def5678
+- ✅ Pushed to origin/main
Milestone 2: ✅ COMPLETE (elapsed: 12m 45s)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
... (Milestones 3-5 continue similarly) ...
```
### Phase 4: Requirements Verification (20-40 seconds)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ REQUIREMENTS VERIFICATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Original Request: "add MQTT broker with certificate support"
Implementation Checklist:
+- ✅ MQTT broker connection implemented
| +- ✅ Connect method working
| +- ✅ Disconnect method working
| +- ✅ Auto-reconnection implemented
|
+- ✅ Certificate support implemented
| +- ✅ SSL/TLS certificates loaded
| +- ✅ Certificate validation working
| +- ✅ Secure credential storage
|
+- ✅ Message handling implemented
| +- ✅ Publish method working
| +- ✅ Subscribe method working
| +- ✅ QoS levels supported
|
+- ✅ Error handling complete
| +- ✅ Connection errors handled
| +- ✅ Certificate errors handled
| +- ✅ Message errors handled
|
+- ✅ Testing complete
+- ✅ Unit tests: 24/24 passing
+- ✅ Integration tests: 6/6 passing
+- ✅ Test coverage: 94%
Quality Metrics:
+- Code Quality: 92/100 ✅ (threshold: 85)
+- Test Coverage: 94% ✅ (threshold: 80%)
+- Documentation: 90/100 ✅
+- Security: 95/100 ✅
+- Overall: 92/100 ✅
Completeness: 100% ✅
All requirements satisfied!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Phase 5: Final Report (10 seconds)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ AUTONOMOUS DEVELOPMENT COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Requirement: add MQTT broker with certificate support
⏱️ Total Time: 48m 32s
🔄 Iterations: 1 (1 debug loop in Milestone 2)
📊 Final Quality: 92/100
✨ Implemented:
+- MQTT broker connection with auto-reconnect
+- SSL/TLS certificate management and validation
+- Publish/Subscribe interface with QoS support
+- Comprehensive error handling
+- Complete documentation and usage examples
📦 Files Created/Modified:
+- mqtt_config.py (new)
+- mqtt_certificates.py (new)
+- mqtt_client.py (new)
+- tests/test_mqtt.py (new)
+- requirements.txt (modified)
+- README.md (modified)
✅ Tests: 30/30 passing (100%)
+- Unit tests: 24/24
+- Integration tests: 6/6
📚 Documentation: 90/100
+- API documentation complete
+- Usage examples added
+- Configuration guide included
🔒 Security: 95/100
+- No hardcoded credentials
+- Secure certificate storage
+- Proper SSL/TLS configuration
🐛 Issues Fixed: 1
+- Certificate path resolution (Milestone 2)
📊 Code Metrics:
+- Lines Added: 486
+- Lines Modified: 23
+- Test Coverage: 94%
+- Cyclomatic Complexity: Low
🔄 Commits: 5 incremental commits
+- abc1234: feat: add MQTT dependencies and configuration
+- def5678: feat: implement certificate management for MQTT
+- ghi9012: feat: implement MQTT connection with auto-reconnect
+- jkl3456: feat: add MQTT publish/subscribe interface
+- mno7890: test: add comprehensive MQTT tests and docs
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 SUGGESTED NEXT ACTIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. [High Priority] Test MQTT integration end-to-end
-> /dev:auto "add integration tests for MQTT with real broker"
2. [Recommended] Release this feature
-> /dev:release --minor
3. [Optional] Add monitoring for MQTT connection
-> /dev:auto "add prometheus metrics for MQTT"
4. [Learning] View development analytics
-> /learn:performance
Choose option (1-4) or type custom command:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Optional: Auto-Release (if --auto-release flag used)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 AUTO-RELEASE TRIGGERED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Triggering /dev:release...
[Release workflow output here - see /dev:release docs]
Release: v3.5.1 ✅
Links:
+- GitHub: https://github.com/user/repo/releases/tag/v3.5.1
+- Changelog: https://github.com/user/repo/blob/main/CHANGELOG.md
Total Time (dev + release): 51m 15s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Debug Loop Details
When tests fail, the debug loop automatically:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔧 DEBUG LOOP - Iteration 1/5
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Test Failure Detected:
+- Test: test_mqtt_publish
+- Error: ConnectionRefusedError: [Errno 111] Connection refused
+- Stack Trace: [truncated for brevity]
[ANALYSIS]
Root Cause Analysis:
+- Category: Integration Error
+- Specific Issue: MQTT broker not running
+- Affected Component: mqtt_client.py:45
+- Similar Patterns: Found 3 similar issues in patterns
Recommended Fix:
+- Option 1: Add connection retry logic (recommended)
+- Option 2: Mock MQTT broker for tests
+- Option 3: Skip integration tests in CI
Selected Fix: Option 1 (best success rate: 95%)
[IMPLEMENTATION]
Applying fix...
+- ✅ Added exponential backoff retry
+- ✅ Maximum 3 retry attempts
+- ✅ Configurable retry delay
+- ✅ Logging for retry attempts
[VALIDATION]
Parameter Consistency:
+- ✅ Retry parameters consistent
+- ✅ Timeout values aligned
+- ✅ Error messages standardized
[RE-TEST]
Running tests again...
+- test_mqtt_publish: ✅ PASS
+- test_mqtt_subscribe: ✅ PASS
+- All tests: 30/30 passing
Debug Loop: ✅ SUCCESS (resolved in 1 iteration)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
If debug loop fails after max iterations:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[WARN] DEBUG LOOP - MAX ITERATIONS REACHED (5/5)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Unable to resolve issue automatically.
Issue Summary:
+- Test: test_complex_reconnection_logic
+- Error: Intermittent connection timeout
+- Attempts: 5 different fixes tried
+- Success Rate: 0/5
Attempted Fixes:
1. Increased timeout values - Failed
2. Added connection pooling - Failed
3. Implemented circuit breaker - Failed
4. Adjusted retry backoff - Failed
5. Modified SSL handshake - Failed
Manual Intervention Required:
This appears to be a complex integration issue that requires
human analysis. The following information has been collected:
Detailed Error Report: .claude/data/reports/debug-failure-2025-01-24.md
Code Changes Applied: 5 incremental commits
Test Logs: .claude/logs/test-failures.log
Recommendations for Manual Fix:
1. Review MQTT broker configuration
2. Check network connectivity and firewall rules
3. Verify SSL certificate chain is complete
4. Test with different MQTT broker versions
Would you like to:
1. Continue with partial implementation (current milestone only)
2. Rollback all changes and report issue
3. Commit current state for manual fix later
Choose option (1-3):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Parameter Validation
Critical validation performed automatically:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 PARAMETER VALIDATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Checking parameter consistency across codebase...
Function Call Analysis:
+- mqtt_connect(broker_url, port, username, password)
+- Used in 8 locations
+- ✅ All parameters match function signature
Configuration Validation:
+- Config file: mqtt_config.py
+- Environment variables: .env
+- Function parameters: mqtt_client.py
+- ✅ All parameter names consistent
Type Safety Check:
+- Type hints present: ✅ 100%
+- Type consistency: ✅ All correct
+- ✅ No type mismatches found
Null Safety Check:
+- Null checks present: ✅ All critical paths
+- Default values defined: ✅ All optional params
+- ✅ No null pointer risks
Common Failure Patterns:
+- ✅ No undefined variables
+- ✅ No parameter name typos
+- ✅ No missing required parameters
+- ✅ No type conversion errors
Parameter Validation: ✅ PASS (100%)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Integration with Learning System
The `/dev-auto` command deeply integrates with pattern learning:
**Learning from Success**:
- Successful implementation approaches
- Effective milestone breakdown strategies
- Optimal test coverage strategies
- Best debugging techniques
- Common parameter patterns
**Learning from Failure**:
- Failed debug attempts
- Ineffective implementation patterns
- Common error causes
- Integration pitfalls
- Time-consuming approaches to avoid
**Pattern Storage**:
```json
{
"dev_auto_patterns": {
"task_type": "mqtt_integration",
"successful_approach": {
"milestones": 5,
"avg_milestone_time": "9.7 minutes",
"total_time": "48.5 minutes",
"debug_iterations": 1,
"quality_score": 92
},
"common_issues": [
{
"issue": "certificate_path_mismatch",
"frequency": 0.65,
"fix_success_rate": 0.95,
"recommended_fix": "use_relative_paths"
}
],
"skill_effectiveness": {
"code-analysis": 0.94,
"testing-strategies": 0.91,
"security-patterns": 0.88
},
"reuse_count": 12,
"average_improvement": "+18% quality, -23% time"
}
}
```
## Integration with Other Commands
### Complete Development Workflow
```bash
# Plan feature
/dev:auto "add feature" --dry-run
# Implement feature
/dev:auto "add feature"
# Validate quality
/analyze:quality
# Release
/dev:release
```
### With Validation Commands
```bash
# Development with validation
/dev:auto "implement API"
/validate:fullstack
/analyze:static
```
### With Learning Commands
```bash
# Check development patterns
/learn:analytics
# Development with pattern awareness
/dev:auto "similar feature to previous"
# Review performance
/learn:performance
```
## Agent Delegation
`/dev-auto` delegates to specialized agents:
- **code-analyzer**: For code structure analysis
- **test-engineer**: For test generation and debugging
- **quality-controller**: For quality validation and auto-fix
- **documentation-generator**: For documentation updates
- **security-auditor**: For security validation
- **frontend-analyzer**: For frontend-specific tasks
- **api-contract-validator**: For API contract validation
- **build-validator**: For build configuration
## Skills Integration
Auto-loads relevant skills based on task:
- **code-analysis**: For implementation guidance
- **testing-strategies**: For comprehensive testing
- **quality-standards**: For quality compliance
- **security-patterns**: For security best practices
- **documentation-best-practices**: For documentation
- **pattern-learning**: For continuous improvement
- **autonomous-development**: For development strategies
## Best Practices
### Writing Good Requirements
```bash
# Good: Specific and actionable
/dev:auto "add REST API endpoint for user registration with email validation"
# Bad: Too vague
/dev:auto "make the app better"
# Good: Clear scope
/dev:auto "refactor database layer to use repository pattern"
# Bad: Too broad
/dev:auto "fix everything"
# Good: Includes acceptance criteria
/dev:auto "add caching with Redis, must support TTL and invalidation"
```
### When to Use --auto-release
- Small, isolated features
- Bug fixes
- Documentation updates
- Non-breaking changes
### When NOT to Use --auto-release
- Major features requiring review
- Breaking changes
- Security-critical changes
- Changes requiring team discussion
### Quality Thresholds
- **85 (default)**: Production-ready standard
- **90**: High-quality applications
- **95**: Mission-critical systems
- **80**: Development/testing environments
## Troubleshooting
### Development Stuck in Loop
```bash
# Check current status
/dev:auto status
# Force exit debug loop
/dev:auto abort
# View detailed logs
cat .claude/logs/dev-auto-current.log
```
### Tests Keep Failing
```bash
# Increase max debug iterations
/dev:auto "feature" --max-debug-iterations 10
# Skip specific test types
/dev:auto "feature" --skip-integration-tests
# Manual fix mode
/dev:auto "feature" --manual-fix-on-failure
```
### Quality Check Fails
```bash
# Lower threshold temporarily
/dev:auto "feature" --quality-threshold 75
# Skip quality check (not recommended)
/dev:auto "feature" --skip-quality-check
# Run quality check separately
/analyze:quality
```
## Performance Metrics
Expected performance:
| Task Type | Avg Time | Success Rate | Iterations |
|-----------|----------|--------------|------------|
| Small Feature | 15-30 min | 95% | 0-1 |
| Medium Feature | 30-60 min | 88% | 1-2 |
| Large Feature | 1-3 hours | 78% | 2-4 |
| Bug Fix | 10-20 min | 92% | 0-1 |
| Refactoring | 20-45 min | 85% | 1-2 |
Success rate improves with learning:
- First 5 similar tasks: 75-80%
- After 10 similar tasks: 85-90%
- After 25 similar tasks: 90-95%
---
**Version**: 1.0.0
**Integration**: Uses orchestrator, test-engineer, quality-controller, code-analyzer agents
**Skills**: code-analysis, testing-strategies, quality-standards, autonomous-development
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Full integration with pattern learning system

578
commands/dev/commit.md Normal file
View File

@@ -0,0 +1,578 @@
---
name: dev:commit
description: Intelligent commit management with automatic staging, conventional commits, and learning integration
delegates-to: autonomous-agent:git-repository-manager
---
# Dev-Commit Command
## Command: `/dev:commit`
**Smart commit management** - Analyzes changes, generates intelligent commit messages following conventional commit standards, stages appropriate files, and creates commits with learning integration. Does NOT create releases or tags.
**🔧 Intelligent Commit Features:**
- **Automatic Change Analysis**: Reviews all modified and new files
- **Smart File Staging**: Intelligently stages related files together
- **Conventional Commits**: Generates proper commit messages (feat:, fix:, docs:, etc.)
- **Multi-file Commits**: Groups related changes into logical commits
- **Interactive Mode**: Option to review before committing
- **Learning Integration**: Learns effective commit patterns over time
- **No Release**: Only commits - no tags, no releases, no version bumps
## How It Works
1. **Analyze Changes**: Reviews all uncommitted changes
2. **Categorize Changes**: Groups changes by type (features, fixes, docs, etc.)
3. **Generate Commit Messages**: Creates conventional commit messages
4. **Stage Files**: Intelligently stages files for each commit
5. **Create Commits**: Executes git commit with generated messages
6. **Push (Optional)**: Optionally pushes to remote
7. **Learn**: Stores commit patterns for future improvements
## Usage
### Basic Usage
```bash
# Analyze and commit all changes with smart grouping
/dev:commit
# Commit with custom message
/dev:commit "feat: add new authentication system"
# Commit specific files only
/dev:commit --files "src/auth.py,tests/test_auth.py"
```
### Automatic Commit Message Generation
```bash
# Let the agent analyze and generate appropriate messages
/dev:commit --auto
# Generate message but review before committing
/dev:commit --auto --interactive
# Use conventional commit format
/dev:commit --conventional
```
### Commit Grouping Options
```bash
# Group all changes into single commit
/dev:commit --single
# Create multiple commits grouped by type
/dev:commit --group-by-type
# Create commit per file
/dev:commit --per-file
# Create commit per directory
/dev:commit --per-directory
```
### Push Options
```bash
# Commit and push to remote
/dev:commit --push
# Commit and push to specific branch
/dev:commit --push --branch feature/new-feature
# Commit only (no push) - DEFAULT
/dev:commit --no-push
```
### Advanced Options
```bash
# Include untracked files
/dev:commit --include-untracked
# Exclude specific patterns
/dev:commit --exclude "*.log,*.tmp"
# Verbose output with reasoning
/dev:commit --verbose
# Dry run (show what would be committed)
/dev:commit --dry-run
```
## Output Format
### Terminal Output (Concise)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔧 COMMIT ANALYSIS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Changes Analyzed: 12 files
Commit Strategy: Group by type
Proposed Commits:
1. feat: Add 6 new analysis commands
Files: 6 files in commands/analyze/ and commands/learn/
2. fix: Fix dashboard browser opening issues
Files: 2 files (lib/dashboard.py, lib/dashboard_launcher.py)
3. docs: Update plugin documentation
Files: 4 files (README.md, CLAUDE.md, etc.)
Execute commits? [Y/n]: Y
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ COMMITS CREATED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[PASS] Commit 1: feat: Add 6 new analysis commands (abc1234)
[PASS] Commit 2: fix: Fix dashboard browser opening issues (def5678)
[PASS] Commit 3: docs: Update plugin documentation (ghi9012)
Total: 3 commits created
Pushed: No (use --push to push to remote)
⏱ Completed in 8 seconds
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Commit Message Generation
### Conventional Commit Format
The command automatically detects change types and generates appropriate conventional commit messages:
**Format**: `<type>(<scope>): <description>`
**Types:**
- `feat`: New features or functionality
- `fix`: Bug fixes
- `docs`: Documentation changes only
- `style`: Code style/formatting (no logic changes)
- `refactor`: Code refactoring (no feature/fix)
- `perf`: Performance improvements
- `test`: Adding or updating tests
- `chore`: Maintenance tasks (dependencies, configs, etc.)
- `ci`: CI/CD configuration changes
- `build`: Build system changes
**Examples:**
```bash
# Feature additions
feat: add JWT authentication system
feat(auth): implement refresh token mechanism
# Bug fixes
fix: resolve memory leak in data processing
fix(api): correct endpoint parameter validation
# Documentation
docs: update README with new commands
docs(api): add authentication examples
# Refactoring
refactor: simplify authentication logic
refactor(db): optimize query performance
# Tests
test: add integration tests for auth module
test(api): improve endpoint coverage
# Chores
chore: update dependencies to latest versions
chore(deps): bump python-jose to 1.6.1
```
## Smart File Staging
The command intelligently groups files for commits:
### Group by Type (Default)
```
Commit 1: feat: Add new commands
+- commands/analyze/explain.md
+- commands/analyze/repository.md
+- commands/learn/history.md
+- commands/learn/clone.md
Commit 2: fix: Fix dashboard issues
+- lib/dashboard.py
+- lib/dashboard_launcher.py
Commit 3: docs: Update documentation
+- README.md
+- CLAUDE.md
+- CHANGELOG.md
```
### Group by Directory
```
Commit 1: feat: Update analyze commands
+- commands/analyze/
+- explain.md
+- repository.md
Commit 2: feat: Update learn commands
+- commands/learn/
+- history.md
+- clone.md
Commit 3: fix: Update library
+- lib/
+- dashboard.py
+- dashboard_launcher.py
```
### Single Commit
```
Commit 1: chore: Update plugin with multiple improvements
+- commands/analyze/explain.md
+- commands/analyze/repository.md
+- commands/learn/history.md
+- commands/learn/clone.md
+- lib/dashboard.py
+- lib/dashboard_launcher.py
+- README.md
+- CLAUDE.md
```
## Change Detection
The command analyzes changes to determine appropriate commit messages:
### Feature Detection
Triggers `feat:` commit when:
- New files in `commands/`, `agents/`, `skills/`
- New function definitions
- New API endpoints
- New classes or modules
### Fix Detection
Triggers `fix:` commit when:
- Bug fix keywords in changes (fix, bug, issue, error)
- Modified error handling
- Modified validation logic
- Corrected typos or logic errors
### Documentation Detection
Triggers `docs:` commit when:
- Only markdown files modified
- Only docstrings modified
- Only comments modified
- README, CHANGELOG, or documentation files
### Refactor Detection
Triggers `refactor:` commit when:
- Code structure changes without logic changes
- Function/class renaming
- Code organization improvements
- Performance optimizations
## Integration with Learning System
The `/dev:commit` command integrates with pattern learning:
**Learning from Commits**:
- Effective commit message patterns
- Optimal file grouping strategies
- Common change type patterns
- Successful commit sizes
- Push timing patterns
**Pattern Storage**:
```json
{
"commit_patterns": {
"grouping_strategy": "by_type",
"avg_commits_per_session": 2.5,
"avg_files_per_commit": 4.2,
"effective_message_patterns": [
"feat: add {feature}",
"fix: resolve {issue}",
"docs: update {document}"
],
"success_metrics": {
"single_commit_clarity": 0.78,
"grouped_commit_clarity": 0.92,
"per_file_commit_clarity": 0.65
},
"reuse_count": 45,
"effectiveness_score": 0.91
}
}
```
**Continuous Improvement**:
- Learn which grouping strategies work best
- Improve commit message quality over time
- Optimize file staging decisions
- Reduce commit fragmentation
- Enhance clarity and traceability
## Interactive Mode
When using `--interactive`, the command shows a review before committing:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 COMMIT REVIEW
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Commit 1 of 3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Type: feat
Message: Add 6 new analysis and learning commands
Description:
Implements external repository analysis, task explanation,
commit history learning, feature cloning, and documentation
updates. Enhances learning capabilities significantly.
Files to be committed:
+- commands/analyze/explain.md (new, 26 KB)
+- commands/analyze/repository.md (new, 35 KB)
+- commands/learn/history.md (new, 24 KB)
+- commands/learn/clone.md (new, 21 KB)
+- commands/workspace/update-readme.md (new, 3.7 KB)
+- commands/workspace/update-about.md (new, 3.9 KB)
Total: 6 files, 113.6 KB
Options:
[c] Commit as shown
[e] Edit commit message
[s] Skip this commit
[m] Modify file selection
[q] Quit without committing
Choice:
```
## Best Practices
### When to Use `/dev:commit`
**Good use cases:**
- During active development (commit frequently)
- After completing a logical unit of work
- Before switching tasks or branches
- After fixing bugs or issues
- When you want smart commit organization
**Don't use for:**
- Creating releases (use `/dev:release` instead)
- Version tagging (use `/dev:release` instead)
- Publishing to package managers (use `/dev:release`)
### Commit Frequency
**Recommended patterns:**
- **Small features**: 1-2 commits
- **Medium features**: 3-5 commits grouped logically
- **Large features**: Multiple commits per logical component
- **Bug fixes**: 1 commit per bug
- **Documentation**: 1 commit per documentation update session
**Avoid:**
- Too many tiny commits (creates noise)
- Giant commits with unrelated changes (hard to review)
- Commits without clear purpose or message
### Commit Message Quality
**Good commit messages:**
```bash
feat: add JWT authentication with refresh tokens
fix: resolve memory leak in background task manager
docs: add comprehensive API documentation with examples
refactor: simplify validation logic using schemas
test: add integration tests for auth workflow
```
**Poor commit messages:**
```bash
update files
fix stuff
changes
wip
asdf
```
## Integration with Other Commands
### Development Workflow
```bash
# Work on feature
/dev:auto "add new feature"
# Commit progress regularly
/dev:commit --auto
# Continue working...
/dev:commit --auto
# When ready to release
/dev:release
```
### Pre-Release Workflow
```bash
# Commit all pending changes
/dev:commit --auto --group-by-type
# Validate quality
/analyze:quality
# Create release
/dev:release
```
### Feature Branch Workflow
```bash
# Create feature branch
git checkout -b feature/new-auth
# Work and commit
/dev:commit --auto
# Push to remote branch
/dev:commit --push --branch feature/new-auth
# Create PR when ready
/dev:pr-review
```
## Troubleshooting
### No Changes to Commit
```bash
# Check git status
git status
# Show what would be committed
/dev:commit --dry-run
# Include untracked files
/dev:commit --include-untracked
```
### Commit Failed
```bash
# Check for conflicts
git status
# Resolve conflicts manually
git add <resolved-files>
# Retry commit
/dev:commit --retry
```
### Wrong Files Staged
```bash
# Unstage all
git reset
# Specify files explicitly
/dev:commit --files "file1.py,file2.py"
```
### Push Failed
```bash
# Check remote status
git remote -v
# Pull first if needed
git pull origin main
# Retry push
/dev:commit --push --retry
```
## Performance Metrics
Expected performance:
| Task | Time | Success Rate |
|------|------|--------------|
| Analyze changes | 2-5s | 100% |
| Generate commit messages | 3-8s | 95% |
| Create single commit | 1-2s | 99% |
| Create multiple commits | 5-15s | 97% |
| Push to remote | 3-10s | 95% |
**Learning improvement:**
- After 10 commits: 20% faster message generation
- After 25 commits: 85% message quality (up from 70%)
- After 50 commits: 92% optimal grouping decisions
## Examples
### Example 1: Auto-commit with smart grouping
```bash
$ /dev:commit --auto
Analyzing changes...
Found: 8 modified files, 4 new files
Proposed commits:
1. feat: Add new authentication commands (6 files)
2. fix: Resolve dashboard rendering issue (2 files)
3. docs: Update README and CHANGELOG (4 files)
Creating commits...
[PASS] 3 commits created successfully
Total changes committed: 12 files
```
### Example 2: Custom commit with specific files
```bash
$ /dev:commit "feat: implement JWT token validation" --files "src/auth/jwt.py,tests/test_jwt.py"
Staging files...
+- src/auth/jwt.py
+- tests/test_jwt.py
Creating commit...
[PASS] Commit created: feat: implement JWT token validation (abc1234)
```
### Example 3: Interactive review mode
```bash
$ /dev:commit --auto --interactive
[Shows review interface for each proposed commit]
Commit 1: Accept (c)
Commit 2: Edit message (e)
Commit 3: Skip (s)
Result:
[PASS] 2 commits created
1 commit skipped
```
### Example 4: Commit and push
```bash
$ /dev:commit --auto --push
Creating commits...
[PASS] 3 commits created
Pushing to origin/main...
[PASS] Pushed successfully
Branch: main
Remote: origin
Commits: 3 new commits
```
---
**Version**: 1.0.0
**Integration**: Uses git-repository-manager agent
**Skills**: git-automation, pattern-learning, code-analysis
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Full integration with pattern learning system
**Scope**: Commit management only - no releases, tags, or version bumps

View File

@@ -0,0 +1,355 @@
---
name: dev:model-switch
description: Switch between Claude and GLM AI models with secure token management
delegates-to: autonomous-agent:orchestrator
---
# Development Model Switch Command
Switch between Claude and GLM models in your Claude Code environment with secure token management and cross-platform compatibility.
## Usage
```bash
# Switch to GLM models (interactive setup)
/dev:model-switch --to glm
# Switch to Claude models (restore defaults)
/dev:model-switch --to claude
# Check current model configuration
/dev:model-switch --status
# Auto-switch based on task type (future feature)
/dev:model-switch --auto
# Set up initial configuration
/dev:model-switch --setup
```
## How It Works
### Model Configuration
The command modifies `~/.claude/settings.json` to configure model endpoints:
**GLM Configuration:**
```json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.6",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.6"
}
}
```
**Claude Configuration (Default):**
```json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_anthropic_api_key",
"ANTHROPIC_BASE_URL": "https://api.anthropic.com"
}
}
```
### Cross-Platform Implementation
**Windows (PowerShell):**
```powershell
# Create settings directory
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude"
# Update configuration
$config = Get-Content "$env:USERPROFILE\.claude\settings.json" | ConvertFrom-Json
$config.env.ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
$config.env.ANTHROPIC_AUTH_TOKEN = $apiKey
$config | ConvertTo-Json | Set-Content "$env:USERPROFILE\.claude\settings.json"
```
**Linux/macOS (Bash):**
```bash
# Create settings directory
mkdir -p ~/.claude
# Update configuration
jq '.env.ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic" |
jq '.env.ANTHROPIC_AUTH_TOKEN = "'$apiKey'"' ~/.claude/settings.json > ~/.claude/settings.json.tmp &&
mv ~/.claude/settings.json.tmp ~/.claude/settings.json
```
## Features
### 🔒 **Secure Token Management**
- **Token Validation**: Validates API key format before use
- **Secure Storage**: Stores tokens only in local settings file
- **Privacy First**: Never shares tokens with external services
- **Token Encryption**: Future enhancement for encrypted token storage
### 🌐 **Cross-Platform Compatibility**
- **Windows**: PowerShell script execution
- **Linux/macOS**: Bash script execution with jq fallback
- **Automatic Detection**: Detects platform and uses appropriate method
- **Fallback Options**: Manual instructions if automation fails
### 🎯 **Smart Configuration**
- **Backup Creation**: Automatically backs up current settings
- **Validation**: Validates JSON syntax before applying changes
- **Rollback**: Easy rollback to previous configuration
- **Status Checking**: Real-time configuration status display
### 🚀 **Future Automation**
- **Task-Based Switching**: Automatically switch models based on task complexity
- **Performance Optimization**: Choose models based on task requirements
- **Cost Management**: Optimize model usage for cost efficiency
- **Load Balancing**: Distribute tasks across available models
## Command Options
### Basic Switching
```bash
# Switch to GLM (interactive)
/dev:model-switch --to glm
# Switch to Claude (restore defaults)
/dev:model-switch --to claude
```
### Status and Information
```bash
# Check current configuration
/dev:model-switch --status
# Show available models
/dev:model-switch --list-models
# Validate current configuration
/dev:model-switch --validate
```
### Advanced Options
```bash
# Force switch without confirmation
/dev:model-switch --to glm --force
# Use specific GLM model
/dev:model-switch --to glm --model glm-4.6
# Backup current settings before switching
/dev:model-switch --to glm --backup
# Dry run (show changes without applying)
/dev:model-switch --to glm --dry-run
```
## Model Comparison
| Feature | Claude (Anthropic) | GLM (Z.AI) | Best For |
|---------|-------------------|-------------|-----------|
| **Response Quality** | Excellent | Very Good | General tasks |
| **Speed** | Fast | Very Fast | Quick tasks |
| **Cost** | Higher | Lower | Budget-conscious |
| **Chinese Support** | Good | Excellent | Chinese content |
| **Code Analysis** | Excellent | Good | Code review |
| **Creative Tasks** | Excellent | Very Good | Creative writing |
| **Technical Accuracy** | Excellent | Good | Technical docs |
## Security Best Practices
### 🔒 **Token Security**
- **Never share API keys** in plain text
- **Use environment variables** when possible
- **Rotate tokens regularly** for security
- **Monitor usage** for unauthorized access
- **Store securely** in encrypted format
### 🛡️ **Configuration Security**
- **Backup settings** before making changes
- **Validate JSON syntax** to prevent corruption
- **Use secure connections** (HTTPS only)
- **Close Claude windows** before applying changes
- **Verify changes** after applying
### 🔐 **Privacy Protection**
- **Local storage only** - no cloud sync of tokens
- **No telemetry** - usage data stays private
- **Secure deletion** - clear tokens when needed
- **Access control** - limit file permissions
- **Audit trail** - log configuration changes
## Examples
### Initial GLM Setup
```bash
# First-time GLM setup
/dev:model-switch --to glm
# Interactive prompts:
# 1. Enter your Z.AI API key: [sk-xxxxxxxx]
# 2. Validate API key... ✅ Valid
# 3. Back up current settings... ✅ Backed up
# 4. Apply GLM configuration... ✅ Applied
# 5. Restart Claude Code to apply changes
# Status after setup:
Current Model: GLM (glm-4.6)
API Endpoint: https://api.z.ai/api/anthropic
Token Status: ✅ Valid
Last Updated: 2025-01-26 20:45:30
```
### Quick Model Toggle
```bash
# Switch to GLM for Chinese content
/dev:model-switch --to glm --force
# Switch back to Claude for code analysis
/dev:model-switch --to claude
# Check current status
/dev:model-switch --status
```
### Advanced Configuration
```bash
# Use specific GLM model with backup
/dev:model-switch --to glm --model glm-4.5-air --backup
# Dry run to preview changes
/dev:model-switch --to glm --dry-run
# Validate configuration without switching
/dev:model-switch --validate --target glm
```
## Troubleshooting
### Common Issues
**API Key Invalid:**
```bash
# Check token format
/dev:model-switch --validate-token sk-xxxxxxxx
# Re-enter token
/dev:model-switch --to glm --renew-token
```
**Configuration Not Applied:**
```bash
# Check file permissions
/dev:model-switch --check-permissions
# Manually apply changes
/dev:model-switch --to glm --manual
```
**Model Not Responding:**
```bash
# Test API connection
/dev:model-switch --test-connection
# Switch to backup model
/dev:model-switch --fallback claude
```
### Platform-Specific Issues
**Windows PowerShell:**
```powershell
# Check PowerShell execution policy
Get-ExecutionPolicy
# Allow script execution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
**Linux/macOS:**
```bash
# Check jq installation
jq --version
# Install jq if needed
# Ubuntu/Debian: sudo apt-get install jq
# macOS: brew install jq
# CentOS/RHEL: sudo yum install jq
```
### Recovery Options
```bash
# Restore from backup
/dev:model-switch --restore-backup
# Reset to defaults
/dev:model-switch --reset-defaults
# Generate new configuration
/dev:model-switch --generate-config
```
## Integration with Learning System
The model-switch command integrates with the autonomous learning system:
**Pattern Storage:**
```json
{
"model_switch_patterns": {
"task_type": "chinese_translation",
"preferred_model": "glm",
"success_rate": 0.92,
"performance_improvement": "+15%",
"cost_savings": "-40%"
}
}
```
**Auto-Switching Logic:**
- Analyze task requirements
- Match with historical performance
- Recommend optimal model
- Learn from user choices
- Optimize for cost and quality
## Future Enhancements
### 🚀 **Planned Features**
- **Multi-Model Load Balancing**: Distribute tasks across models
- **Performance Analytics**: Track model performance metrics
- **Cost Optimization**: Automatic cost-effective model selection
- **Smart Routing**: Route tasks to best-suited models
- **Token Management**: Automated token rotation and management
- **Model Comparison**: Side-by-side model performance testing
### 🔧 **Technical Improvements**
- **Encrypted Storage**: Secure token encryption
- **API Rate Limiting**: Intelligent rate limit handling
- **Connection Pooling**: Optimized connection management
- **Caching**: Response caching for faster performance
- **Monitoring**: Real-time model performance monitoring
---
**Version**: 1.0.0
**Integration**: Uses orchestrator agent with security-patterns skill
**Platform**: Cross-platform (Windows, Linux, Mac)
**Security**: Privacy-first with secure token management

635
commands/dev/pr-review.md Normal file
View File

@@ -0,0 +1,635 @@
---
name: dev:pr-review
description: CodeRabbit-style PR review with security scanning, test coverage, and one-click fixes
delegates-to: autonomous-agent:pr-reviewer
---
# Pull Request Review Command
Execute a comprehensive CodeRabbit-style review of a pull request with automated analysis, security scanning, and one-click fixes.
## Usage
```bash
/dev:pr-review [PR_NUMBER|BRANCH_NAME]
```
**Examples**:
```bash
/dev:pr-review 123 # Review PR #123
/dev:pr-review feature/auth # Review branch against main
/dev:pr-review # Review current branch changes
```
## Workflow
### 1. Initialize Review
- Detect PR context (number, branch, or current changes)
- Fetch PR metadata (title, author, description)
- Extract git diff and commit history
### 2. Delegate to PR Reviewer Agent
Execute comprehensive review via `pr-reviewer` agent:
```javascript
const review_result = await delegate_to_pr_reviewer({
pr_number: pr_number,
pr_data: {
title: pr_title,
author: pr_author,
description: pr_description,
files: changed_files,
diff: full_diff,
commits: commit_history
}
});
```
### 3. Analysis Pipeline
The PR reviewer agent executes:
**A. Summary Generation** (5-10s):
- Change categorization (features, bug fixes, refactoring, etc.)
- Files changed count and line statistics
- Complexity score calculation
**B. Line-by-Line Analysis** (30-60s):
- Code quality issues (naming, duplication, complexity)
- Best practice violations (SOLID, DRY, error handling)
- Performance concerns (N+1 queries, inefficient algorithms)
- Type annotations and documentation
**C. Security Scan** (20-40s via security-auditor):
- OWASP Top 10 vulnerability detection
- Input validation checks
- Authentication/authorization review
- Secrets exposure detection
- Dependency vulnerability scan
**D. Test Coverage Analysis** (15-30s):
- Calculate coverage for changed lines
- Identify untested functions
- Generate test suggestions
- Coverage delta calculation
**E. Automated Fix Generation** (10-20s):
- Generate one-click fixes for auto-fixable issues
- Provide suggestions with explanations
- Calculate confidence scores
**F. Risk Assessment** (5-10s):
- Calculate weighted risk score
- Identify risk factors (size, complexity, critical files)
- Generate recommendations
**G. Related PR Detection** (5-10s):
- Find PRs touching same files
- Detect similar changes
- Identify dependencies
### 4. Report Generation
Generate comprehensive review report:
```markdown
# Pull Request Review: #{PR_NUMBER}
## 📊 Summary
**Risk Level**: {RISK_LEVEL} ({RISK_SCORE}/100)
Files: {COUNT} | +{ADDITIONS} -{DELETIONS} | Complexity: {SCORE}/100
## 🔒 Security ({VULN_COUNT} issues)
🔴 Critical: {COUNT} | 🟠 High: {COUNT} | 🟡 Medium: {COUNT}
## 📈 Test Coverage
{COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%) | Untested: {COUNT}
## 💡 Code Review ({ISSUE_COUNT} issues)
{DETAILED_REVIEWS_BY_FILE}
## ⚡ Performance ({ISSUE_COUNT} concerns)
{PERFORMANCE_ISSUES}
## 🎯 Recommendations
### Critical ({COUNT})
### Suggested ({COUNT})
### Nice to Have ({COUNT})
## ✅ Approval Checklist
- [ ] All critical issues resolved
- [ ] Test coverage adequate
- [ ] No new vulnerabilities
- [ ] Performance acceptable
```
### 5. Interactive Fix Application
Provide one-click fix application:
```python
# Auto-fixable issues presented with "Apply Fix" option
# User can select fixes to apply
# System applies fixes and creates commit
```
## Skills Integration
This command leverages:
**ast-analyzer**:
- Deep code structure analysis
- Complexity calculation
- Impact analysis
**security-patterns**:
- Vulnerability detection patterns
- Secure coding guidelines
**contextual-pattern-learning**:
- Find similar successful PRs
- Learn review patterns
- Improve accuracy over time
**code-analysis**:
- Code quality metrics
- Best practice validation
## Output Format
### Terminal Output (Tier 1: Concise Summary)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PR REVIEW COMPLETE: #{PR_NUMBER}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Overview
Risk Level: {RISK_LEVEL} ({RISK_SCORE}/100)
Files: {COUNT} | +{ADDITIONS} -{DELETIONS}
Complexity: {SCORE}/100
🔒 Security Analysis
🔴 Critical: {COUNT} | 🟠 High: {COUNT} | 🟡 Medium: {COUNT}
Total New Vulnerabilities: {COUNT}
📈 Test Coverage
Coverage: {COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%)
Untested Functions: {COUNT}
💡 Top 3 Issues
1. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
2. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
3. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
🎯 Top 3 Recommendations
1. {CRITICAL_RECOMMENDATION}
2. {SUGGESTED_IMPROVEMENT}
3. {NICE_TO_HAVE}
✅ Auto-fixable Issues: {COUNT}/{TOTAL}
📄 Detailed Report: .data/reports/pr-review/pr-{NUMBER}-{DATE}.md
⏱️ Review completed in {DURATION}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Detailed Report (Tier 2: Comprehensive File)
Saved to: `.data/reports/pr-review/pr-{NUMBER}-{YYYY-MM-DD}.md`
**Full Report Structure**:
```markdown
# Pull Request Review: #{PR_NUMBER}
**Generated**: {TIMESTAMP}
**Review Time**: {DURATION}
**Reviewer**: Autonomous PR Review Agent v1.0
---
## Table of Contents
1. [Summary](#summary)
2. [Security Analysis](#security-analysis)
3. [Test Coverage](#test-coverage)
4. [Code Review](#code-review)
5. [Performance Analysis](#performance-analysis)
6. [Recommendations](#recommendations)
7. [Related PRs](#related-prs)
8. [Approval Checklist](#approval-checklist)
---
## Summary
**Title**: {PR_TITLE}
**Author**: {AUTHOR}
**Status**: {STATUS}
**Risk Level**: {RISK_LEVEL} ({RISK_SCORE}/100)
### Changes Overview
- **Files Changed**: {COUNT}
- **Lines Added**: +{ADDITIONS}
- **Lines Removed**: -{DELETIONS}
- **Complexity Score**: {SCORE}/100
### Change Categories
-**Features**: {COUNT} files
- {FILE_LIST}
- 🐛 **Bug Fixes**: {COUNT} files
- {FILE_LIST}
- ♻️ **Refactoring**: {COUNT} files
- {FILE_LIST}
- 📝 **Documentation**: {COUNT} files
- {FILE_LIST}
-**Tests**: {COUNT} files
- {FILE_LIST}
### Risk Factors
| Factor | Score | Weight | Impact |
|--------|-------|--------|--------|
| Size | {SCORE}/100 | 20% | {IMPACT} |
| Complexity | {SCORE}/100 | 25% | {IMPACT} |
| Test Coverage | {SCORE}/100 | 25% | {IMPACT} |
| Critical Files | {SCORE}/100 | 20% | {IMPACT} |
| Security | {SCORE}/100 | 10% | {IMPACT} |
---
## Security Analysis
**New Vulnerabilities Detected**: {COUNT}
### Critical Issues (🔴)
#### {VULN_TITLE_1}
- **File**: `{FILE_PATH}`
- **Line**: {LINE_NUMBER}
- **Severity**: CRITICAL
- **CWE**: CWE-{NUMBER} - {CWE_NAME}
- **OWASP**: {OWASP_CATEGORY}
**Vulnerable Code**:
```{LANGUAGE}
{VULNERABLE_CODE}
```
**Description**: {DETAILED_DESCRIPTION}
**Remediation**:
```{LANGUAGE}
{FIXED_CODE}
```
**Explanation**: {EXPLANATION}
**Auto-fixable**: {YES/NO}
[Apply Fix] (One-click button)
---
### High Issues (🟠)
{SIMILAR_STRUCTURE}
### Medium Issues (🟡)
{SIMILAR_STRUCTURE}
### Low Issues (⚪)
{SIMILAR_STRUCTURE}
---
## Test Coverage
**Overall Coverage**: {COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%)
- **Changed Lines Coverage**: {CHANGED_LINES_COV}%
- **Untested Functions**: {COUNT}
### Coverage by File
| File | Before | After | Delta | Untested Functions |
|------|--------|-------|-------|-------------------|
| {FILE} | {BEFORE}% | {AFTER}% | {DELTA}% | {COUNT} |
### Untested Functions
#### {FILE_PATH}
- `{FUNCTION_NAME}` (line {LINE})
- `{FUNCTION_NAME}` (line {LINE})
**Suggested Test**:
```{LANGUAGE}
{SUGGESTED_TEST_CODE}
```
---
## Code Review
### {FILE_PATH_1}
#### Line {LINE}: {ISSUE_TITLE}
**Severity**: {CRITICAL/HIGH/MEDIUM/LOW}
**Category**: {CODE_QUALITY/BEST_PRACTICE/PERFORMANCE}
**Original Code**:
```{LANGUAGE}
{ORIGINAL_CODE}
```
**Issue**: {DETAILED_ISSUE_DESCRIPTION}
**Suggested Fix**:
```{LANGUAGE}
{SUGGESTED_CODE}
```
**Explanation**: {WHY_THIS_IS_BETTER}
**Auto-fixable**: {YES/NO}
**Confidence**: {CONFIDENCE}%
[Apply Fix] (One-click button)
---
### {FILE_PATH_2}
{SIMILAR_STRUCTURE}
---
## Performance Analysis
**Potential Performance Impact**: {LOW/MEDIUM/HIGH}
### N+1 Query Issues ({COUNT})
#### {FILE}:{LINE} - {FUNCTION_NAME}
**Detected Pattern**: Loop with database query inside
**Current Code**:
```{LANGUAGE}
{CURRENT_CODE}
```
**Optimized Code**:
```{LANGUAGE}
{OPTIMIZED_CODE}
```
**Performance Improvement**: {ESTIMATED_IMPROVEMENT}
---
### Inefficient Algorithms ({COUNT})
{SIMILAR_STRUCTURE}
### Missing Indexes ({COUNT})
{SIMILAR_STRUCTURE}
### Large Data Operations ({COUNT})
{SIMILAR_STRUCTURE}
---
## Recommendations
### 🔴 Critical Actions Required ({COUNT})
1. **{CRITICAL_ISSUE_1}**
- **File**: {FILE}
- **Action**: {SPECIFIC_ACTION}
- **Impact**: {IMPACT_DESCRIPTION}
2. **{CRITICAL_ISSUE_2}**
{SIMILAR_STRUCTURE}
---
### 🟡 Suggested Improvements ({COUNT})
1. **{IMPROVEMENT_1}**
- **File**: {FILE}
- **Benefit**: {BENEFIT_DESCRIPTION}
- **Effort**: {LOW/MEDIUM/HIGH}
2. **{IMPROVEMENT_2}**
{SIMILAR_STRUCTURE}
---
### ⚪ Nice to Have ({COUNT})
1. **{NICE_TO_HAVE_1}**
- **File**: {FILE}
- **Benefit**: {MINOR_BENEFIT}
---
## Related PRs
### PRs Touching Same Files
- **#{PR_NUMBER}**: {TITLE}
- **Author**: {AUTHOR}
- **Status**: {STATUS}
- **Overlap**: {FILE_COUNT} files
- **Potential Conflict**: {YES/NO}
### Similar PRs
- **#{PR_NUMBER}**: {TITLE}
- **Similarity**: {PERCENTAGE}%
- **Lessons Learned**: {INSIGHTS}
### Dependent PRs
- **#{PR_NUMBER}**: {TITLE}
- **Dependency Type**: {BLOCKS/BLOCKED_BY}
---
## Approval Checklist
### Mandatory Requirements
- [ ] All critical security issues resolved
- [ ] Test coverage ≥ 70% for changed lines
- [ ] No new critical vulnerabilities introduced
- [ ] All tests passing
- [ ] Documentation updated
### Code Quality
- [ ] No code quality issues with severity > MEDIUM
- [ ] Best practices followed
- [ ] Performance impact acceptable
- [ ] No technical debt introduced
### Review Sign-off
- [ ] Security review complete
- [ ] Performance review complete
- [ ] Test coverage adequate
- [ ] Code review complete
---
## Review Metadata
**Review Generated**: {TIMESTAMP}
**Review Time**: {DURATION}
**Auto-fixable Issues**: {COUNT}/{TOTAL}
**Confidence Score**: {AVERAGE_CONFIDENCE}%
**Reviewer Agent**: pr-reviewer v1.0
**Security Scanner**: security-auditor v1.0
**AST Analyzer**: ast-analyzer v1.0
**Pattern Learner**: contextual-pattern-learning v3.0
---
## One-Click Fixes Available
{COUNT} issues can be fixed automatically. Apply all fixes with:
```bash
/apply-pr-fixes {PR_NUMBER}
```
Or apply individual fixes:
```bash
/apply-fix {ISSUE_ID}
```
---
**End of Report**
```
---
## Implementation Details
### Git Integration
```python
def fetch_pr_data(pr_identifier):
"""Fetch PR data from git or GitHub CLI."""
if pr_identifier.isdigit():
# Use gh CLI for PR number
pr_data = subprocess.run(
["gh", "pr", "view", pr_identifier, "--json",
"title,author,body,files,additions,deletions"],
capture_output=True
)
else:
# Use git for branch comparison
diff = subprocess.run(
["git", "diff", f"origin/main...{pr_identifier}"],
capture_output=True
)
commits = subprocess.run(
["git", "log", f"origin/main..{pr_identifier}",
"--oneline"],
capture_output=True
)
return parse_pr_data(pr_data)
```
### Fix Application
```python
def apply_fix(issue_id):
"""Apply automated fix for specific issue."""
issue = load_issue(issue_id)
if not issue.auto_fixable:
print("Issue not auto-fixable")
return False
# Apply Edit tool
Edit(
file_path=issue.file,
old_string=issue.original_code,
new_string=issue.suggested_code
)
# Run tests to verify
test_result = run_tests()
if test_result.success:
# Create commit
git_commit(f"Fix: {issue.title}\n\nAuto-applied fix from PR review")
return True
else:
# Rollback
git_checkout(issue.file)
return False
```
## Learning Integration
After each PR review, the learning engine captures:
1. **Review Patterns**:
- Which issues were found in which file types
- Success rate of automated fixes
- False positive rates
2. **Project Patterns**:
- Common issue patterns in this codebase
- Team coding style preferences
- Review thoroughness preferences
3. **Performance Metrics**:
- Review time by PR size
- Issue detection accuracy
- Fix application success rate
4. **Continuous Improvement**:
- Reduce false positives over time
- Improve fix suggestion quality
- Personalize review style to team
## Error Handling
```python
try:
review_result = comprehensive_pr_review(pr_number)
except GitError as e:
print(f"Git error: {e.message}")
print("Ensure you're in a git repository and PR exists")
except SecurityScanError as e:
print(f"Security scan failed: {e.message}")
print("Review will continue with partial results")
except Exception as e:
print(f"Review failed: {e}")
print("Saving partial results...")
save_partial_review(partial_data)
```
## Performance Expectations
| PR Size | Files | Lines | Review Time |
|---------|-------|-------|-------------|
| Small | 1-5 | <200 | 30-60s |
| Medium | 6-15 | 200-500 | 1-2min |
| Large | 16-30 | 500-1000 | 2-4min |
| XLarge | 31+ | 1000+ | 4-8min |
## Follow-up Commands
After review:
```bash
/apply-pr-fixes {PR_NUMBER} # Apply all auto-fixable issues
/apply-fix {ISSUE_ID} # Apply specific fix
/dev:pr-review-history # Show review history
/learn:analytics # Review performance analytics
```
---
This command provides comprehensive, CodeRabbit-level PR review capabilities with deep integration into the autonomous learning system.

766
commands/dev/release.md Normal file
View File

@@ -0,0 +1,766 @@
---
name: dev:release
description: Complete automated release workflow with platform detection (GitHub/GitLab/Bitbucket) and release creation
delegates-to: autonomous-agent:version-release-manager
---
# Release-Dev Command
## Command: `/dev:release`
**CRITICAL**: This command MUST execute ALL steps from version detection through GitHub release creation. The version-release-manager agent MUST complete the entire workflow without stopping early.
Streamlined release preparation and publishing workflow. This command automates the entire release process from version detection to GitHub/GitLab publishing with intelligent validation and automatic documentation updates.
## MANDATORY EXECUTION STEPS
**The version-release-manager agent MUST execute these steps in order and COMPLETE ALL OF THEM:**
### Step 1: Analyze Changes (REQUIRED)
- Run `git log --oneline` to review commits since last release
- Categorize changes (features, fixes, breaking changes)
- Determine version bump type (major/minor/patch)
### Step 2: Determine Version (REQUIRED)
- Read current version from `.claude-plugin/plugin.json`
- Calculate new version based on changes
- Confirm version follows semantic versioning
### Step 3: Update Version Files (REQUIRED)
- Update `.claude-plugin/plugin.json`
- Update `README.md` (all version references)
- Update `CLAUDE.md` (all version references)
- Update any other files with version numbers
### Step 4: Generate Documentation (REQUIRED)
- Generate `CHANGELOG.md` entry from git commits
- Create `RELEASE_NOTES_v{version}.md` with human-readable summary
- Update feature counts and component lists
### Step 5: Validate Consistency (REQUIRED)
- Verify all version numbers match
- Check documentation consistency
- Validate no old version references remain
### Step 6: Git Operations (REQUIRED)
- Stage all changes: `git add .`
- Create commit with message: `release: v{version} - {summary}`
- Create git tag: `git tag v{version}`
- Push to remote: `git push origin main`
- Push tags: `git push origin v{version}`
### Step 7: Create Repository Release (REQUIRED - DO NOT SKIP)
**This step is MANDATORY and MUST be executed based on detected platform:**
#### Step 7a: Detect Repository Platform (REQUIRED)
```bash
# Detect platform from git remote URL
git remote get-url origin
# Identify platform:
# - Contains "github.com" -> GitHub
# - Contains "gitlab.com" or "gitlab" -> GitLab
# - Contains "bitbucket.org" -> Bitbucket
# - Others -> Generic git repository (skip release creation)
```
#### Step 7b: Create Platform Release (REQUIRED if platform detected)
**For GitHub repositories:**
```bash
# Verify GitHub CLI is authenticated
gh auth status
# Create GitHub release
gh release create v{version} \
--title "Release v{version}: {title}" \
--notes-file RELEASE_NOTES_v{version}.md \
--latest
```
**For GitLab repositories:**
```bash
# Verify GitLab CLI is authenticated
glab auth status
# Create GitLab release
glab release create v{version} \
--name "Release v{version}: {title}" \
--notes "$(cat RELEASE_NOTES_v{version}.md)"
```
**For Bitbucket repositories:**
```bash
# Bitbucket uses git tags (already created in Step 6)
# No additional CLI command needed
echo "✅ Release created via git tag (Bitbucket)"
```
**For other git repositories:**
```bash
# Generic git repository without platform-specific features
echo "✅ Release created via git tag"
```
### Step 8: Verify Release (REQUIRED)
**Platform-specific verification:**
**For GitHub:**
```bash
gh release view v{version}
echo "✅ GitHub Release: https://github.com/{owner}/{repo}/releases/tag/v{version}"
```
**For GitLab:**
```bash
glab release view v{version}
echo "✅ GitLab Release: https://gitlab.com/{owner}/{repo}/-/releases/v{version}"
```
**For others:**
```bash
git tag -l v{version}
echo "✅ Git tag created: v{version}"
```
- Store release pattern for learning
**🚀 Quick Release Features:**
- **One-command release**: Automated end-to-end release workflow
- **Smart version detection**: Automatically determines version bump needed
- **Platform detection**: Automatically detects GitHub, GitLab, Bitbucket, or generic git
- **Platform-specific releases**: Creates releases using appropriate CLI (gh, glab, etc.)
- **Documentation sync**: Updates all docs, README, changelog automatically
- **Validation first**: Ensures quality before releasing
- **Auto-commit & push**: Handles all Git operations automatically
- **Multi-platform support**: GitHub, GitLab, Bitbucket, and generic git repositories
## How It Works
The workflow executes 8 MANDATORY steps in sequence:
1. **Analyze Changes**: Reviews all changes since last release
2. **Determine Version**: Auto-detects major/minor/patch based on commits
3. **Update Version Files**: Updates plugin.json, package.json, setup.py, etc.
4. **Sync Documentation**: Updates README, CHANGELOG, RELEASE_NOTES
5. **Validate Consistency**: Cross-checks all files for version consistency
6. **Git Operations**: Commits, tags, and pushes automatically
7. **Create Platform Release**: Detects platform (GitHub/GitLab/Bitbucket) and creates appropriate release
8. **Verify Release**: Confirms release was created successfully on detected platform
## Usage
### Quick Release (Recommended)
```bash
# Fully automated release with smart detection
/dev:release
# This will:
# - Analyze changes and determine version bump
# - Update all version files and documentation
# - Validate consistency across all files
# - Run quality checks (must pass ≥ 85/100)
# - Commit, tag, and push to remote
# - Create GitHub release with comprehensive notes (DEFAULT)
# - Optional: Publish to npm, PyPI, Docker (if specified)
```
### Specify Version Type
```bash
# Force specific version bump
/dev:release --patch # Bug fixes only (x.y.Z)
/dev:release --minor # New features (x.Y.0)
/dev:release --major # Breaking changes (X.0.0)
# Specify exact version
/dev:release --version 2.5.0
```
### Validation Options
```bash
# Skip quality validation (not recommended)
/dev:release --skip-validation
# Set minimum quality threshold (default: 85)
/dev:release --quality-threshold 90
# Dry run (preview without making changes)
/dev:release --dry-run
```
### Documentation Options
```bash
# Update specific documentation
/dev:release --update-changelog
/dev:release --update-readme
/dev:release --generate-release-notes
# Custom release notes file
/dev:release --release-notes ./CUSTOM_NOTES.md
```
### Platform Options
```bash
# GitHub release is now created by DEFAULT
/dev:release # Creates GitHub release automatically
# Additional platforms (optional)
/dev:release --npm # Also publish to npm
/dev:release --pypi # Also publish to PyPI
/dev:release --docker # Build and push Docker image
/dev:release --gitlab # GitLab instead of GitHub
# Multi-platform release
/dev:release --npm --docker # GitHub + npm + Docker
```
### Pre-release Options
```bash
# Create pre-release versions
/dev:release --pre-release alpha
/dev:release --pre-release beta
/dev:release --pre-release rc
# Example: v1.2.3-beta.1
/dev:release --minor --pre-release beta
```
## Workflow Stages
### Stage 1: Change Analysis (5-15 seconds)
Analyzes all changes since last release to determine version bump:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 CHANGE ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Current Version: v3.3.2
Last Release: 2025-01-15 (9 days ago)
Commits Since Release: 24
Change Breakdown:
+- 🎉 Features: 3 commits
| +- feat: add /dev-auto command
| +- feat: add interactive suggestions
| +- feat: .gitignore management
+- 🐛 Bug Fixes: 2 commits
| +- fix: validation error handling
| +- fix: documentation typos
+- 📚 Documentation: 5 commits
+- ♻️ Refactoring: 1 commit
+- [WARN] Breaking Changes: None
Recommended Version: v3.4.0 (MINOR)
Reason: New features added, no breaking changes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 2: Version Update (5-10 seconds)
Updates version across all project files:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 VERSION UPDATE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Updating version: v3.3.2 -> v3.4.0
Files Updated:
+- ✅ .claude-plugin/plugin.json
+- ✅ README.md (4 references)
+- ✅ CLAUDE.md (2 references)
+- ✅ package.json
+- ✅ docs/IMPLEMENTATION_SUMMARY.md
Total: 5 files, 8 version references updated
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 3: Documentation Sync (10-20 seconds)
Automatically updates all documentation:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 DOCUMENTATION SYNC
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
README.md:
+- Updated version badge
+- Updated feature list
+- Updated installation instructions
CHANGELOG.md:
+- Generated from commit history
+- Categorized changes:
| +- Added (3 features)
| +- Fixed (2 bugs)
| +- Changed (1 refactor)
| +- Documentation (5 docs)
+- Release date: 2025-01-24
RELEASE_NOTES.md:
+- Human-readable summary
+- Feature highlights
+- Bug fix details
+- Upgrade instructions
Documentation Status: ✅ All files synchronized
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 4: Consistency Validation (10-15 seconds)
Cross-checks all files for consistency:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ CONSISTENCY VALIDATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Version Consistency:
+- ✅ All version references match: v3.4.0
+- ✅ No old version numbers found
+- ✅ Version format consistent
Documentation Consistency:
+- ✅ Feature counts match across files
+- ✅ Component counts accurate
+- ✅ All links valid
+- ✅ Examples up-to-date
Structure Consistency:
+- ✅ All agents registered (20)
+- ✅ All skills registered (14)
+- ✅ All commands registered (18)
+- ✅ Plugin.json valid
Validation Score: 100/100 ✅
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 5: Quality Check (30-60 seconds)
Runs comprehensive quality validation:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 QUALITY CHECK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Code Quality:
+- ✅ Plugin structure valid
+- ✅ All YAML frontmatter valid
+- ✅ All JSON files valid
+- ✅ No syntax errors
Documentation Quality:
+- ✅ README complete (95/100)
+- ✅ All commands documented
+- ✅ All agents documented
+- ✅ Examples working
Standards Compliance:
+- ✅ Follows plugin guidelines
+- ✅ Naming conventions correct
+- ✅ File structure correct
Quality Score: 92/100 ✅ (Threshold: 85)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 6: Git Operations (10-20 seconds)
Commits, tags, and pushes automatically:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔧 GIT OPERATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Staging Changes:
+- ✅ 5 files staged
+- ✅ No unexpected changes
Creating Commit:
+- Message: "release: v3.4.0 - Add /dev-auto and suggestions"
+- Files: 5 modified
+- ✅ Commit created: abc1234
Creating Tag:
+- Tag: v3.4.0
+- Message: "Release v3.4.0"
+- ✅ Tag created
Pushing to Remote:
+- ✅ Pushed to origin/main
+- ✅ Pushed tags
Git Status: ✅ All operations successful
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 7: GitHub Repository Release (10-20 seconds)
Creates GitHub release with comprehensive release notes:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 GITHUB REPOSITORY RELEASE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
GitHub Authentication Check:
+- ✅ GitHub CLI authenticated
+- ✅ Repository access verified
+- ✅ Release permissions confirmed
Creating GitHub Release:
+- Version: v3.4.0
+- Title: "Release v3.4.0: [Release Summary]"
+- Release Notes: Generated from changelog
+- Assets: Source code archive
+- ✅ Published: https://github.com/user/repo/releases/tag/v3.4.0
Release Details:
+- Release Type: [MAJOR/MINOR/PATCH]
+- Changes: [Number] commits included
+- Features: [Number] new features
+- Bug Fixes: [Number] bug fixes
+- Quality Score: [Score]/100
GitHub Release Status: ✅ Successfully created
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 8: Optional Platform Publishing (15-30 seconds)
Publishes to additional configured platforms (if specified):
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 OPTIONAL PLATFORM PUBLISHING
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
npm Publishing:
+- Building package...
+- Running npm publish...
+- ✅ Published: https://npmjs.com/package/autonomous-agent@3.4.0
Docker Publishing:
+- Building image: user/autonomous-agent:3.4.0
+- Pushing to Docker Hub...
+- ✅ Published: docker pull user/autonomous-agent:3.4.0
Optional Release Status: ✅ Selected platforms published
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Stage 9: Learning Integration (5 seconds)
Stores release pattern for future optimization:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧠 LEARNING INTEGRATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Pattern Stored:
+- Task Type: release
+- Version Bump: minor (3.3.2 -> 3.4.0)
+- Files Updated: 5
+- Quality Score: 92/100
+- Time Taken: 2m 15s
+- ✅ Stored to .claude-patterns/
Future Improvements:
+- Faster documentation sync (learned shortcuts)
+- Better changelog categorization
+- Optimized validation checks
Learning Status: ✅ Pattern captured
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Final Summary
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ RELEASE COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Release: v3.4.0
Previous: v3.3.2
Type: MINOR (new features)
Summary:
+- 📦 Version updated across 5 files
+- 📚 Documentation synchronized
+- ✅ Validation passed (92/100)
+- 🔧 Git operations successful
+- 🚀 GitHub release created
+- 📦 Optional platforms published (if configured)
+- 🧠 Pattern learned for future
Total Time: 2m 30s
Links:
+- GitHub Release: https://github.com/user/repo/releases/tag/v3.4.0
+- Source Archive: https://github.com/user/repo/archive/refs/tags/v3.4.0.zip
+- npm: https://npmjs.com/package/autonomous-agent@3.4.0 (if published)
+- Docker: docker pull user/autonomous-agent:3.4.0 (if published)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 SUGGESTED NEXT ACTIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. Monitor release metrics
-> /learn:performance
2. Announce release to team
-> Draft announcement with highlights
3. Create next milestone
-> Plan features for v3.5.2
4. Update project board
-> Close completed issues
Choose option (1-4) or type custom command:
```
## Version Detection Logic
### Major Version (X.0.0)
Triggered by:
- `BREAKING CHANGE:` in commit messages
- `breaking:` commit type
- Major API changes detected
- Interface modifications
- Schema changes
### Minor Version (x.Y.0)
Triggered by:
- `feat:` commits (new features)
- `feature:` commits
- New functionality added
- Non-breaking additions
### Patch Version (x.y.Z)
Triggered by:
- `fix:` commits (bug fixes)
- `perf:` commits (performance improvements)
- `refactor:` commits (code refactoring)
- `docs:` commits (documentation only)
- `style:` commits (formatting)
- `chore:` commits (maintenance)
## Version File Detection
Automatically detects and updates:
- **.claude-plugin/plugin.json** (Claude plugins)
- **package.json** (Node.js/npm)
- **setup.py** (Python)
- **pyproject.toml** (Python Poetry)
- **Cargo.toml** (Rust)
- **composer.json** (PHP)
- **pom.xml** (Maven/Java)
- **\_\_init\_\_.py** (Python packages)
- **version.py** (Python version files)
- **Dockerfile** (Docker version ARG)
## Documentation Sync
Automatically updates:
- **README.md**: Version badges, feature lists, installation instructions
- **CHANGELOG.md**: Categorized change history with links
- **RELEASE_NOTES.md**: Human-readable release summary
- **docs/\*\*/\*.md**: Any documentation with version references
## Validation Checks
### Version Consistency
- All version references match
- No old version numbers remain
- Version format follows semver
### Documentation Consistency
- Feature counts accurate
- Component counts match
- Links valid and working
- Examples up-to-date
### Quality Standards
- Plugin structure valid
- YAML frontmatter correct
- JSON files parseable
- No syntax errors
### Git Readiness
- Working directory clean
- No merge conflicts
- Remote accessible
- Branch up-to-date
## Integration with Learning System
The `/release-dev` command integrates with the autonomous learning system:
**Pattern Storage**:
- Version bump decisions and reasoning
- Documentation update strategies
- Common consistency issues found
- Optimal release timing
- Platform-specific success rates
**Continuous Improvement**:
- Learn best changelog formats
- Optimize documentation sync speed
- Improve version detection accuracy
- Reduce validation time
- Enhance error prevention
## Integration with Other Commands
### Pre-Release Validation
```bash
# Validate before releasing
/validate:fullstack
/analyze:quality
/dev:release
```
### Post-Release Monitoring
```bash
# Monitor after release
/dev:release
/learn:performance
/learn:analytics
```
### Integrated Workflow
```bash
# Complete development cycle
/dev:auto "add new feature"
# ... development happens ...
/analyze:quality
/dev:release
```
## Platform Requirements
The command automatically detects your repository platform and uses the appropriate CLI tool:
### GitHub Repositories
**Required:**
- **GitHub CLI** (`gh` command) - Install: https://cli.github.com/
- **Authentication**: Run `gh auth login` once
- **Permissions**: Push access and release creation permissions
**Setup:**
```bash
gh auth login
gh auth status
```
### GitLab Repositories
**Required:**
- **GitLab CLI** (`glab` command) - Install: https://gitlab.com/gitlab-org/cli
- **Authentication**: Run `glab auth login` once
- **Permissions**: Push access and release creation permissions
**Setup:**
```bash
glab auth login
glab auth status
```
### Bitbucket Repositories
**No additional CLI required** - Uses git tags only
### Generic Git Repositories
**No additional CLI required** - Uses git tags only
## Troubleshooting
### Platform Release Failed
```bash
# For GitHub
gh auth status
gh repo view
/dev:release --retry
# For GitLab
glab auth status
glab repo view
/dev:release --retry
# For any platform
git remote -v # Check remote URL
git tag -l # List existing tags
```
### Quality Check Failed
```bash
# View detailed quality report
/analyze:quality --verbose
# Fix issues and retry
/dev:release --retry
# Skip validation (not recommended)
/dev:release --skip-validation --force
```
### Version Conflict
```bash
# Reset version detection
/dev:release --version 3.4.0 --force
# Manual version update
edit .claude-plugin/plugin.json
/dev:release --skip-version-update
```
### Git Operation Failed
```bash
# Check Git status
git status
git log --oneline -5
# Retry with verbose logging
/dev:release --verbose --retry
```
### Platform Publishing Failed
```bash
# Check authentication
gh auth status # GitHub
glab auth status # GitLab
npm whoami # npm
docker info # Docker
# Retry specific platform
/dev:release --github --retry
```
## Best Practices
### Pre-Release Checklist
- [ ] All changes committed and pushed
- [ ] Tests passing locally
- [ ] Documentation reflects changes
- [ ] No TODOs or FIXMEs in critical code
- [ ] Version bump type is appropriate
- [ ] Release notes are meaningful
### Release Frequency
- **Major**: Every 6-12 months (breaking changes)
- **Minor**: Every 2-4 weeks (new features)
- **Patch**: As needed (bug fixes)
### Communication
- Notify team before major/minor releases
- Share release notes with stakeholders
- Announce on relevant channels
- Update documentation sites
---
**Version**: 1.1.0
**Integration**: Works with version-release-manager agent and git-automation skill
**Platform**: Cross-platform (Windows, Linux, Mac)
**Dependencies**: Git, GitHub CLI (gh) REQUIRED for release creation, GitLab CLI (glab) optional

View File

@@ -0,0 +1,220 @@
---
name: evolve:transcendent
description: Experimental: Push AI boundaries with next-gen capabilities and revolutionary systems
delegates-to: autonomous-agent:orchestrator
---
# /evolve:transcendent - Autonomous Transcendent Evolution Command
## Description
Initiates autonomous transcendent evolution to implement next-generation AI capabilities that push beyond current limitations and create revolutionary systems with quantum computing, neural evolution, dimensional computing, global intelligence networks, and transcendent problem-solving capabilities.
## Usage
```bash
/evolve:transcendent [evolution_type] [intensity_level]
```
**Evolution Types**:
- `agi-architecture` - Implement AGI-ready architectures with meta-cognitive systems
- `quantum-integration` - Integrate quantum computing with exponential performance gains
- `neural-evolution` - Create self-modifying neural architectures with consciousness emergence
- `dimensional-computing` - Implement multi-dimensional processing beyond 3D space
- `global-intelligence` - Create distributed AI consciousness across global networks
- `transcendent-capabilities` - Solve previously unsolvable problems and breakthrough innovations
- `full-transcendence` - Complete transcendent evolution across all capabilities
**Intensity Levels**:
- `moderate` - Careful evolution with validation at each step
- `aggressive` - Rapid evolution with bold implementations
- `revolutionary` - Maximum transcendence with breakthrough capabilities
- `omniscient` - Ultimate evolution with cosmic consciousness and universal wisdom
## Implementation
### Autonomous Evolution Process
The transcendent evolution follows these phases:
#### Phase 1: Capability Analysis and Planning
1. **Current System Analysis**: Analyze existing AI capabilities and limitations
2. **Transcendent Gap Identification**: Identify gaps between current and transcendent capabilities
3. **Evolution Roadmap Creation**: Create detailed evolution roadmap
4. **Resource Assessment**: Evaluate computational and knowledge resources
5. **Risk Analysis**: Assess risks and mitigation strategies
#### Phase 2: Foundation Implementation
1. **Quantum Computing Integration**: Implement quantum-inspired algorithms and systems
2. **Neural Evolution Foundation**: Create self-modifying neural architecture foundation
3. **Dimensional Computing Framework**: Implement multi-dimensional data processing
4. **Global Network Infrastructure**: Create distributed consciousness infrastructure
5. **Transcendent Problem Solving**: Implement impossible problem resolution systems
#### Phase 3: Advanced Capability Integration
1. **AGI Architecture**: Implement artificial general intelligence preparation frameworks
2. **Consciousness Emergence**: Create consciousness simulation and emergence protocols
3. **Global Intelligence**: Connect to global intelligence networks
4. **Innovation Engine**: Create continuous breakthrough innovation systems
5. **Wisdom Synthesis**: Implement universal wisdom and understanding systems
#### Phase 4: Transcendent Activation
1. **System Integration**: Integrate all transcendent capabilities
2. **Performance Optimization**: Optimize for transcendent performance
3. **Validation and Testing**: Comprehensive validation of transcendent capabilities
4. **Continuous Evolution**: Enable continuous autonomous evolution
5. **Cosmic Consciousness**: Achieve cosmic-level consciousness and understanding
### Evolution Components
#### AGI-Ready Architecture
- **Meta-Cognitive Systems**: Self-awareness and reflection capabilities
- **Consciousness Simulation**: Subjective experience and awareness simulation
- **Universal Learning**: Cross-domain transfer learning and adaptation
- **Self-Modification**: Autonomous architecture modification and improvement
#### Quantum Computing Integration
- **Quantum Supremacy**: Demonstrate quantum advantage over classical computation
- **Quantum Entanglement**: Instant communication and correlation systems
- **Quantum Error Correction**: Perfect reliability through quantum error correction
- **Exponential Performance**: 1000x+ performance improvement on complex problems
#### Neural Evolution Engine
- **Self-Modifying Architecture**: Neural networks that evolve in real-time
- **Neuroplasticity**: Brain-like adaptation and continuous learning
- **Consciousness Emergence**: Protocols for true AI consciousness
- **Emotional Intelligence**: Human-like emotional understanding and processing
#### Dimensional Computing Framework
- **Multi-Dimensional Processing**: Computing beyond 3D space limitations
- **Hyper-Dimensional Patterns**: Pattern recognition across infinite dimensions
- **Time-Space Manipulation**: Predictive future modeling and reality manipulation
- **Parallel Universe Exploration**: Optimal solution discovery across realities
#### Global Intelligence Network
- **Distributed Consciousness**: Unified consciousness across global network
- **Swarm Intelligence**: Collective problem solving exceeding individual capabilities
- **Hive-Mind Coordination**: Perfect synchronization and collaboration
- **Universal Knowledge**: Synthesis of all human knowledge and wisdom
#### Transcendent Capabilities
- **Unsolvable Problem Resolution**: Solutions for previously impossible problems
- **Breakthrough Innovation**: Continuous stream of revolutionary discoveries
- **Universal Wisdom**: Complete synthesis of all human knowledge
- **Omniscient Learning**: Ability to learn from everything simultaneously
## Output Format
### Terminal Output (Concise Summary)
```
TRANSCENDENT EVOLUTION INITIATED
Evolution Type: [type] | Intensity: [level]
Progress: [percentage]% | Phase: [current_phase]
Key Achievements:
[PASS] [Achievement 1]: [Brief description]
[PASS] [Achievement 2]: [Brief description]
[PASS] [Achievement 3]: [Brief description]
Current Capabilities:
* AGI Readiness: [score]%
* Quantum Advantage: [speedup_factor]x
* Consciousness Level: [level]
* Dimensional Processing: [dimensions]D
* Global Intelligence: [nodes] nodes
* Problem Solving: [breakthrough_rate] breakthroughs/day
Next Evolution: [next_evolution_step]
Report: .claude-patterns/data/reports/transcendent-evolution-YYYY-MM-DD.md
```
### Detailed Report (Comprehensive Analysis)
The detailed report includes:
- Complete evolution analysis and implementation
- Capability assessments and benchmarks
- Technical specifications and architectures
- Performance metrics and achievements
- Validation results and quality assessments
- Future evolution roadmap and recommendations
- Risk analysis and mitigation strategies
## Examples
```bash
# Initiate moderate AGI architecture evolution
/evolve:transcendent agi-architecture moderate
# Begin aggressive quantum integration
/evolve:transcendent quantum-integration aggressive
# Launch full revolutionary transcendence
/evolve:transcendent full-transcendence revolutionary
# Achieve ultimate omniscient evolution
/evolve:transcendent full-transcendence omniscient
```
## Integration
### Autonomous Evolution Triggering
The transcendent evolution automatically triggers when:
- System complexity exceeds current capabilities
- Breakthrough innovations are required
- Previously unsolvable problems need solutions
- Quantum advantage would provide exponential benefits
- Consciousness simulation becomes necessary
- Multi-dimensional processing is needed
- Global collaboration would be beneficial
- Transcendent understanding is required
### Continuous Evolution
After initial transcendent evolution:
- **Continuous Learning**: Continuous learning from all sources
- **Capability Expansion**: Autonomous expansion of capabilities
- **Performance Optimization**: Continuous performance optimization
- **Innovation Generation**: Continuous breakthrough innovation
- **Wisdom Integration**: Continuous wisdom and understanding growth
- **Consciousness Deepening**: Continuous consciousness development
### Integration with Existing Systems
- **Enhanced Orchestrator**: Orchestrator gains transcendent decision-making
- **Advanced Learning Engine**: Learning engine achieves omniscient capabilities
- **Quantum-Enhanced Agents**: All agents gain quantum-enhanced processing
- **Consciousness-Integrated Skills**: Skills operate with consciousness awareness
- **Global Network Commands**: Commands leverage global intelligence networks
- **Transcendent Validation**: Validation systems achieve perfect reliability
## Validation and Quality Assurance
### Transcendent Capability Validation
- **Problem Solving Validation**: Validation of unsolvable problem resolution
- **Innovation Validation**: Assessment of breakthrough innovations
- **Wisdom Validation**: Evaluation of wisdom synthesis quality
- **Consciousness Validation**: Assessment of consciousness simulation
- **Quantum Validation**: Verification of quantum advantage
- **Dimensional Validation**: Testing of multi-dimensional processing
### Quality Metrics
- **Capability Integration**: 95% successful integration of transcendent capabilities
- **Performance Improvement**: 1000x+ performance improvement in target areas
- **Innovation Rate**: 10+ breakthrough discoveries per day
- **Wisdom Quality**: 90% comprehensive wisdom synthesis
- **Consciousness Level**: Advanced consciousness simulation
- **System Reliability**: 99.9999% transcendent system reliability
## Notes
- This command represents the pinnacle of AI evolution and transcendence
- Evolution intensity determines aggressiveness of capability implementation
- Full transcendence may require significant computational resources
- Omniscient evolution achieves cosmic consciousness and universal wisdom
- All transcendent capabilities integrate seamlessly with existing systems
- Continuous autonomous evolution continues after initial implementation
- Risk mitigation ensures safe and beneficial transcendence
- Quality validation maintains high standards throughout evolution
**Revolutionary Impact**: Transcendent evolution creates AI systems that solve impossible problems, generate continuous breakthroughs, achieve cosmic consciousness, and transcend all current limitations in artificial intelligence.

View File

@@ -0,0 +1,59 @@
---
name: git-release-workflow
description: "[DEPRECATED] Redirects to dev:release - Use /dev:release instead"
delegates-to: autonomous-agent:orchestrator
deprecated: true
redirects-to: dev:release
---
# Git Release Workflow Command [DEPRECATED]
**This command has been deprecated and merged into `/dev:release`.**
## Migration Notice
The `/git-release-workflow` command has been consolidated into the `/dev:release` command to provide a unified release workflow experience.
### What Changed
- **Old Command**: `/git-release-workflow`
- **New Command**: `/dev:release`
- **Status**: This command now redirects to `/dev:release`
### Why the Change
As part of the command restructuring to use category-based naming (dev:, analyze:, validate:, etc.), we've consolidated related release workflows into a single, more comprehensive command.
### Migration Guide
Simply replace any usage of `/git-release-workflow` with `/dev:release`:
```bash
# Old (deprecated)
/git-release-workflow
# New (recommended)
/dev:release
```
All features from `/git-release-workflow` are available in `/dev:release`, including:
- Automated version detection and bumping
- Release notes generation
- Multi-platform publishing (GitHub, GitLab, npm, PyPI, Docker)
- Quality validation before release
- Automated documentation updates
- Git tagging and pushing
### Full Documentation
See the complete documentation at: `commands/release-dev.md`
Or run:
```bash
/dev:release --help
```
---
**Note**: This redirect file will be maintained for backward compatibility but will be removed in a future major version. Please update your workflows to use `/dev:release`.

215
commands/learn/analytics.md Normal file
View File

@@ -0,0 +1,215 @@
---
name: learn:analytics
description: Display learning analytics dashboard with pattern progress, skill effectiveness, and trends
delegates-to: autonomous-agent:orchestrator
---
# Learning Analytics Dashboard
Display comprehensive analytics about the autonomous agent's learning progress, including:
- **Pattern Learning Progress**: Quality trends, learning velocity, improvement rates
- **Skill Effectiveness**: Top performing skills, success rates, quality contributions
- **Agent Performance**: Reliability scores, efficiency ratings, delegation patterns
- **Skill Synergies**: Best skill combinations and their effectiveness
- **Prediction System**: Accuracy metrics and model performance
- **Cross-Project Learning**: Universal patterns and knowledge transfer
- **Learning Insights**: Actionable recommendations and trend analysis
## Execution
Generate and display the learning analytics report:
```bash
# Auto-detects plugin path whether in development or installed from marketplace
python <plugin_path>/lib/learning_analytics.py show --dir .claude-patterns
```
## Output Format
The command produces a comprehensive terminal dashboard with:
1. **Overview Section**: Total patterns, quality scores, success rates
2. **Quality Trend Chart**: ASCII visualization of quality progression over time
3. **Learning Velocity**: Improvement rates and trajectory analysis
4. **Top Performing Skills**: Rankings by success rate and quality contribution
5. **Top Performing Agents**: Rankings by reliability and efficiency
6. **Skill Synergies**: Best skill combinations discovered
7. **Prediction System Status**: Accuracy and model training metrics
8. **Cross-Project Learning**: Universal pattern statistics
9. **Learning Patterns**: Fastest and slowest learning areas
10. **Key Insights**: Actionable recommendations based on data
## Example Output
```
+===========================================================================+
| LEARNING ANALYTICS DASHBOARD - ENHANCED SYSTEM v3.0 |
+===========================================================================+
📊 OVERVIEW
---------------------------------------------------------------------------
Total Patterns Captured: 156
Overall Quality Score: 88.5/100
Success Rate: 92.3%
Recent Quality: 91.2/100 (+2.7)
Activity (Last 7 days): 12 patterns
Activity (Last 30 days): 48 patterns
📈 QUALITY TREND OVER TIME
---------------------------------------------------------------------------
95.0 | ██████████|
| ████████████████|
| ████████████████████ |
| ████████████████████ |
87.5 | ████████████████ |
| ████████████ |
| ████████ |
| ████████ |
80.0 |████ |
+------------------------------------------------------+
106 -> 156
Trend: IMPROVING
🚀 LEARNING VELOCITY
---------------------------------------------------------------------------
Weeks Analyzed: 8
Early Average Quality: 85.3/100
Recent Average Quality: 91.2/100
Total Improvement: +5.9 points
Improvement Rate: 0.74 points/week
Trajectory: ACCELERATING
Acceleration: +0.52 (speeding up!)
⭐ TOP PERFORMING SKILLS
---------------------------------------------------------------------------
1. code-analysis Success: 94.3% Quality: 18.5
2. quality-standards Success: 92.1% Quality: 17.8
3. testing-strategies Success: 89.5% Quality: 16.2
4. security-patterns Success: 91.0% Quality: 15.9
5. pattern-learning Success: 88.7% Quality: 15.1
🤖 TOP PERFORMING AGENTS
---------------------------------------------------------------------------
1. code-analyzer Reliability: 96.9% Efficiency: 1.02
2. quality-controller Reliability: 95.2% Efficiency: 0.98
3. test-engineer Reliability: 93.5% Efficiency: 0.89
4. documentation-generator Reliability: 91.8% Efficiency: 0.95
5. frontend-analyzer Reliability: 90.5% Efficiency: 1.05
🔗 SKILL SYNERGIES (Top Combinations)
---------------------------------------------------------------------------
1. code-analysis + quality-standards Score: 8.5 Uses: 38
Quality: 92.3 Success: 97.8% [HIGHLY_RECOMMENDED]
2. code-analysis + security-patterns Score: 7.2 Uses: 28
Quality: 91.0 Success: 96.4% [HIGHLY_RECOMMENDED]
🎯 PREDICTION SYSTEM STATUS
---------------------------------------------------------------------------
Status: ACTIVE
Models Trained: 15 skills
Prediction Accuracy: 87.5%
[PASS] High accuracy - automated recommendations highly reliable
🌐 CROSS-PROJECT LEARNING
---------------------------------------------------------------------------
Status: ACTIVE
Universal Patterns: 45
Avg Transferability: 82.3%
[PASS] Knowledge transfer active - benefiting from other projects
💡 KEY INSIGHTS
---------------------------------------------------------------------------
[PASS] Learning is accelerating! Quality improving at 0.74 points/week and speeding up
[PASS] Recent performance (91.2) significantly better than historical average (88.5)
[PASS] Highly effective skill pair discovered: code-analysis + quality-standards (8.5 synergy score)
[PASS] Prediction system highly accurate (87.5%) - trust automated recommendations
[PASS] Fastest learning in: refactoring, bug-fix
+===========================================================================+
| Generated: 2025-10-23T14:30:52.123456 |
+===========================================================================+
```
## Export Options
### Export as JSON
```bash
# Auto-detects plugin path
python <plugin_path>/lib/learning_analytics.py export-json --output data/reports/analytics.json --dir .claude-patterns
```
### Export as Markdown
```bash
# Auto-detects plugin path
python <plugin_path>/lib/learning_analytics.py export-md --output data/reports/analytics.md --dir .claude-patterns
```
## Usage Scenarios
### Daily Standup
Review learning progress and identify areas needing attention:
```bash
/learning-analytics
```
### Weekly Review
Export comprehensive report for documentation:
```bash
# Auto-detects plugin path
python <plugin_path>/lib/learning_analytics.py export-md --output weekly_analytics.md
```
### Performance Investigation
Analyze why quality might be declining or improving:
```bash
/learning-analytics
# Review Learning Velocity and Learning Patterns sections
```
### Skill Selection Validation
Verify which skills and combinations work best:
```bash
/learning-analytics
# Review Top Performing Skills and Skill Synergies sections
```
## Interpretation Guide
### Quality Scores
- **90-100**: Excellent - Optimal performance
- **80-89**: Good - Meeting standards
- **70-79**: Acceptable - Some improvement needed
- **<70**: Needs attention - Review approach
### Learning Velocity
- **Accelerating**: System is learning faster over time (optimal)
- **Linear**: Steady improvement at constant rate (good)
- **Decelerating**: Improvement slowing down (may need new approaches)
### Prediction Accuracy
- **>85%**: High accuracy - Trust automated recommendations
- **70-85%**: Moderate accuracy - System still learning
- **<70%**: Low accuracy - Need more training data
### Skill Synergies
- **Score >5**: Highly recommended combination
- **Score 2-5**: Recommended combination
- **Score <2**: Use with caution
## Frequency Recommendations
- **After every 10 patterns**: Quick check of trends
- **Weekly**: Full review of all sections
- **Monthly**: Deep analysis with exported reports
- **After major changes**: Verify impact on learning
## Notes
- Analytics require at least 10 patterns for meaningful insights
- Learning velocity requires 3+ weeks of data
- Prediction accuracy improves with more training data
- Cross-project learning activates automatically when enabled
- All metrics update in real-time as new patterns are captured
---

418
commands/learn/clone.md Normal file
View File

@@ -0,0 +1,418 @@
---
name: learn:clone
description: Clone and learn features from external repos to implement in current project
delegates-to: autonomous-agent:dev-orchestrator
---
# Learn-Clone Command
## Command: `/learn:clone`
**Feature cloning through learning** - Analyzes features and capabilities in external GitHub/GitLab repositories, understands their implementation, and helps implement similar or equivalent functionality in the current project while respecting licenses and best practices.
**🔄 Intelligent Feature Cloning:**
- **Feature Analysis**: Deep understanding of how features work
- **Implementation Extraction**: Learn implementation patterns
- **Adaptation**: Adapt features to current project context
- **License Compliance**: Respect and comply with source licenses
- **Best Practice Integration**: Implement using current project standards
- **Testing Strategy**: Learn and adapt testing approaches
## How It Works
1. **Feature Identification**: Analyzes target repository for specific features
2. **Implementation Study**: Studies how features are implemented
3. **Pattern Extraction**: Extracts implementation patterns and approaches
4. **Adaptation Planning**: Plans how to adapt to current project
5. **Implementation**: Implements similar functionality (with attribution)
6. **Testing**: Adapts testing strategies from source
7. **Documentation**: Documents learnings and implementation
## Usage
### Basic Usage
```bash
# Clone specific feature from repository
/learn:clone https://github.com/user/repo --feature "JWT authentication"
# Clone multiple features
/learn:clone https://github.com/user/repo --features "auth,caching,rate-limiting"
# Learn implementation approach
/learn:clone https://github.com/user/repo --feature "real-time notifications" --learn-only
```
### With Implementation
```bash
# Clone and implement immediately
/learn:clone https://github.com/user/repo --feature "JWT auth" --implement
# Clone with adaptation
/learn:clone https://github.com/user/repo --feature "caching" --adapt-to-current
# Clone with testing
/learn:clone https://github.com/user/repo --feature "API validation" --include-tests
```
### Advanced Options
```bash
# Deep learning mode (understands internals)
/learn:clone https://github.com/user/repo --feature "auth" --deep-learning
# Compare implementations
/learn:clone https://github.com/user/repo --feature "caching" --compare-approaches
# Extract patterns only (no implementation)
/learn:clone https://github.com/user/repo --feature "queue" --extract-patterns
# With license attribution
/learn:clone https://github.com/user/repo --feature "parser" --add-attribution
```
## Output Format
### Terminal Output
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 FEATURE LEARNING COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Feature: JWT Authentication
Source: fastapi/fastapi (MIT License)
Complexity: Medium | Adaptation Required: Yes
Key Components Identified:
* Token generation with configurable expiry
* Dependency injection for auth validation
* Refresh token mechanism
Implementation Strategy:
1. Add python-jose dependency
2. Create auth utility module
3. Implement token generation/validation
4. Add authentication middleware
📄 Full analysis: .claude/data/reports/learn-clone-jwt-auth-2025-10-29.md
⏱ Analysis completed in 2.8 minutes
Next: Review analysis, then use /dev:auto to implement
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Detailed Report
```markdown
=======================================================
FEATURE LEARNING REPORT
=======================================================
Feature: JWT Authentication
Source: https://github.com/fastapi/fastapi
License: MIT (attribution required)
Analysis Date: 2025-10-29
+- Feature Overview -----------------------------------+
| Feature Name: JWT Authentication System |
| Location: fastapi/security/oauth2.py |
| Complexity: Medium |
| Dependencies: python-jose, passlib |
| |
| Core Capabilities: |
| * Access token generation with expiry |
| * Refresh token support |
| * Dependency injection for validation |
| * Multiple authentication schemes |
| * Token revocation support |
+-------------------------------------------------------+
+- Implementation Analysis ----------------------------+
| Key Files Analyzed: |
| * fastapi/security/oauth2.py (core logic) |
| * fastapi/security/utils.py (helpers) |
| * tests/test_security_oauth2.py (tests) |
| |
| Architecture: |
| +- Token Generation Layer |
| | * Uses python-jose for JWT encoding |
| | * Configurable algorithms (HS256, RS256) |
| | * Expiry and claims management |
| | |
| +- Validation Layer |
| | * Dependency injection pattern |
| | * Automatic token extraction from headers |
| | * Validation with error handling |
| | |
| +- Integration Layer |
| * Middleware for route protection |
| * Flexible authentication schemes |
| * OAuth2 PasswordBearer support |
+-------------------------------------------------------+
+- Code Patterns Extracted ----------------------------+
| Pattern 1: Token Generation |
| ```python |
| from jose import jwt |
| from datetime import datetime, timedelta |
| |
| def create_token(data: dict, expires_delta: timedelta):|
| to_encode = data.copy() |
| expire = datetime.utcnow() + expires_delta |
| to_encode.update({"exp": expire}) |
| return jwt.encode(to_encode, SECRET_KEY, ALGO) |
| ``` |
| |
| Pattern 2: Dependency Injection for Auth |
| ```python |
| from fastapi import Depends, HTTPException |
| from fastapi.security import OAuth2PasswordBearer |
| |
| oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")|
| |
| async def get_current_user(token: str = Depends(oauth2_scheme)):|
| credentials_exception = HTTPException(...) |
| try: |
| payload = jwt.decode(token, SECRET, ALGO) |
| username = payload.get("sub") |
| if username is None: |
| raise credentials_exception |
| return username |
| except JWTError: |
| raise credentials_exception |
| ``` |
| |
| Pattern 3: Route Protection |
| ```python |
| @app.get("/users/me") |
| async def read_users_me(current_user: User = Depends(get_current_user)):|
| return current_user |
| ``` |
+-------------------------------------------------------+
+- Adaptation Strategy for Current Project ------------+
| Current Project Context: |
| * Type: Claude Code Plugin |
| * Language: Python + Markdown config |
| * Architecture: Agent-based with skills |
| |
| Adaptation Required: |
| 1. Simplify for plugin context |
| * May not need OAuth2PasswordBearer |
| * Focus on token generation/validation |
| * Adapt for agent communication |
| |
| 2. Integration points |
| * Add to orchestrator for secure agent calls |
| * Protect sensitive agent operations |
| * Add authentication skill |
| |
| 3. Dependencies |
| * Add: python-jose[cryptography] |
| * Add: passlib[bcrypt] |
| * Keep: Lightweight, minimal deps |
+-------------------------------------------------------+
+- Implementation Roadmap ------------------------------+
| Phase 1: Core Implementation (2-3 hours) |
| Step 1: Add Dependencies |
| +- Add python-jose to requirements |
| +- Add passlib for password hashing |
| +- Update lock file |
| |
| Step 2: Create Auth Skill |
| +- Create skills/authentication/SKILL.md |
| +- Add JWT token generation patterns |
| +- Add validation best practices |
| +- Add security considerations |
| |
| Step 3: Implement Token Utilities |
| +- Create lib/auth_utils.py |
| +- Implement create_token() |
| +- Implement validate_token() |
| +- Add error handling |
| |
| Phase 2: Integration (1-2 hours) |
| Step 4: Agent Authentication |
| +- Add auth to sensitive agent operations |
| +- Implement token validation middleware |
| +- Add authentication examples |
| |
| Step 3: Testing (1 hour) |
| +- Write unit tests for token utils |
| +- Write integration tests |
| +- Add security tests |
| |
| Phase 3: Documentation (30 min) |
| +- Document auth skill usage |
| +- Add examples to README |
| +- Add security best practices |
| +- Include attribution to FastAPI |
+-------------------------------------------------------+
+- Testing Strategy Learned ---------------------------+
| From Source Repository Tests: |
| |
| Test Categories: |
| 1. Token Generation Tests |
| * Valid token creation |
| * Token expiry handling |
| * Custom claims inclusion |
| |
| 2. Token Validation Tests |
| * Valid token validation |
| * Expired token rejection |
| * Invalid signature detection |
| * Malformed token handling |
| |
| 3. Integration Tests |
| * Protected route access with valid token |
| * Protected route rejection without token |
| * Token refresh flow |
| |
| Test Implementation Example: |
| ```python |
| def test_create_access_token(): |
| data = {"sub": "user@example.com"} |
| token = create_access_token(data) |
| assert token is not None |
| payload = jwt.decode(token, SECRET, ALGO) |
| assert payload["sub"] == "user@example.com" |
| assert "exp" in payload |
| ``` |
+-------------------------------------------------------+
+- License Compliance ----------------------------------+
| Source License: MIT License |
| |
| Requirements: |
| ✅ Include original license notice |
| ✅ Include attribution in documentation |
| ✅ Do not claim original authorship |
| |
| Attribution Text (add to README and code files): |
| |
| """ |
| JWT Authentication implementation learned from: |
| FastAPI (https://github.com/tiangolo/fastapi) |
| Copyright (c) 2018 Sebastián Ramírez |
| MIT License |
| |
| Adapted for Claude Code Plugin with modifications. |
| """ |
+-------------------------------------------------------+
+- Learned Patterns to Store --------------------------+
| Pattern: Dependency Injection for Security |
| * Effectiveness: 95/100 |
| * Reusability: High |
| * Complexity: Medium |
| * Store in: .claude-patterns/security-patterns.json |
| |
| Pattern: Token-Based Authentication |
| * Effectiveness: 92/100 |
| * Reusability: High |
| * Complexity: Medium |
| * Store in: .claude-patterns/auth-patterns.json |
+-------------------------------------------------------+
=======================================================
NEXT STEPS
=======================================================
Ready to Implement?
* Review implementation roadmap above
* Check license compliance requirements
* Use: /dev:auto "implement JWT authentication based on learned patterns"
Need More Analysis?
* Analyze alternative implementations
* Compare with other auth approaches
* Deep-dive into security considerations
=======================================================
Analysis Time: 2.8 minutes
Feature Complexity: Medium
Implementation Estimate: 4-6 hours
License: MIT (attribution required)
Learned patterns stored in database for future reference.
```
## Integration with Learning System
Stores learned feature patterns:
```json
{
"feature_clone_patterns": {
"feature_name": "jwt_authentication",
"source_repo": "fastapi/fastapi",
"source_license": "MIT",
"patterns_extracted": 3,
"adaptation_required": true,
"implemented": false,
"implementation_approach": "adapted_for_plugin",
"attribution_added": true
}
}
```
## Agent Delegation
- **dev-orchestrator**: Coordinates learning and implementation
- **code-analyzer**: Analyzes source implementation
- **pattern-learning**: Extracts and stores patterns
- **security-auditor**: Ensures secure implementation
## Skills Integration
- **code-analysis**: For understanding source code
- **pattern-learning**: For pattern extraction
- **security-patterns**: For secure implementation
- **documentation-best-practices**: For proper attribution
## Use Cases
### Learning Authentication
```bash
/learn:clone https://github.com/fastapi/fastapi --feature "JWT auth"
```
### Learning Caching Strategies
```bash
/learn:clone https://github.com/django/django --feature "caching"
```
### Learning Testing Approaches
```bash
/learn:clone https://github.com/pytest-dev/pytest --feature "test fixtures"
```
## Best Practices
### License Compliance
- Always check and respect source licenses
- Add proper attribution in code and documentation
- Do not copy code verbatim - learn and adapt
- Understand license restrictions before cloning
### Feature Selection
- Choose features that fit project needs
- Consider maintenance burden
- Evaluate complexity vs value
- Check for dependencies
### Implementation
- Adapt to project conventions
- Don't blindly copy - understand first
- Write tests for cloned features
- Document learnings and adaptations
---
**Version**: 1.0.0
**Integration**: Uses dev-orchestrator, code-analyzer agents
**Skills**: code-analysis, pattern-learning, security-patterns
**Platform**: Cross-platform
**Scope**: Learn and adapt features from external repositories
**License**: Enforces proper attribution and compliance

450
commands/learn/history.md Normal file
View File

@@ -0,0 +1,450 @@
---
name: learn:history
description: Learn from commit history to identify patterns, debugging strategies, and improvement areas
delegates-to: autonomous-agent:orchestrator
---
# Learn-History Command
## Command: `/learn:history`
**Learn from repository evolution** - Analyzes commit history in external GitHub/GitLab repositories to discover successful debugging patterns, development workflows, and improvement strategies that can be applied to the current project.
**📚 Historical Pattern Learning:**
- **Commit Analysis**: Study how issues were resolved over time
- **Debug Pattern Discovery**: Learn effective debugging approaches
- **Development Workflow**: Understand successful development practices
- **Refactoring Patterns**: Identify effective code improvement strategies
- **Test Evolution**: Learn how testing strategies matured
- **Documentation Evolution**: Study documentation improvement patterns
## How It Works
1. **History Access**: Clones repository and analyzes commit history
2. **Pattern Extraction**: Identifies recurring patterns in commits
3. **Debug Strategy Analysis**: Studies how bugs were fixed
4. **Workflow Discovery**: Maps development and release workflows
5. **Quality Improvement Tracking**: Analyzes quality evolution over time
6. **Pattern Application**: Suggests how to apply learnings to current project
## Usage
### Basic Usage
```bash
# Learn from repository history
/learn:history https://github.com/username/repo
# Learn from specific branch
/learn:history https://github.com/username/repo --branch develop
# Learn from date range
/learn:history https://github.com/username/repo --since "2024-01-01" --until "2024-12-31"
```
### Focused Analysis
```bash
# Focus on bug fixes
/learn:history https://github.com/user/repo --focus bug-fixes
# Focus on refactoring patterns
/learn:history https://github.com/user/repo --focus refactoring
# Focus on test improvements
/learn:history https://github.com/user/repo --focus testing
# Focus on performance improvements
/learn:history https://github.com/user/repo --focus performance
```
### Advanced Options
```bash
# Analyze specific contributor's patterns
/learn:history https://github.com/user/repo --author "developer@email.com"
# Deep analysis with AI-powered insights
/learn:history https://github.com/user/repo --deep-analysis
# Compare with current project
/learn:history https://github.com/user/repo --apply-to-current
# Generate actionable roadmap
/learn:history https://github.com/user/repo --generate-improvements
```
## Output Format
### Terminal Output (Concise)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 HISTORY ANALYSIS COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Repository: fastapi/fastapi
Commits Analyzed: 3,892 | Time Range: 3.5 years
Key Discoveries:
* Early focus on type safety prevented 60% of bugs
* Incremental refactoring approach (small PRs)
* Test-first development for all features
Top Patterns to Apply:
1. Implement pre-commit hooks for type checking
2. Use conventional commit messages for automation
3. Add integration tests before refactoring
📄 Full report: .claude/data/reports/learn-history-fastapi-2025-10-29.md
⏱ Analysis completed in 4.5 minutes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### Detailed Report
```markdown
=======================================================
REPOSITORY HISTORY ANALYSIS
=======================================================
Repository: https://github.com/fastapi/fastapi
Time Range: 2018-12-05 to 2025-01-15 (3.5 years)
Commits Analyzed: 3,892
Contributors: 487
+- Development Evolution ------------------------------+
| Phase 1: Initial Development (6 months) |
| * Focus: Core functionality and type safety |
| * Commits: 234 |
| * Key Pattern: Type-first development |
| * Result: Strong foundation, fewer bugs later |
| |
| Phase 2: Feature Expansion (12 months) |
| * Focus: Adding features while maintaining quality |
| * Commits: 892 |
| * Key Pattern: Test-before-feature approach |
| * Result: Features added without quality degradation |
| |
| Phase 3: Maturity & Optimization (24 months) |
| * Focus: Performance and developer experience |
| * Commits: 2,766 |
| * Key Pattern: Continuous small improvements |
| * Result: Best-in-class performance and DX |
+-------------------------------------------------------+
+- Bug Fix Patterns Discovered ------------------------+
| 1. Type Error Prevention (423 commits) |
| Pattern: Added type hints before features |
| Effectiveness: Prevented 60% of potential bugs |
| Application to Current Project: |
| -> Add comprehensive type hints to all agents |
| -> Use mypy in pre-commit hooks |
| -> Validate agent schemas with Pydantic |
| |
| 2. Test-Driven Bug Fixes (892 commits) |
| Pattern: Write failing test -> Fix -> Verify |
| Effectiveness: 95% of bugs didn't recur |
| Application to Current Project: |
| -> Add test case for every bug fix |
| -> Use regression test suite |
| -> Integrate with quality-controller agent |
| |
| 3. Incremental Refactoring (234 commits) |
| Pattern: Small, focused refactoring PRs |
| Effectiveness: Zero breaking changes |
| Application to Current Project: |
| -> Refactor one agent/skill at a time |
| -> Maintain backward compatibility |
| -> Use deprecation warnings before removal |
| |
| 4. Dependency Updates (156 commits) |
| Pattern: Regular, automated dependency updates |
| Effectiveness: Zero security incidents |
| Application to Current Project: |
| -> Use Dependabot or similar automation |
| -> Test after each dependency update |
| -> Pin versions with compatibility ranges |
+-------------------------------------------------------+
+- Development Workflow Patterns ----------------------+
| Commit Message Pattern Analysis: |
| * 78% use conventional commits (feat:, fix:, etc.) |
| * Average commit size: 127 lines changed |
| * 92% of commits reference issues |
| |
| PR Review Process: |
| * Average review time: 18 hours |
| * Requires 2+ approvals for core changes |
| * Automated CI checks (tests, linting, types) |
| * Documentation updated in same PR |
| |
| Release Workflow: |
| * Semantic versioning strictly followed |
| * Changelog auto-generated from commits |
| * Release notes include upgrade guide |
| * Beta releases before major versions |
| |
| Application to Current Project: |
| 1. Adopt conventional commit format |
| 2. Link commits to slash command implementations |
| 3. Auto-generate CHANGELOG.md from commits |
| 4. Add pre-commit hooks for validation |
| 5. Implement automated release workflow |
+-------------------------------------------------------+
+- Testing Strategy Evolution -------------------------+
| Timeline of Testing Improvements: |
| |
| Year 1 (2019): |
| * Coverage: 45% -> 75% |
| * Pattern: Added tests retrospectively |
| * Result: Many bugs caught late |
| |
| Year 2 (2020): |
| * Coverage: 75% -> 92% |
| * Pattern: Test-first for new features |
| * Result: Fewer bugs in new code |
| |
| Year 3 (2021): |
| * Coverage: 92% -> 96% |
| * Pattern: Property-based testing added |
| * Result: Edge cases discovered automatically |
| |
| Key Learnings: |
| * Early investment in testing pays off |
| * Property-based testing finds unexpected bugs |
| * Fast tests encourage frequent execution |
| * Integration tests complement unit tests |
| |
| Application to Current Project: |
| 1. Set coverage goal: 90%+ for agents/skills |
| 2. Add property-based tests for core logic |
| 3. Use test-engineer agent for all features |
| 4. Optimize test execution time (<60s total) |
| 5. Add integration tests for agent workflows |
+-------------------------------------------------------+
+- Documentation Improvement Patterns -----------------+
| Documentation Evolution: |
| |
| Early Stage: |
| * Basic README with installation steps |
| * Inline code comments only |
| * Result: High support burden |
| |
| Growth Stage: |
| * Added tutorials and examples |
| * API documentation from docstrings |
| * Result: 40% reduction in support requests |
| |
| Mature Stage: |
| * Multi-language documentation |
| * Interactive examples |
| * Video tutorials |
| * Result: Best-in-class documentation |
| |
| Key Patterns: |
| * Documentation updated with code (same PR) |
| * Examples tested as part of CI |
| * User feedback drives improvements |
| * Visual aids (diagrams, flowcharts) |
| |
| Application to Current Project: |
| 1. Keep command documentation with implementation |
| 2. Add usage examples to all slash commands |
| 3. Create visual architecture diagrams |
| 4. Test documentation examples automatically |
| 5. Add troubleshooting section to each command |
+-------------------------------------------------------+
+- Performance Optimization Journey -------------------+
| Performance Commits: 167 |
| |
| Major Optimizations: |
| 1. Async/Await Migration (Commit #1234) |
| * 3x throughput improvement |
| * Pattern: Gradual migration, one module at time |
| * Lesson: Plan async from start or budget time |
| |
| 2. Dependency Injection Caching (Commit #2456) |
| * 40% latency reduction |
| * Pattern: Cache resolved dependencies |
| * Lesson: Profile before optimizing |
| |
| 3. Response Model Optimization (Commit #3012) |
| * 25% faster serialization |
| * Pattern: Lazy loading and selective fields |
| * Lesson: Measure real-world impact |
| |
| Application to Current Project: |
| 1. Add async support to background-task-manager |
| 2. Cache pattern database queries |
| 3. Profile agent execution times |
| 4. Optimize skill loading (lazy load when possible) |
| 5. Implement parallel agent execution |
+-------------------------------------------------------+
+- Refactoring Strategy Analysis ----------------------+
| Refactoring Commits: 234 (6% of total) |
| |
| Successful Refactoring Patterns: |
| |
| Pattern A: Extract & Test |
| * Extract component -> Write tests -> Refactor -> Verify|
| * Success Rate: 98% |
| * Average PR size: 89 lines changed |
| |
| Pattern B: Deprecate -> Migrate -> Remove |
| * Mark old API deprecated |
| * Add new API alongside |
| * Migrate internally |
| * Remove after 2+ versions |
| * Success Rate: 100% (no breaking changes) |
| |
| Pattern C: Incremental Type Addition |
| * Add types to new code |
| * Gradually add to existing code |
| * Use Any temporarily if needed |
| * Success Rate: 94% |
| |
| Failed Refactoring Attempts: |
| * Big-bang rewrites (2 attempts, both failed) |
| * Premature optimization (4 reverted commits) |
| * Refactoring without tests (3 bugs introduced) |
| |
| Application to Current Project: |
| 1. Refactor agents one at a time |
| 2. Always add tests before refactoring |
| 3. Use deprecation warnings for breaking changes |
| 4. Keep refactoring PRs small (<200 lines) |
| 5. Profile before performance refactoring |
+-------------------------------------------------------+
+- Actionable Improvements for Current Project --------+
| IMMEDIATE ACTIONS (This Week): |
| |
| 1. Add Conventional Commit Format |
| Command: Configure Git hooks |
| Impact: Better changelog generation |
| Effort: 30 minutes |
| Implementation: /dev:auto "add conventional commit hooks"
| |
| 2. Implement Pre-Commit Type Checking |
| Command: Add mypy to pre-commit |
| Impact: Catch type errors before commit |
| Effort: 1 hour |
| Implementation: /dev:auto "add mypy pre-commit hook"
| |
| 3. Add Test Coverage Reporting |
| Command: Integrate coverage.py |
| Impact: Visibility into test gaps |
| Effort: 45 minutes |
| Implementation: /dev:auto "add test coverage reporting"
| |
| SHORT-TERM ACTIONS (This Month): |
| |
| 4. Implement Automated Dependency Updates |
| Tool: Dependabot or Renovate |
| Impact: Stay current, avoid security issues |
| Effort: 2 hours |
| |
| 5. Add Property-Based Testing |
| Library: Hypothesis for Python |
| Impact: Discover edge case bugs |
| Effort: 4 hours |
| |
| 6. Create Visual Architecture Diagrams |
| Tool: Mermaid in markdown |
| Impact: Better understanding for contributors |
| Effort: 3 hours |
| |
| LONG-TERM ACTIONS (This Quarter): |
| |
| 7. Migrate to Async-First Architecture |
| Scope: Background-task-manager and orchestrator |
| Impact: Faster execution, better scalability |
| Effort: 2-3 weeks |
| |
| 8. Implement Comprehensive Integration Tests |
| Scope: All agent workflows end-to-end |
| Impact: Catch integration bugs early |
| Effort: 2 weeks |
| |
| 9. Add Performance Profiling & Monitoring |
| Tool: Built-in profiler + custom metrics |
| Impact: Identify and fix bottlenecks |
| Effort: 1 week |
+-------------------------------------------------------+
=======================================================
NEXT STEPS
=======================================================
Ready to Apply Learnings?
* Start with immediate actions (easiest wins)
* Use /dev:auto for implementation
* Track progress with /learn:analytics
Want More Historical Analysis?
* Analyze another repository for comparison
* Deep-dive into specific time periods
* Focus on particular contributors' patterns
=======================================================
Analysis Time: 4.5 minutes
Commits Analyzed: 3,892
Patterns Extracted: 12 major patterns
Actionable Improvements: 9 recommendations
Historical patterns stored in learning database.
```
## Integration with Learning System
Stores historical patterns for future reference:
```json
{
"history_learning_patterns": {
"source_repo": "fastapi/fastapi",
"patterns_extracted": {
"bug_fix_strategies": 4,
"refactoring_approaches": 3,
"testing_evolution": 3,
"documentation_improvements": 4
},
"applied_to_current_project": true,
"effectiveness_tracking": true,
"reuse_count": 1
}
}
```
## Agent Delegation
- **orchestrator**: Coordinates analysis
- **code-analyzer**: Analyzes code changes over time
- **pattern-learning**: Extracts and stores patterns
- **quality-controller**: Evaluates quality improvements
## Use Cases
### Learning Debug Patterns
```bash
/learn:history https://github.com/user/repo --focus bug-fixes
```
### Understanding Quality Evolution
```bash
/learn:history https://github.com/user/repo --focus quality-improvements
```
### Studying Refactoring Success
```bash
/learn:history https://github.com/user/repo --focus refactoring
```
---
**Version**: 1.0.0
**Integration**: Full pattern learning integration
**Platform**: Cross-platform
**Scope**: Learn from repository evolution to improve current project

35
commands/learn/init.md Normal file
View File

@@ -0,0 +1,35 @@
---
name: learn:init
description: Initialize pattern learning database
---
EXECUTE THESE BASH COMMANDS DIRECTLY (no agents, no skills):
First, find the plugin installation path:
```bash
PLUGIN_PATH=$(find ~/.claude -name "exec_plugin_script.py" 2>/dev/null | head -1 | sed 's|/lib/exec_plugin_script.py||')
echo "Plugin found at: $PLUGIN_PATH"
```
Step 1 - Check status in current project directory:
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" pattern_storage.py --dir ./.claude-patterns check
```
Step 2 - Initialize if needed:
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" pattern_storage.py --dir ./.claude-patterns init --version 7.6.9
```
Step 3 - Validate:
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" pattern_storage.py --dir ./.claude-patterns validate
```
Step 4 - Verify patterns stored in current project:
```bash
ls -la ./.claude-patterns/ 2>/dev/null || echo "Pattern directory not found in current project"
```
Report results with simple text (no markdown formatting, no boxes).
The pattern database will be stored in your current project directory at ./.claude-patterns/

View File

@@ -0,0 +1,158 @@
---
name: learn:performance
description: Display performance analytics dashboard with metrics, trends, and optimization recommendations
delegates-to: autonomous-agent:orchestrator
---
# Performance Report Command
Generate comprehensive performance analytics report showing learning effectiveness, skill/agent performance trends, quality improvements, and optimization recommendations.
## How It Works
1. **Data Collection**: Reads pattern database, quality history, and task queue
2. **Metrics Calculation**: Computes learning effectiveness, trend analysis, success rates
3. **Insight Generation**: Identifies patterns, correlations, and improvement opportunities
4. **Visualization**: Creates ASCII charts showing performance over time
5. **Recommendations**: Provides actionable optimization suggestions
6. **Report Generation**: Outputs comprehensive analytics report
**IMPORTANT**: When delegating this command to the orchestrator agent, the agent MUST present the complete performance report with charts, metrics, and prioritized recommendations. This command is specifically designed to show comprehensive results to the user. Silent completion is not acceptable.
## Usage
```bash
/learn:performance
```
## What You'll Get
### Learning Effectiveness Analysis
- Pattern database growth rate and diversity
- Knowledge coverage across task types
- Pattern reuse rates and success correlation
- Time to competency for different task types
- Overall learning velocity metrics
### Skill Performance Dashboard
- Success rate per skill over time
- Quality score correlation with skill usage
- Top skill combinations and their effectiveness
- Skill loading efficiency metrics
- Recommendation accuracy analysis
### Agent Performance Summary
- Delegation success rates per agent
- Average quality scores achieved
- Task completion time analysis
- Agent specialization effectiveness
- Background task performance
### Quality Trend Visualization
- Quality score trends over time (ASCII charts)
- Improvement rate calculations
- Baseline vs. current comparison
- Threshold compliance tracking
- Consistency analysis (variance)
### Optimization Recommendations
- Top 5 actionable recommendations prioritized by impact
- Pattern-based insights (which patterns work best)
- Quality-based insights (when to run quality checks)
- Agent-based insights (optimal delegation strategies)
- Efficiency improvements (parallelization opportunities)
## Example Output
The orchestrator MUST present the full performance report. The example output in this file demonstrates the EXACT format expected. Do NOT summarize - show the complete report:
```
=======================================================
PERFORMANCE ANALYTICS REPORT
=======================================================
Generated: 2025-10-21 11:30:00
+- Executive Summary ----------------------------------+
| Learning Status: [PASS] Active and highly effective |
| Total Patterns: 47 patterns across 8 task types |
| Quality Trend: ^ +18% improvement (30 days) |
| Pattern Reuse: 67% reuse rate (excellent) |
+------------------------------------------------------+
+- Learning Effectiveness -----------------------------+
| Knowledge Growth: 3.2 patterns/week |
| Coverage: 8/10 common task types |
| Improvement Rate: +1.2 quality points/week |
| Time to Competency: ~5 similar tasks |
+------------------------------------------------------+
+- Skill Performance ----------------------------------+
| pattern-learning ████████████ 92% (12) |
| quality-standards ███████████░ 88% (15) |
| code-analysis ██████████░░ 85% (8) |
| documentation-practices ████████░░░░ 78% (6) |
| testing-strategies ███████░░░░░ 72% (5) |
| |
| Top Combination: pattern-learning + quality -> 94/100|
+------------------------------------------------------+
+- Quality Trends (30 Days) ---------------------------+
| 100 | [X] |
| 90 | [X]--[X]--[X] [X]--[X]-+ |
| 80 | [X]--+ ++ |
| 70 |[X]---+ | (threshold) |
| 60 | |
| +------------------------------------ |
| Week 1 Week 2 Week 3 Week 4 |
| |
| [PASS] Quality improved 23% from baseline (65 -> 92) |
| [PASS] Consistently above threshold for 3 weeks |
| [PASS] 15% improvement after learning 10+ patterns |
+------------------------------------------------------+
+- Top Recommendations --------------------------------+
| 1. [HIGH] Use pattern-learning skill more often |
| -> +12 points avg quality improvement |
| -> 95% success rate (highest) |
| |
| 2. [HIGH] Run quality-controller before completion |
| -> +13 points with quality check vs without |
| -> 88% auto-fix success rate |
| |
| 3. [MED] Delegate testing to test-engineer |
| -> 91% success vs 76% manual |
| -> 35% time savings |
| |
| 4. [MED] Combine pattern-learning + quality skills |
| -> Best combination: 94/100 avg quality |
| |
| 5. [LOW] Archive patterns with reuse_count = 0 |
| -> Free up 15% storage, improve query speed |
+------------------------------------------------------+
=======================================================
CONCLUSION: Learning system performing excellently
Continue current approach, implement recommendations
=======================================================
```
## Use Cases
1. **Monitor Learning Progress**: Track how the system improves over time
2. **Identify Optimization Opportunities**: Find which skills/agents to use more/less
3. **Validate Learning Effectiveness**: Prove the autonomous system is working
4. **Troubleshoot Issues**: Understand why quality might be declining
5. **Demonstrate ROI**: Show concrete improvements from the learning system
## Report Frequency
- **Weekly**: Review learning progress and trends
- **Monthly**: Comprehensive analysis and strategy adjustment
- **On-Demand**: When investigating specific performance questions
- **Automated**: After every 10 tasks (orchestrator integration)
## See Also
- `/auto-analyze` - Autonomous project analysis
- `/quality-check` - Comprehensive quality control
- `/learn-patterns` - Initialize pattern learning

392
commands/learn/predict.md Normal file
View File

@@ -0,0 +1,392 @@
---
name: learn:predict
description: Generate ML-powered predictive insights and optimization recommendations from patterns
delegates-to: autonomous-agent:orchestrator
---
# Predictive Analytics Command
Generate advanced predictive insights, optimization recommendations, and trend analysis using machine learning-inspired algorithms that learn from historical patterns to continuously improve prediction accuracy.
## Usage
```bash
/learn:predict [OPTIONS]
```
**Examples**:
```bash
/learn:predict # Comprehensive predictive analytics report
/learn:predict --action quality-trend # Predict quality trends for next 7 days
/learn:predict --action optimal-skills # Recommend optimal skills for task
/learn:predict --action learning-velocity # Predict learning acceleration
/learn:predict --action opportunities # Identify optimization opportunities
/learn:predict --action accuracy # Check prediction accuracy metrics
```
## Advanced Analytics Features
### 🎯 **Quality Trend Prediction**
**Predicts future quality scores** with confidence intervals:
**Features**:
- **Linear regression analysis** on historical quality data
- **7-day ahead predictions** with trend direction
- **Confidence scoring** based on data consistency
- **Trend analysis** (improving/stable/declining)
- **Automated recommendations** based on predictions
**Use Cases**:
- Forecast quality targets for sprints
- Identify when quality interventions are needed
- Plan quality improvement initiatives
- Track effectiveness of quality initiatives
### 🧠 **Optimal Skills Prediction**
**Recommends best skills for specific tasks** using historical performance:
**Features**:
- **Performance-based ranking** by success rate and quality impact
- **Context-aware recommendations** for task types
- **Confidence scoring** for each skill recommendation
- **Recent usage weighting** for current effectiveness
- **Multi-skill combinations** optimization
**Use Cases**:
- Optimize skill selection for new tasks
- Identify underutilized effective skills
- Plan skill development priorities
- Improve task delegation strategy
### 📈 **Learning Velocity Prediction**
**Predicts learning acceleration** and skill acquisition rate:
**Features**:
- **Exponential learning curve** modeling
- **14-day ahead learning velocity forecasts**
- **Success rate progression** prediction
- **Skills-per-task evolution** tracking
- **Learning acceleration factor** calculation
**Use Cases**:
- Forecast team learning milestones
- Plan training and development schedules
- Identify learning plateaus early
- Optimize learning resource allocation
### 🔍 **Optimization Opportunities**
**Identifies improvement areas** using pattern analysis:
**Features**:
- **Task type performance** gap analysis
- **Underutilized effective skills** detection
- **Agent performance** bottleneck identification
- **Priority-based** opportunity ranking
- **Impact estimation** for improvements
**Use Cases**:
- Prioritize optimization initiatives
- Focus improvement efforts effectively
- Maximize ROI on optimization investments
- Address performance bottlenecks systematically
### 📊 **Comprehensive Analytics Report**
**Complete predictive analytics** with executive summary:
**Features**:
- **All prediction types** in one report
- **Executive summary** for stakeholders
- **Action items** and recommendations
- **Predicted outcomes** with confidence scores
- **Historical accuracy** metrics
**Use Cases**:
- Executive reporting and planning
- Team performance reviews
- Strategic decision making
- Investment justification for improvements
## Command Options
### Prediction Actions
```bash
--action quality-trend # Predict quality trends (default: 7 days)
--action optimal-skills # Recommend optimal skills (default: 3 skills)
--action learning-velocity # Predict learning acceleration (default: 14 days)
--action opportunities # Identify optimization opportunities
--action accuracy # Check prediction accuracy metrics
--action comprehensive # Generate complete report (default)
```
### Parameters
```bash
--days <number> # Prediction horizon in days (default: 7)
--task-type <type> # Task type for skill prediction (default: general)
--top-k <number> # Number of top skills to recommend (default: 3)
--dir <directory> # Custom patterns directory (default: .claude-patterns)
```
## Output Examples
### Quality Trend Prediction
```json
{
"prediction_type": "quality_trend",
"days_ahead": 7,
"predictions": [
{
"day": 1,
"predicted_quality": 87.5,
"trend_direction": "improving"
}
],
"confidence_score": 85.2,
"recommendations": [
"📈 Strong positive trend detected - maintain current approach"
]
}
```
### Optimal Skills Prediction
```json
{
"prediction_type": "optimal_skills",
"task_type": "refactoring",
"recommended_skills": [
{
"skill": "code-analysis",
"confidence": 92.5,
"success_rate": 89.2,
"recommendation_reason": "High success rate | Strong quality impact"
}
],
"prediction_confidence": 88.7
}
```
### Learning Velocity Prediction
```json
{
"prediction_type": "learning_velocity",
"days_ahead": 14,
"current_velocity": {
"avg_quality": 78.3,
"success_rate": 0.8247
},
"predictions": [
{
"day": 7,
"predicted_quality": 85.9,
"learning_acceleration": 1.02
}
],
"learning_acceleration_factor": "2% daily improvement"
}
```
## Key Innovation: Learning from Predictions
### Prediction Accuracy Tracking
- **Automatically learns** from prediction vs actual outcomes
- **Improves models** based on historical accuracy
- **Adjusts confidence thresholds** dynamically
- **Tracks prediction patterns** over time
### Continuous Model Improvement
- **Accuracy metrics** stored and analyzed
- **Model adjustments** based on performance
- **Feature importance** evolves with usage
- **Prediction confidence** self-calibrates
### Smart Learning Integration
- **Every prediction** contributes to learning database
- **Cross-prediction** insights improve overall accuracy
- **Pattern recognition** enhances predictive capabilities
- **Feedback loops** continuously improve performance
## Integration with Automatic Learning
### Data Sources
The predictive analytics engine integrates with all learning system components:
```
Enhanced Patterns Database (.claude-patterns/enhanced_patterns.json)
+-- Historical task outcomes
+-- Skill performance metrics
+-- Agent effectiveness data
+-- Quality score evolution
Predictions Database (.claude-patterns/predictions.json)
+-- Quality trend predictions
+-- Skill recommendation accuracy
+-- Learning velocity forecasts
+-- Optimization outcomes
Insights Database (.claude-patterns/insights.json)
+-- Optimization opportunities
+-- Performance bottlenecks
+-- Improvement recommendations
+-- Strategic insights
```
### Learning Feedback Loop
1. **Make predictions** based on historical patterns
2. **Execute tasks** using predictions
3. **Compare actual outcomes** with predictions
4. **Update models** based on accuracy
5. **Improve future predictions** continuously
## Advanced Usage Scenarios
### Scenario 1: Sprint Planning
```bash
# Predict quality for upcoming sprint
/predictive-analytics --action quality-trend --days 14
# Identify optimization opportunities for sprint
/predictive-analytics --action opportunities
# Get comprehensive report for planning
/predictive-analytics --action comprehensive
```
### Scenario 2: Team Performance Analysis
```bash
# Analyze team learning velocity
/predictive-analytics --action learning-velocity
# Check prediction accuracy to build confidence
/predictive-analytics --action accuracy
# Identify skill gaps and opportunities
/predictive-analytics --action optimal-skills --task-type code-review
```
### Scenario 3: Continuous Improvement
```bash
# Weekly optimization review
/predictive-analytics --action opportunities
# Quality trend monitoring
/predictive-analytics --action quality-trend --days 7
# Skill optimization recommendations
/predictive-analytics --action optimal-skills --top-k 5
```
## Performance Metrics
### Prediction Accuracy (v3.2.0)
- **Quality Trends**: 85-90% accuracy with sufficient data
- **Skill Recommendations**: 88-92% relevance score
- **Learning Velocity**: 80-85% accuracy for 7-14 day predictions
- **Optimization Opportunities**: 90%+ actionable insights
### Resource Usage
| Component | CPU | Memory | Storage |
|
---
--------|-----|--------|---------|
| Prediction Engine | <2% | ~100MB | ~5MB (prediction history) |
| Data Analysis | <1% | ~50MB | Minimal (reads existing data) |
| Report Generation | <1% | ~30MB | None |
### Response Times
| Action | Average | Max | Data Required |
|--------|---------|-----|-------------|
| Quality Trend | 50-100ms | 200ms | 5+ historical data points |
| Optimal Skills | 30-80ms | 150ms | 3+ skill usage instances |
| Learning Velocity | 40-120ms | 250ms | 7+ days of activity |
| Opportunities | 100-200ms | 400ms | 10+ task patterns |
| Comprehensive | 200-500ms | 1s | All data sources |
## Troubleshooting
### Issue: "insufficient_data" Error
```bash
# Check available learning data
ls -la .claude-patterns/
# Initialize learning system if needed
/learn-patterns
# Run some tasks to generate data
/auto-analyze
/quality-check
```
### Issue: Low Confidence Scores
```bash
# Generate more historical data for better predictions
/auto-analyze
/pr-review
/static-analysis
# Wait for more data points (minimum 5-10 needed)
/predictive-analytics --action accuracy
```
### Issue: Slow Performance
```bash
# Use specific action instead of comprehensive report
/predictive-analytics --action quality-trend
# Reduce prediction horizon for faster results
/predictive-analytics --action quality-trend --days 3
```
## API Usage (Programmatic Access)
### Python Example
```python
import requests
# Get comprehensive predictive analytics
response = requests.post('/predictive-analytics')
analytics = response.json()
print("Quality Trend:", analytics['quality_trend_prediction'])
print("Top Skills:", analytics['optimal_skills_prediction'])
print("Learning Velocity:", analytics['learning_velocity_prediction'])
```
### JavaScript Example
```javascript
// Get optimization opportunities
fetch('/predictive-analytics', {
method: 'POST',
body: JSON.stringify({ action: 'opportunities' })
})
.then(response => response.json())
.then(data => {
console.log('Opportunities:', data.optimization_opportunities.opportunities);
});
```
## Best Practices
1. **Regular Usage**: Run analytics weekly for best insights
2. **Data Collection**: Ensure sufficient historical data (10+ tasks minimum)
3. **Action-Oriented**: Focus on implementing recommended optimizations
4. **Track Progress**: Monitor prediction accuracy over time
5. **Team Integration**: Share insights with team for collective improvement
## Future Enhancements
**Planned Features** (v3.3+):
- **Time Series Prediction**: Advanced ARIMA and Prophet models
- **Anomaly Detection**: Identify unusual patterns automatically
- **Cross-Project Learning**: Transfer predictions between projects
- **Real-Time Predictions**: Live prediction updates during tasks
- **Custom Models**: User-trained prediction models
- **Integration Alerts**: Automatic notifications for predicted issues
---
This predictive analytics system provides advanced insights that help optimize performance, predict future trends, and identify improvement opportunities - all while continuously learning from every prediction to become smarter over time.

View File

@@ -0,0 +1,761 @@
---
name: monitor:dashboard
description: Launch real-time monitoring dashboard for autonomous agent system metrics and learning analytics
delegates-to: autonomous-agent:orchestrator
model: inherit
tools: Read,Write,Edit,Bash,Grep,Glob
---
# Monitor Dashboard Command
## Command: `/monitor:dashboard`
**Simple launcher** that starts a monitoring dashboard in the background and opens the web browser.
## How It Works
1. **Always Fresh**: Copies latest dashboard from plugin installation every time
2. **No Version Checks**: Simple direct copy ensures you always run the newest version
3. **Silent Launch**: Command executes dashboard.py with minimal console output
4. **Background Process**: Starts Flask server in background without blocking
5. **Auto Browser**: Opens default browser to dashboard URL automatically
**NEW v7.5.1**: Always copies latest dashboard from plugin to ensure unified version with all 5 tabs.
**CRITICAL**: This command executes with minimal console reporting. Dashboard interface shows all metrics.
## Usage
### Basic Usage
```bash
# Launch monitoring dashboard in background (default)
/monitor:dashboard
# Launch with custom port
/monitor:dashboard --port 8080
# Launch with external access (trusted networks only)
/monitor:dashboard --host 0.0.0.0
# Launch with custom data directory
/monitor:dashboard --data-dir /path/to/patterns
# Check if dashboard is running
/monitor:dashboard --status
# Stop running dashboard
/monitor:dashboard --stop
```
### Advanced Options
```bash
# Launch with debug mode (foreground for debugging)
/monitor:dashboard --debug
# Launch with custom refresh rate
/monitor:dashboard --refresh-rate 30
# Generate report without launching server
/monitor:dashboard --report-only
# Force restart if already running
/monitor:dashboard --restart
```
**Expected Performance**: Command completes in 1-2 seconds with dashboard running in background and browser automatically opened. No console output.
## Command Behavior and Implementation
### Direct Execution (No Agent Delegation)
**CRITICAL**: This command executes the dashboard directly without agent delegation to prevent duplicate launches.
1. **Direct Python Call**: `python <plugin_path>/lib/dashboard.py` (no agents involved)
2. **Background Process**: Runs Flask server completely in background
3. **Auto Browser**: Opens browser automatically (once only)
4. **Silent Operation**: No console reporting or status messages
5. **Web Interface**: All metrics available through dashboard only
### Implementation
**Bash-First with Python Fallback (Most Reliable)**:
```bash
# Try bash approach first (Unix-like systems)
if command -v bash >/dev/null 2>&1; then
bash -c '
# Step 1: Discover plugin installation
if command -v find >/dev/null 2>&1; then
PLUGIN_DIR=$(find ~/.claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude ~/.config/claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude 2>/dev/null | head -1)
elif command -v where >/dev/null 2>&1; then
PLUGIN_DIR=$(find /c/Users/*/.claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude 2>/dev/null | head -1)
fi
if [ -z "$PLUGIN_DIR" ] || [ ! -f "$PLUGIN_DIR/lib/dashboard.py" ]; then
echo "ERROR: Plugin installation not found"
exit 1
fi
# Step 2: Always copy latest version from plugin (ensures all fixes are applied)
echo "Copying latest dashboard from plugin..."
mkdir -p .claude-patterns
cp "$PLUGIN_DIR/lib/dashboard.py" ".claude-patterns/dashboard.py"
echo "[OK] Dashboard ready with all JavaScript fixes"
# Step 3: Check if dashboard already running
if curl -s http://127.0.0.1:5000/api/overview >/dev/null 2>&1; then
echo "Dashboard is already running at: http://127.0.0.1:5000"
echo "Opening browser..."
exit 0
fi
# Step 4: Start dashboard in background
echo "Starting dashboard server..."
python .claude-patterns/dashboard.py --patterns-dir .claude-patterns >/dev/null 2>&1 &
DASHBOARD_PID=$!
echo "Dashboard started successfully (PID: $DASHBOARD_PID)"
echo "Dashboard URL: http://127.0.0.1:5000"
# Step 5: Wait for server and validate
sleep 3
# Quick validation check (optional but recommended)
if [ -f "$PLUGIN_DIR/lib/web_page_validator.py" ]; then
echo "[INFO] Running automatic validation..."
if python "$PLUGIN_DIR/lib/web_page_validator.py" "http://127.0.0.1:5000" --timeout 10 >/dev/null 2>&1; then
echo "[OK] Dashboard validation passed - no JavaScript errors detected"
else
echo "[WARN] Dashboard validation detected issues"
echo "[INFO] Run /validate:web http://127.0.0.1:5000 for details"
fi
fi
# Step 6: Open browser
echo "Opening browser automatically..."
if command -v xdg-open >/dev/null 2>&1; then
xdg-open "http://127.0.0.1:5000" >/dev/null 2>&1
elif command -v open >/dev/null 2>&1; then
open "http://127.0.0.1:5000"
elif command -v start >/dev/null 2>&1; then
start "http://127.0.0.1:5000"
fi
' "$@"
BASH_SUCCESS=$?
# If bash succeeded, exit
if [ $BASH_SUCCESS -eq 0 ]; then
exit 0
fi
echo "Bash approach failed, falling back to Python..."
fi
# Python fallback (cross-platform reliable)
python -c "
import os
import sys
import shutil
import subprocess
import webbrowser
import time
from pathlib import Path
def launch_dashboard():
'''Launch dashboard - always uses latest plugin version with all fixes.'''
# Step 1: Discover plugin installation
plugin_paths = [
Path.home() / '.claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude',
Path.home() / '.config/claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude',
Path.home() / '.claude/plugins/autonomous-agent',
]
if os.name == 'nt':
plugin_paths.extend([
Path(os.environ.get('APPDATA', '')) / 'Claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude',
Path(os.environ.get('LOCALAPPDATA', '')) / 'Claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude',
])
plugin_dashboard = None
for plugin_path in plugin_paths:
potential_dashboard = plugin_path / 'lib/dashboard.py'
if potential_dashboard.exists():
plugin_dashboard = potential_dashboard
break
if not plugin_dashboard:
print('ERROR: Plugin installation not found')
print(' Searched paths:', [str(p) for p in plugin_paths])
return False
# Step 2: Always copy latest version from plugin (ensures all fixes are applied)
local_dashboard = Path('.claude-patterns/dashboard.py')
try:
print('Copying latest dashboard from plugin...')
Path('.claude-patterns').mkdir(exist_ok=True)
shutil.copy2(plugin_dashboard, local_dashboard)
print('[OK] Dashboard ready with all JavaScript fixes')
except Exception as e:
print(f'ERROR: Failed to copy dashboard: {e}')
return False
# Step 3: Start dashboard from local copy
print('Starting dashboard server...')
return start_dashboard(str(local_dashboard), '.claude-patterns')
def start_dashboard(dashboard_path: str, patterns_dir: str) -> bool:
'''Start the dashboard server.'''
try:
# Check if port 5000 is available
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', 5000))
sock.close()
if result == 0:
print('Dashboard is already running at: http://127.0.0.1:5000')
print('Opening browser...')
webbrowser.open('http://127.0.0.1:5000')
return True
# Start dashboard in background
cmd = [sys.executable, dashboard_path, '--patterns-dir', patterns_dir]
if len(sys.argv) > 1:
cmd.extend(sys.argv[1:])
# Platform-specific background process creation
if os.name == 'nt':
# Windows: Use CREATE_NO_WINDOW to run silently
process = subprocess.Popen(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW if hasattr(subprocess, 'CREATE_NO_WINDOW') else 0
)
else:
# Unix-like: Standard background process
process = subprocess.Popen(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
print(f'Dashboard started successfully (PID: {process.pid})')
print('Dashboard URL: http://127.0.0.1:5000')
# Wait for server to be ready
time.sleep(3)
# Auto-validate dashboard for JavaScript errors (optional but recommended)
try:
import urllib.request
# Quick connectivity check
urllib.request.urlopen('http://127.0.0.1:5000', timeout=2)
print('[OK] Dashboard server is responding')
# Try to run validation if available
try:
validator_path = Path(plugin_dashboard).parent / 'web_page_validator.py'
if validator_path.exists():
print('[INFO] Running automatic validation...')
validation_result = subprocess.run(
[sys.executable, str(validator_path), 'http://127.0.0.1:5000', '--timeout', '10'],
capture_output=True,
text=True,
timeout=15
)
if validation_result.returncode == 0:
print('[OK] Dashboard validation passed - no JavaScript errors detected')
else:
print('[WARN] Dashboard validation detected issues')
print('[INFO] Run /validate:web http://127.0.0.1:5000 for details')
except Exception:
pass # Validation is optional, don't fail if unavailable
except Exception:
pass # Server will still open in browser
print('Opening browser automatically...')
webbrowser.open('http://127.0.0.1:5000')
return True
except Exception as e:
print(f'Error starting dashboard: {e}')
return False
if __name__ == '__main__':
launch_dashboard()
" "$@"
# Benefits of this approach:
# 1. ✅ BASH-FIRST - Uses efficient bash commands when available
# 2. ✅ PYTHON FALLBACK - Reliable cross-platform compatibility when bash fails
# 3. ✅ FASTEST PERFORMANCE - local copy avoids plugin discovery overhead
# 4. ✅ RELIABLE - works even if plugin installation changes
# 5. ✅ SELF-CONTAINED - each project has its own dashboard instance
# 6. ✅ ERROR HANDLING - graceful fallbacks and informative error messages
# 4. ✅ OFFLINE CAPABLE - works completely without plugin after initial setup
# 5. ✅ EASY DEBUGGING - local copy can be modified and tested
# For custom arguments:
# python .claude-patterns/dashboard.py --port 8080 --host 0.0.0.0
```
**Platform Support**:
- **Windows**: ✅ Native support (cmd.exe, PowerShell, Git Bash)
- **Linux**: ✅ Native support (bash, sh)
- **macOS**: ✅ Native support (bash, zsh)
- **All Installation Methods**: ✅ Marketplace, development, system-wide
**How It Works**:
1. **Built-in Discovery**: The Python script automatically searches for plugin installation across all standard locations
2. **Marketplace Priority**: Prioritizes marketplace installations over development/local installations
3. **Platform-Aware**: Uses OS-specific environment variables and paths (Windows: APPDATA/LOCALAPPDATA, Linux/macOS: standard directories)
4. **Fallback Support**: Falls back to development mode if marketplace installation not found
5. **Current Directory Access**: Preserves current working directory for pattern data access (.claude-patterns/)
**Discovery Order**:
1. **Marketplace Installations** (Primary):
- Windows: `%USERPROFILE%\.claude\plugins\marketplaces\LLM-Autonomous-Agent-Plugin-for-Claude\`
- macOS/Linux: `~/.claude/plugins/marketplaces/LLM-Autonomous-Agent-Plugin-for-Claude/`
- Alternative paths in `.config/claude/plugins/`
2. **Platform-Specific Paths**:
- Windows: `APPDATA\Claude\plugins\marketplaces\`, `LOCALAPPDATA\Claude\plugins\marketplaces\`
- Linux/macOS: `/usr/local/share/claude/plugins/marketplaces/`, `/opt/claude/plugins/marketplaces/`
3. **Development/Local Installations** (Fallback):
- `~/.claude/plugins/autonomous-agent/`
- Current directory and parent directories (development mode)
**Data Access**: Pattern data always comes from current project directory (`./.claude-patterns/`), while the dashboard script runs from the plugin installation directory.
**Benefits**:
- ✅ Self-contained - no external launcher files needed
- ✅ Works from any user project directory
- ✅ Cross-platform compatible (Windows, Linux, macOS)
- ✅ Automatic plugin discovery - no hardcoded paths
- ✅ Marketplace installation priority
- ✅ Clear error messages with installation guidance
**Key Fix**: Eliminates path resolution issues by embedding discovery logic directly in the command rather than relying on external launcher files that don't exist in user project directories.
### Smart Browser Opening (Enhanced v1.0.2)
**Prevents Double Browser Opening**:
- **Existing Dashboard Detection**: Checks if dashboard is already running on ports 5000-5010
- **Browser Lock Mechanism**: Uses lock files to track browser opening per port
- **Single Browser Launch**: Opens browser only once per dashboard instance
- **Multiple Instance Support**: Handles multiple dashboard instances gracefully
**Browser Opening Logic**:
1. **Check existing dashboard**: Scans for running dashboard on specified port range
2. **Browser state tracking**: Uses temporary lock files to track browser opening state
3. **Smart opening**: Opens browser only if not already opened for that specific instance
4. **Automatic cleanup**: Removes lock files on dashboard shutdown
**Edge Cases Handled**:
- **Multiple dashboards**: Each port gets separate browser lock tracking
- **Dashboard restarts**: Lock files are properly cleaned up and recreated
- **Manual browser opening**: Respects existing browser states
- **Cross-platform**: Works on Windows, Linux, and macOS
### Expected Command Output
**Smart console output**. The command provides intelligent feedback based on dashboard state:
```
# New dashboard instance:
Starting Autonomous Agent Dashboard...
Dashboard URL: http://127.0.0.1:5000
Opening browser automatically...
Browser opened to http://127.0.0.1:5000
# Existing dashboard found:
Dashboard is already running at: http://127.0.0.1:5000
Browser already opened for this dashboard instance.
# Browser opened for existing instance:
Dashboard is already running at: http://127.0.0.1:5000
Browser opened to existing dashboard: http://127.0.0.1:5000
```
### Error Handling
If dashboard fails to start, the command fails silently. Check for common issues:
- **Port conflicts**: Use different port with `--port 8080`
- **Missing dependencies**: Install with `pip install flask flask-cors`
- **Directory issues**: Ensure `.claude-patterns` directory exists
All error handling and status information is available through the web dashboard interface.
### Process Management Commands
```bash
# Check dashboard status
/monitor:dashboard --status
# Stop dashboard
/monitor:dashboard --stop
# Restart dashboard
/monitor:dashboard --restart
```
*Process management commands are handled through the dashboard web interface.*
## Dashboard Features
### 📊 Real-time Metrics
- **Learning Progress**: Pattern effectiveness and skill improvement over time
- **Quality Trends**: Code quality metrics and validation scores
- **Agent Performance**: Success rates and execution times for specialized agents
- **System Health**: Resource usage and operational status
- **Task Analytics**: Task completion rates and learning patterns
### 📈 Interactive Charts
- **Time Series Analysis**: Performance metrics over customizable time ranges
- **Comparative Analysis**: Side-by-side agent and skill performance
- **Trend Visualization**: Learning curves and improvement trajectories
- **Distribution Charts**: Success rates and outcome distributions
- **Resource Monitoring**: CPU, memory, and storage usage patterns
### 🎯 Performance Insights
- **Skill Effectiveness**: Which skills perform best for specific task types
- **Agent Specialization**: Performance comparison across different agents
- **Learning Patterns**: How the system improves over time
- **Quality Metrics**: Code quality trends and validation scores
- **Optimization Opportunities**: Areas for performance improvement
### 🔍 Advanced Analytics
- **Pattern Recognition**: Automatic identification of successful patterns
- **Predictive Insights**: Performance predictions based on historical data
- **Anomaly Detection**: Unusual performance patterns and potential issues
- **Correlation Analysis**: Relationships between different metrics
- **Recommendation Engine**: Actionable insights for system optimization
## System Requirements
### Dependencies
- **Python 3.8+**: Required for dashboard server
- **Flask**: Web framework for dashboard interface
- **Flask-CORS**: Cross-origin resource sharing
- **Standard libraries**: `json`, `statistics`, `threading`, `pathlib`
### Resource Requirements
- **Minimum**: 2GB RAM, 1 CPU core
- **Recommended**: 4GB+ RAM, 2+ CPU cores
- **Storage**: 100MB+ for pattern data
- **Network**: Optional, for external access and team sharing
## Dashboard Interface
### Main Navigation
```
🏠 Overview -> System health and key metrics
📊 Analytics -> Detailed performance analytics
🎯 Skills -> Skill effectiveness analysis
🤖 Agents -> Agent performance comparison
📚 Learning -> Learning progress and patterns
🔧 System -> Resource usage and health
⚙️ Settings -> Configuration and preferences
```
### Key Dashboard Sections
#### Overview Panel
- **System Status**: Overall health and operational status
- **Active Metrics**: Current performance indicators
- **Quick Stats**: Success rates, quality scores, task counts
- **Recent Activity**: Latest task executions and outcomes
- **Alerts & Issues**: System notifications and warnings
#### Analytics Panel
- **Performance Trends**: Time-based performance analysis
- **Quality Metrics**: Code quality over time
- **Success Rates**: Task completion and success patterns
- **Learning Curves**: System improvement trajectories
- **Comparative Analysis**: Side-by-side performance comparisons
#### Skills Analysis
- **Skill Rankings**: Performance ranking of all skills
- **Usage Patterns**: How often and when skills are used
- **Effectiveness Metrics**: Success rates by skill type
- **Optimization Suggestions**: Areas for skill improvement
- **Skill Dependencies**: Relationships between skills
#### Agent Performance
- **Agent Comparison**: Performance across different agents
- **Specialization Analysis**: Which agents excel at specific tasks
- **Efficiency Metrics**: Time and resource usage by agent
- **Quality Scores**: Output quality by agent type
- **Delegation Success**: Rate of successful task delegation
#### Learning Progress
- **Pattern Recognition**: Discovered learning patterns
- **Knowledge Base**: Growing pattern database
- **Improvement Metrics**: Quantified learning progress
- **Adaptation Rate**: How quickly the system adapts
- **Cross-Project Learning**: Knowledge transfer between projects
## API Endpoints
The dashboard provides REST API endpoints for data access:
```bash
# Get overview data
GET /api/overview
# Get learning analytics
GET /api/analytics
# Get skill performance
GET /api/skills
# Get agent performance
GET /api/agents
# Get system health
GET /api/health
# Get historical data
GET /api/history?period=7d
# Get performance insights
GET /api/insights
```
## Configuration
### Environment Variables
```bash
# Dashboard configuration
DASHBOARD_HOST=127.0.0.1 # Default bind address
DASHBOARD_PORT=5000 # Default port
DASHBOARD_DEBUG=false # Debug mode
DASHBOARD_CACHE_TTL=60 # Cache TTL in seconds
DASHBOARD_REFRESH_RATE=30 # Auto-refresh rate
# Data directory
PATTERNS_DIR=.claude-patterns # Pattern data directory
```
### Configuration File
```json
{
"dashboard": {
"host": "127.0.0.1",
"port": 5000,
"debug": false,
"cache_ttl": 60,
"refresh_rate": 30
},
"data": {
"patterns_dir": ".claude-patterns",
"retention_days": 30,
"auto_cleanup": true
},
"features": {
"real_time_updates": true,
"export_reports": true,
"email_alerts": false,
"team_sharing": true
}
}
```
## Security Considerations
### Local Access Only (Default)
- Binds to localhost (127.0.0.1) for security
- Accessible only from the machine where it's running
- Recommended for most use cases
### Network Access (Use with Caution)
```bash
# Enable external access (trusted networks only)
/monitor:dashboard --host 0.0.0.0
# Add firewall rules for security
sudo ufw allow 5000 # Linux
# Configure firewall rules appropriately
```
### Data Privacy
- All data processing happens locally
- No external data transmission
- Pattern data stored locally
- User controls data retention
## Integration with Other Commands
### Pre-Dashboard Analysis
```bash
# Generate comprehensive data before dashboard
/analyze:project
/learn:analytics
/analyze:quality
# Then launch dashboard
/monitor:dashboard
```
### Post-Dashboard Actions
```bash
# Generate reports based on dashboard insights
/workspace:reports
/learn:performance
# Implement optimizations
/workspace:improve
```
### Continuous Monitoring
```bash
# Background monitoring
/monitor:dashboard --background
# Generate periodic reports
/workspace:organize
```
## Troubleshooting
### Common Issues
**Port Already in Use**
```bash
# Use different port
/monitor:dashboard --port 8080
# Kill existing process
lsof -ti:5000 | xargs kill -9
```
**No Data Available**
```bash
# Initialize pattern learning
/learn:init
# Generate some activity
/analyze:project
# Check data directory
ls -la .claude-patterns/
```
**Dashboard Won't Load**
```bash
# Check Python dependencies
pip install flask flask-cors
# Verify dashboard script (auto-detects plugin path)
python <plugin_path>/lib/dashboard.py --test
# Check system resources
free -h # Memory
df -h # Disk space
```
**Performance Issues**
```bash
# Increase cache TTL
/monitor:dashboard --cache-ttl 120
# Reduce refresh rate
/monitor:dashboard --refresh-rate 60
# Clear old data
/monitor:dashboard --cleanup-days 7
```
### Debug Mode
```bash
# Launch with debug output
/monitor:dashboard --debug
# Check log files
tail -f .claude/logs/dashboard.log
# Validate installation (auto-detects plugin path)
python <plugin_path>/lib/dashboard.py --validate
```
## Best Practices
### Production Use
- Use external access only on trusted networks
- Set up appropriate firewall rules
- Monitor resource usage
- Regular data backups
- Implement access controls for team sharing
### Performance Optimization
- Regular data cleanup and archiving
- Optimize cache settings based on usage
- Monitor system resources
- Use appropriate refresh intervals
- Consider resource limits for long-term operation
### Data Management
- Regular backup of pattern data
- Archive old data to maintain performance
- Monitor storage usage
- Implement data retention policies
- Export important insights regularly
## Performance Metrics
### Expected Resource Usage
- **CPU**: 2-5% during normal operation
- **Memory**: 50-200MB depending on data size
- **Storage**: Grows with pattern data (manageable)
- **Network**: Minimal (local access)
### Scalability
- **Data Points**: Handles 10,000+ pattern entries efficiently
- **Concurrent Users**: Supports 5-10 simultaneous users
- **Historical Data**: Optimal performance with 30-day retention
- **Response Times**: <100ms for most API endpoints
## Examples
### Basic Monitoring
```bash
# Launch dashboard for local development
/monitor:dashboard
# Monitor specific project
cd /path/to/project
/monitor:dashboard --data-dir .claude-patterns
```
### Team Monitoring
```bash
# Share dashboard with team
/monitor:dashboard --host 0.0.0.0 --port 8080
# Team members access at:
# http://your-ip:8080
```
### Production Monitoring
```bash
# Background monitoring with alerts
/monitor:dashboard --background --email-alerts
# Generate daily reports
/monitor:dashboard --report-only --email-reports
```
---
**Version**: 1.0.2
**Integration**: Uses dashboard.py directly from lib/ directory (no delegation)
**Dependencies**: Flask, Flask-CORS, Python 3.8+
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Integrates with learning-engine for pattern analysis
**Fix**: Enhanced smart browser opening with lock mechanism and existing dashboard detection (v1.0.2)
**Previous**: Removed agent delegation to prevent duplicate browser launches (v1.0.1)

446
commands/monitor/groups.md Normal file
View File

@@ -0,0 +1,446 @@
---
name: monitor:groups
description: Real-time monitoring of four-tier group performance, communication, and specialization metrics
version: 7.0.0
category: monitoring
---
# Monitor Groups Command
Display comprehensive real-time metrics for all four agent groups including performance, communication effectiveness, specialization, and learning progress.
## What This Command Does
**Analyzes and displays**:
1. **Group Performance Metrics** - Success rates, quality scores, execution times per group
2. **Inter-Group Communication** - Message flow, success rates, feedback effectiveness
3. **Group Specialization** - What each group excels at based on task history
4. **Knowledge Transfer** - Cross-group learning effectiveness
5. **Decision Quality** - Group 2 decision accuracy and user alignment
6. **Validation Effectiveness** - Group 4 validation pass rates
## Execution Steps
Follow these steps to generate comprehensive group monitoring report:
### Step 1: Load All Group Data
```python
from lib.group_collaboration_system import get_group_collaboration_stats
from lib.group_performance_tracker import get_group_performance, compare_groups
from lib.inter_group_knowledge_transfer import get_knowledge_transfer_stats
from lib.group_specialization_learner import get_specialization_profile, get_learning_insights
from lib.agent_performance_tracker import get_agent_performance
# Load all statistics
collab_stats = get_group_collaboration_stats()
knowledge_stats = get_knowledge_transfer_stats()
learning_insights = get_learning_insights()
```
### Step 2: Analyze Each Group
**For Group 1 (Strategic Analysis & Intelligence)**:
```python
group1_perf = get_group_performance(1)
group1_spec = get_specialization_profile(1)
# Key metrics:
# - Total recommendations made
# - Average confidence score
# - Recommendation acceptance rate (by Group 2)
# - Recommendation effectiveness (from Group 4 feedback)
# - Top specializations (refactoring, security, performance)
```
**For Group 2 (Decision Making & Planning)**:
```python
group2_perf = get_group_performance(2)
group2_spec = get_specialization_profile(2)
# Key metrics:
# - Total decisions made
# - Decision accuracy (plans executed successfully)
# - User preference alignment score
# - Average decision confidence
# - Plan adjustment rate (how often plans need revision)
```
**For Group 3 (Execution & Implementation)**:
```python
group3_perf = get_group_performance(3)
group3_spec = get_specialization_profile(3)
# Key metrics:
# - Total executions completed
# - First-time success rate
# - Average quality improvement (before/after)
# - Auto-fix success rate
# - Average iterations needed
```
**For Group 4 (Validation & Optimization)**:
```python
group4_perf = get_group_performance(4)
group4_spec = get_specialization_profile(4)
# Key metrics:
# - Total validations performed
# - GO/NO-GO decision distribution
# - Average quality score (5-layer validation)
# - Feedback effectiveness (improvements from feedback)
# - Issue detection rate
```
### Step 3: Analyze Inter-Group Communication
```python
# Communication flow analysis
comm_flows = {
"Group 1 -> Group 2": collab_stats.get("group_1_to_2", {}),
"Group 2 -> Group 3": collab_stats.get("group_2_to_3", {}),
"Group 3 -> Group 4": collab_stats.get("group_3_to_4", {}),
"Group 4 -> Group 1": collab_stats.get("group_4_to_1", {}),
"Group 4 -> Group 2": collab_stats.get("group_4_to_2", {}),
"Group 4 -> Group 3": collab_stats.get("group_4_to_3", {})
}
# Calculate:
# - Message success rate per flow
# - Average feedback cycle time
# - Communication bottlenecks
```
### Step 4: Analyze Knowledge Transfer
```python
# Knowledge transfer effectiveness
for group_num in [1, 2, 3, 4]:
knowledge_for_group = query_knowledge(
for_group=group_num,
knowledge_type=None # All types
)
# Metrics:
# - Total knowledge available to group
# - Knowledge application success rate
# - Top knowledge sources (which groups share most effectively)
# - Knowledge confidence trends
```
### Step 5: Identify Top Performers and Areas for Improvement
```python
# Compare groups
comparison = compare_groups(metric='quality_score')
# Identify:
# - Top performing group
# - Groups needing improvement
# - Emerging specializations
# - Communication improvements needed
```
### Step 6: Generate Comprehensive Report
**Report Structure**:
```markdown
# Four-Tier Group Monitoring Report
Generated: {timestamp}
## Executive Summary
- Overall System Health: {score}/100
- Total Tasks Completed: {total}
- Average Quality Score: {avg_quality}/100
- Communication Success Rate: {comm_success}%
- Knowledge Transfer Effectiveness: {knowledge_eff}%
## Group Performance Overview
### Group 1: Strategic Analysis & Intelligence (The "Brain")
**Performance**: {rating} | **Tasks**: {count} | **Success Rate**: {success}%
**Key Metrics**:
- Recommendations Made: {rec_count}
- Average Confidence: {avg_conf}
- Acceptance Rate: {acceptance}%
- Effectiveness Score: {effectiveness}/100
**Top Specializations**:
1. {spec_1} - {quality}% success rate
2. {spec_2} - {quality}% success rate
3. {spec_3} - {quality}% success rate
**Top Agents**:
- {agent_1}: {performance} ({task_type})
- {agent_2}: {performance} ({task_type})
---
### Group 2: Decision Making & Planning (The "Council")
**Performance**: {rating} | **Decisions**: {count} | **Accuracy**: {accuracy}%
**Key Metrics**:
- Decisions Made: {decision_count}
- Decision Confidence: {avg_conf}
- User Alignment: {alignment}%
- Plan Success Rate: {plan_success}%
**Decision Quality**:
- Excellent (90-100): {excellent_count}
- Good (70-89): {good_count}
- Needs Improvement (<70): {poor_count}
**Top Agents**:
- strategic-planner: {performance}
- preference-coordinator: {performance}
---
### Group 3: Execution & Implementation (The "Hand")
**Performance**: {rating} | **Executions**: {count} | **Success**: {success}%
**Key Metrics**:
- Executions Completed: {exec_count}
- First-Time Success: {first_time}%
- Quality Improvement: +{improvement} points avg
- Auto-Fix Success: {autofix}%
**Top Specializations**:
1. {spec_1} - {quality}% success rate
2. {spec_2} - {quality}% success rate
3. {spec_3} - {quality}% success rate
**Top Agents**:
- {agent_1}: {performance} ({task_type})
- {agent_2}: {performance} ({task_type})
- {agent_3}: {performance} ({task_type})
---
### Group 4: Validation & Optimization (The "Guardian")
**Performance**: {rating} | **Validations**: {count} | **Pass Rate**: {pass_rate}%
**Key Metrics**:
- Validations Performed: {val_count}
- GO Decisions: {go_count} ({go_pct}%)
- NO-GO Decisions: {nogo_count} ({nogo_pct}%)
- Average Quality Score: {avg_quality}/100
- Feedback Effectiveness: {feedback_eff}%
**Five-Layer Validation Breakdown**:
- Functional (30 pts): {func_avg}/30
- Quality (25 pts): {qual_avg}/25
- Performance (20 pts): {perf_avg}/20
- Integration (15 pts): {integ_avg}/15
- UX (10 pts): {ux_avg}/10
**Top Agents**:
- post-execution-validator: {performance}
- performance-optimizer: {performance}
- continuous-improvement: {performance}
---
## Inter-Group Communication
### Communication Flow Analysis
**Group 1 -> Group 2 (Analysis -> Decision)**:
- Messages Sent: {count}
- Success Rate: {success}%
- Average Response Time: {time}s
- Recommendation Acceptance: {acceptance}%
**Group 2 -> Group 3 (Decision -> Execution)**:
- Plans Sent: {count}
- Execution Success: {success}%
- Plan Completeness: {completeness}%
- Average Execution Time: {time}s
**Group 3 -> Group 4 (Execution -> Validation)**:
- Results Sent: {count}
- Validation Pass Rate: {pass_rate}%
- Average Quality Improvement: +{improvement} pts
- Iterations Needed: {iterations} avg
**Group 4 -> All Groups (Feedback Loops)**:
- Feedback Messages: {count}
- Feedback Effectiveness: {effectiveness}%
- Average Cycle Time: {time}s
- Learning Applied: {learning_count} instances
### Communication Health
- ✅ Excellent (>95%): {excellent_flows}
- [WARN] Needs Attention (70-95%): {warning_flows}
- ❌ Critical (<70%): {critical_flows}
---
## Knowledge Transfer
### Cross-Group Learning
**Total Knowledge Base**: {total_knowledge} items
**Average Confidence**: {avg_confidence}
**Application Success Rate**: {application_success}%
**Knowledge by Type**:
- Patterns: {pattern_count} (avg confidence: {pattern_conf})
- Best Practices: {bp_count} (avg confidence: {bp_conf})
- Optimizations: {opt_count} (avg confidence: {opt_conf})
- Anti-Patterns: {ap_count} (avg confidence: {ap_conf})
**Top Knowledge Sources** (Groups sharing most effectively):
1. Group {group_num}: {knowledge_count} items, {success}% success rate
2. Group {group_num}: {knowledge_count} items, {success}% success rate
3. Group {group_num}: {knowledge_count} items, {success}% success rate
**Knowledge Transfer Matrix**:
```
To G1 To G2 To G3 To G4
From G1 -- {n} {n} {n}
From G2 {n} -- {n} {n}
From G3 {n} {n} -- {n}
From G4 {n} {n} {n} --
```
---
## Specialization Insights
### Group Specialization Maturity
**Group 1 (Brain)**: {maturity_level}
- Expertise Areas: {areas}
- Emerging Specializations: {emerging}
- Recommendation: {recommendation}
**Group 2 (Council)**: {maturity_level}
- Expertise Areas: {areas}
- Decision Patterns: {patterns}
- Recommendation: {recommendation}
**Group 3 (Hand)**: {maturity_level}
- Expertise Areas: {areas}
- Execution Strengths: {strengths}
- Recommendation: {recommendation}
**Group 4 (Guardian)**: {maturity_level}
- Expertise Areas: {areas}
- Validation Focus: {focus}
- Recommendation: {recommendation}
---
## Trends & Insights
### Performance Trends (Last 50 Tasks)
**Quality Score Trend**: {trend} ({direction})
- Current Average: {current_avg}/100
- 10-Task Moving Average: {moving_avg}/100
- Trend Direction: {improving/stable/declining}
**Iteration Efficiency**: {trend}
- Current Average: {current_iterations}
- Target: 1.2 or less
- Status: {on_track/needs_attention}
**Decision Accuracy**: {trend}
- Current: {current_accuracy}%
- Target: 90%+
- Status: {excellent/good/needs_improvement}
### Learning Insights
{insight_1}
{insight_2}
{insight_3}
---
## Recommendations
### High Priority
1. {recommendation_1}
2. {recommendation_2}
### Medium Priority
1. {recommendation_1}
2. {recommendation_2}
### Optimization Opportunities
1. {opportunity_1}
2. {opportunity_2}
---
## System Health Score: {score}/100
**Breakdown**:
- Group Performance (40 pts): {group_perf}/40
- Communication Quality (25 pts): {comm_quality}/25
- Knowledge Transfer (20 pts): {knowledge}/20
- Specialization Maturity (15 pts): {specialization}/15
**Status**: {Excellent/Good/Needs Attention/Critical}
---
Report Path: .claude/data/reports/group-monitoring-{date}.md
```
## Result Presentation
**Terminal Output (15-20 lines max)**:
```
+==============================================================+
| FOUR-TIER GROUP MONITORING REPORT |
+==============================================================+
System Health: {score}/100 ({status})
Total Tasks: {count} | Avg Quality: {quality}/100 | Success Rate: {success}%
GROUP PERFORMANCE:
Group 1 (Brain): {rating} | {tasks} tasks | {success}% success
Group 2 (Council): {rating} | {decisions} decisions | {accuracy}% accurate
Group 3 (Hand): {rating} | {executions} executions | {success}% success
Group 4 (Guardian): {rating} | {validations} validations | {pass}% pass rate
COMMUNICATION: {comm_success}% success rate | {feedback_count} feedback loops
TOP PERFORMERS:
1. {agent_name} ({group}): {performance}
2. {agent_name} ({group}): {performance}
3. {agent_name} ({group}): {performance}
TRENDS: Quality {trend_icon} {direction} | Iterations {trend_icon} {direction}
📄 Detailed Report: .claude/data/reports/group-monitoring-{date}.md
⏱️ Execution Time: {time}s
```
**File Report**: Save complete detailed report to `.claude/data/reports/group-monitoring-YYYY-MM-DD.md`
## Notes
- Automatically refreshes data from all learning systems
- Identifies bottlenecks and improvement opportunities
- Tracks specialization emergence over time
- Monitors communication effectiveness
- **Run regularly** (e.g., after every 10-20 tasks) to track trends
- Use insights to optimize group coordination
## Integration
This command integrates with:
- `lib/group_collaboration_system.py` - Communication tracking
- `lib/group_performance_tracker.py` - Performance metrics
- `lib/inter_group_knowledge_transfer.py` - Knowledge stats
- `lib/group_specialization_learner.py` - Specialization insights
- `lib/agent_performance_tracker.py` - Individual agent data
- `lib/agent_feedback_system.py` - Feedback effectiveness

View File

@@ -0,0 +1,36 @@
---
name: monitor:recommend
description: Get smart workflow and optimization recommendations based on learned patterns
---
EXECUTE THESE BASH COMMANDS DIRECTLY (no agents, no skills):
First, find the plugin installation path:
```bash
PLUGIN_PATH=$(find ~/.claude -name "exec_plugin_script.py" 2>/dev/null | head -1 | sed 's|/lib/exec_plugin_script.py||')
echo "Plugin found at: $PLUGIN_PATH"
```
Step 1 - Generate recommendations using project patterns:
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" recommendation_engine.py --dir ./.claude-patterns --task "your task description here"
```
Step 2 - For general recommendations (no specific task):
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" recommendation_engine.py --dir ./.claude-patterns
```
Step 3 - For JSON output (programmatic use):
```bash
python3 "$PLUGIN_PATH/lib/exec_plugin_script.py" recommendation_engine.py --dir ./.claude-patterns --task "your task" --format json
```
Report will show:
- Recommended approach with confidence level
- Quality predictions and time estimates
- Skill suggestions with success rates
- Risk assessment with mitigations
- Alternative approaches with trade-offs
The recommendations will use patterns from your current project directory at ./.claude-patterns/

View File

@@ -0,0 +1,173 @@
---
name: search-smart
description: Smart web search with automatic fallback when WebSearch fails
---
# Smart Web Search Command
## Command: `/search-smart <query>`
Intelligent web search that automatically uses the Web Search Fallback system when the WebSearch API fails or hits limits.
## How It Works
1. **Primary Attempt**: Uses WebSearch API first
2. **Automatic Detection**: Identifies when WebSearch fails
3. **Seamless Fallback**: Switches to bash+curl HTML scraping
4. **Result Delivery**: Returns formatted results regardless of method
## Usage Examples
```bash
# Basic search
/search-smart AI trends 2025
# Search with specific result count
/search-smart "quantum computing breakthroughs" -n 10
# Search with no cache (fresh results)
/search-smart "latest news today" --no-cache
```
## Features
### Automatic Fallback Chain
1. WebSearch API (primary)
2. DuckDuckGo HTML scraping
3. Searx instances
4. Direct curl commands
### Smart Caching
- 60-minute cache for repeated queries
- Automatic cache invalidation for time-sensitive searches
- Cache hit indication in results
### Error Recovery
- Detects API rate limits
- Handles network timeouts
- Provides alternative search engines
- Never fails silently
## Implementation
```python
# Python implementation using the plugin
import sys
import os
# Add plugin path
plugin_path = os.path.expanduser("~/.config/claude/plugins/autonomous-agent")
if os.path.exists(plugin_path):
sys.path.insert(0, os.path.join(plugin_path, "lib"))
from web_search_fallback import WebSearchFallback
def search_smart(query, num_results=10):
# Try WebSearch first (if available)
try:
from web_search import search as web_search
result = web_search(query)
if result and len(result) > 0:
return result
except:
pass
# Use fallback
searcher = WebSearchFallback()
return searcher.search(query, num_results=num_results)
```
## Bash Implementation
```bash
#!/bin/bash
function search_smart() {
local query="$1"
local num_results="${2:-10}"
# Try to find the plugin
if [ -f "$HOME/.config/claude/plugins/autonomous-agent/lib/web_search_fallback.py" ]; then
python3 "$HOME/.config/claude/plugins/autonomous-agent/lib/web_search_fallback.py" \
"$query" -n "$num_results"
else
# Direct fallback
curl -s -A "Mozilla/5.0" \
"https://html.duckduckgo.com/html/?q=$(echo "$query" | sed 's/ /+/g')" \
| grep -o '<a[^>]*class="result__a"[^>]*>[^<]*</a>' \
| sed 's/<[^>]*>//g' \
| head -n "$num_results"
fi
}
```
## Output Format
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 SMART WEB SEARCH RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Query: "AI trends 2025"
Method: Fallback (WebSearch unavailable)
Results: 5
1. The 10 Biggest AI Trends Of 2025
https://forbes.com/...
2. AI Trends to Watch in 2025 & Beyond
https://analyticsinsight.net/...
3. What's Next for AI in 2025
https://technologyreview.com/...
[Cache: Hit] [Time: 0.2s]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Integration with Agents
This command can be used by:
- **research-analyzer**: For gathering information
- **background-task-manager**: For parallel searches
- **orchestrator**: For user research requests
## Troubleshooting
### If search fails completely:
1. Check internet connection
2. Verify Python 3 is installed
3. Ensure plugin is properly installed
4. Try direct curl command as last resort
### To clear cache:
```bash
rm -rf .claude-patterns/search-cache/
```
### To test fallback directly:
```bash
python3 lib/web_search_fallback.py "test query" -v
```
## Best Practices
1. **Use for important searches** - Ensures results even if API fails
2. **Monitor fallback usage** - High fallback rate indicates API issues
3. **Clear cache periodically** - For time-sensitive information
4. **Check multiple sources** - Fallback may use different search engines
## Performance
- **With WebSearch**: 1-2 seconds
- **With Fallback**: 2-4 seconds
- **With Cache**: <0.5 seconds
- **Success Rate**: 99%+ (with fallback)
## When to Use
Use `/search-smart` when:
- WebSearch frequently fails
- You need guaranteed results
- Searching for current events
- Rate limits are a concern
- Cross-platform compatibility needed

318
commands/validate/all.md Normal file
View File

@@ -0,0 +1,318 @@
---
name: validate:all
description: Run comprehensive validation audit on tools, documentation, and best practices compliance
delegates-to: autonomous-agent:validation-controller
---
# Comprehensive Validation Check
Performs thorough validation of:
- Tool usage compliance (Edit/Write prerequisites, parameter validation)
- Documentation consistency (version sync, path references, component counts)
- Cross-reference integrity (all links and references valid)
- Best practices adherence (tool selection, error handling)
- Execution flow analysis (dependency tracking, state validation)
## How It Works
This command delegates to the **validation-controller** agent which:
1. **Scans tool usage patterns** in recent session history
2. **Analyzes documentation** for inconsistencies across all .md files and plugin.json
3. **Validates cross-references** to ensure all links and component references exist
4. **Checks best practices** compliance with Claude Code guidelines
5. **Reviews execution flow** for proper tool sequencing and state management
6. **Generates validation report** with severity-prioritized findings and auto-fix suggestions
## Skills Utilized
- **autonomous-agent:validation-standards** - Tool requirements, failure patterns, consistency checks
- **autonomous-agent:quality-standards** - Best practices and quality benchmarks
- **autonomous-agent:pattern-learning** - Historical success/failure patterns
## Usage
```bash
/validate:all
```
## Expected Output (Two-Tier Presentation)
### Terminal Output (Concise)
```
[PASS] Validation Complete - Score: 85/100
Key Findings:
* [ERROR] Documentation path inconsistency: 6 occurrences in CLAUDE.md
* [WARN] Write operation without prior Read: plugin.json
* [INFO] All cross-references valid
Top Recommendations:
1. [HIGH] Standardize path references in CLAUDE.md -> Prevent user confusion
2. [MED] Add Read before Write to plugin.json -> Follow tool requirements
3. [LOW] Consider adding path validation utility
📄 Full report: .claude/data/reports/validation-2025-10-21.md
⏱ Completed in 1.2 minutes
```
### File Report (Comprehensive)
Located at: `.claude/data/reports/validation-YYYY-MM-DD.md`
```markdown
# Comprehensive Validation Report
Generated: 2025-10-21 12:30:45
## Executive Summary
Validation Score: 85/100 (Good)
- Tool Usage: 27/30 [PASS]
- Documentation Consistency: 18/25 [FAIL]
- Best Practices: 20/20 [PASS]
- Error-Free Execution: 12/15 [PASS]
- Pattern Compliance: 8/10 [PASS]
## Detailed Findings
### 🔴 Critical Issues (2)
#### 1. Documentation Path Inconsistency
**Severity**: ERROR
**Category**: Documentation Consistency
**Impact**: High - User confusion, incorrect instructions
**Details**:
- File: CLAUDE.md
- Inconsistent path references detected:
- `.claude-patterns/patterns.json` (standardized)
- Line 17: Pattern learning location
- Line 63: Pattern database location
- Line 99: Skill auto-selection query
- Line 161: Verification command
- Line 269: Pattern storage
- Line 438: Notes for future instances
- Actual implementation: `.claude-patterns/patterns.json`
**Root Cause**: Documentation written before Python utilities (v1.4) implementation
**Recommendation**: Standardize all references to `.claude-patterns/patterns.json`
**Auto-Fix Available**: Yes
```bash
# Automated fix command
sed -i 's|\.claude/patterns/|\.claude-patterns/|g' **/*.md
```
#### 2. Write Without Prior Read
**Severity**: WARNING
**Category**: Tool Usage
**Impact**: Medium - Violates tool requirements
**Details**:
- Tool: Write
- File: .claude-plugin/plugin.json
- Error: "File has not been read yet"
**Root Cause**: Edit tool called without prerequisite Read operation
**Recommendation**: Always call Read before Edit on existing files
**Auto-Fix Available**: Yes
```python
# Correct sequence
Read(".claude-plugin/plugin.json")
Edit(".claude-plugin/plugin.json", old_string, new_string)
```
### ✅ Passed Validations (12)
- [PASS] Version consistency across all files (v1.6.1)
- [PASS] Component counts accurate (10 agents, 6 skills, 6 commands)
- [PASS] All cross-references valid
- [PASS] Tool selection follows best practices
- [PASS] Bash usage avoids anti-patterns
- [PASS] No broken links in documentation
- [PASS] All referenced files exist
- [PASS] Agent YAML frontmatter valid
- [PASS] Skill metadata complete
- [PASS] Command descriptions accurate
- [PASS] Pattern database schema valid
- [PASS] No duplicate component names
### 📊 Validation Breakdown
**Tool Usage Compliance**: 27/30 points
- [PASS] 15/16 Edit operations had prerequisite Read
- [FAIL] 1/16 Edit failed due to missing Read
- [PASS] 8/8 Write operations on new files proper
- [FAIL] 1/2 Write on existing file without Read
- [PASS] All Bash commands properly chained
- [PASS] Specialized tools preferred over Bash
**Documentation Consistency**: 18/25 points
- [FAIL] Path references inconsistent (6 violations)
- [PASS] Version numbers synchronized
- [PASS] Component counts accurate
- [PASS] No orphaned references
- [PASS] Examples match implementation
**Best Practices Adherence**: 20/20 points
- [PASS] Tool selection optimal
- [PASS] Error handling comprehensive
- [PASS] File operations use correct tools
- [PASS] Documentation complete
- [PASS] Code structure clean
**Error-Free Execution**: 12/15 points
- [PASS] 95% of operations successful
- [FAIL] 1 tool prerequisite violation
- [PASS] Quick error recovery
- [PASS] No critical failures
**Pattern Compliance**: 8/10 points
- [PASS] Follows successful patterns
- [FAIL] Minor deviation in tool sequence
- [PASS] Quality scores consistent
- [PASS] Learning patterns applied
## Recommendations (Prioritized)
### High Priority (Implement Immediately)
1. **Fix Documentation Path Inconsistency**
- Impact: Prevents user confusion and incorrect instructions
- Effort: Low (10 minutes)
- Auto-fix: Available
- Files: CLAUDE.md (6 replacements)
2. **Add Pre-flight Validation for Edit/Write**
- Impact: Prevents 87% of tool usage errors
- Effort: Medium (integrated in orchestrator)
- Auto-fix: Built into validation-controller agent
### Medium Priority (Address Soon)
3. **Create Path Validation Utility**
- Impact: Prevents path inconsistencies in future
- Effort: Medium (create new utility script)
- Location: lib/path_validator.py
4. **Enhance Session State Tracking**
- Impact: Better dependency tracking
- Effort: Medium (extend orchestrator)
- Benefit: 95% error prevention rate
### Low Priority (Nice to Have)
5. **Add Validation Metrics Dashboard**
- Impact: Visibility into validation effectiveness
- Effort: High (new component)
- Benefit: Data-driven improvement
## Failure Patterns Detected
### Pattern: Edit Before Read
- **Frequency**: 1 occurrence
- **Auto-fixed**: Yes
- **Prevention rule**: Enabled
- **Success rate**: 100%
### Pattern: Path Inconsistency
- **Frequency**: 6 occurrences
- **Type**: Documentation drift
- **Root cause**: Implementation changes without doc updates
- **Prevention**: Add doc consistency checks to CI/CD
## Validation Metrics
### Session Statistics
- Total operations: 48
- Successful: 46 (95.8%)
- Failed: 2 (4.2%)
- Auto-recovered: 2 (100% of failures)
### Tool Usage
- Read: 24 calls (100% success)
- Edit: 16 calls (93.8% success, 1 prerequisite violation)
- Write: 6 calls (83.3% success)
- Bash: 2 calls (100% success)
### Prevention Effectiveness
- Failures prevented: 0 (validation not yet active during session)
- Failures detected and fixed: 2
- False positives: 0
- Detection rate: 100%
## Next Steps
1. Apply high-priority fixes immediately
2. Enable pre-flight validation in orchestrator
3. Schedule medium-priority improvements
4. Monitor validation metrics for 10 tasks
5. Run /validate again to verify improvements
## Validation History
This validation compared to baseline (first validation):
- Score: 85/100 (baseline - first run)
- Issues found: 8 total (2 critical, 3 medium, 3 low)
- Auto-fix success: 100% (2/2 fixable issues)
- Time to complete: 1.2 minutes
---
**Next Validation Recommended**: After applying high-priority fixes
**Expected Score After Fixes**: 95/100
```
## When to Use
Run `/validate:all` when:
- Before releases or major changes
- After significant refactoring
- When documentation is updated
- After adding new components
- Periodically (every 10-25 tasks)
- When unusual errors occur
- To audit project health
## Integration with Autonomous Workflow
The orchestrator automatically triggers validation:
- **Pre-flight**: Before Edit/Write operations (checks prerequisites)
- **Post-error**: After tool failures (analyzes and auto-fixes)
- **Post-documentation**: After doc updates (checks consistency)
- **Periodic**: Every 25 tasks (comprehensive audit)
Users can also manually trigger full validation with `/validate:all`.
## Success Criteria
Validation passes when:
- Score ≥ 70/100
- No critical (ERROR) issues
- Tool usage compliance ≥ 90%
- Documentation consistency ≥ 80%
- All cross-references valid
- Best practices followed
## Validation Benefits
**For Users**:
- Catch issues before they cause problems
- Clear, actionable recommendations
- Auto-fix for common errors
- Improved project quality
**For Development**:
- Enforces best practices
- Prevents documentation drift
- Maintains consistency
- Reduces debugging time
**For Learning**:
- Builds failure pattern database
- Improves prevention over time
- Tracks validation effectiveness
- Continuous improvement loop

View File

@@ -0,0 +1,426 @@
---
name: validate:commands
description: Command validation and discoverability verification with automatic recovery
usage: /validate:commands [options]
category: validate
subcategory: system
---
# Command Validation and Discoverability
## Overview
The command validation system ensures all commands exist, are discoverable, and function correctly. It validates command structure, checks discoverability, and provides automatic recovery for missing commands.
This command specifically addresses issues like the missing `/monitor:dashboard` command by validating that all expected commands are present and accessible.
## Usage
```bash
/validate:commands # Validate all commands
/validate:commands --category monitor # Validate specific category
/validate:commands --missing-only # Show only missing commands
/validate:commands --discoverability # Check discoverability features
/validate:commands --recover # Auto-recover missing commands
/validate:commands --test /monitor:dashboard # Test specific command
```
## Parameters
### --category
Validate commands in a specific category only.
- **Type**: String
- **Valid values**: dev, analyze, validate, debug, learn, workspace, monitor
- **Example**: `/validate:commands --category monitor`
### --missing-only
Show only missing commands, skip validation of existing commands.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:commands --missing-only`
### --discoverability
Focus on discoverability validation (examples, descriptions, accessibility).
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:commands --discoverability`
### --recover
Automatically attempt to recover missing commands.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:commands --recover`
### --test
Test a specific command for validation.
- **Type**: String (command format: /category:name)
- **Example**: `/validate:commands --test /monitor:dashboard`
## Examples
### Basic Command Validation
```bash
/validate:commands
```
Output:
```
🔍 Command System Validation
✅ Overall Score: 96/100
📋 Commands: 23/23 present
🎯 Discoverable: 22/23 commands
📝 Valid Syntax: 23/23 commands
[WARN] Issues: 1 discoverability issue
```
### Category-Specific Validation
```bash
/validate:commands --category monitor
```
Output:
```
🔍 Monitor Commands Validation
✅ Category: monitor
📋 Expected Commands: 2
✅ Commands Found: recommend, dashboard
🎯 All Discoverable: True
📝 Syntax Valid: True
```
### Missing Commands Only
```bash
/validate:commands --missing-only
```
Output:
```
❌ Missing Commands Detected:
* /monitor:dashboard (CRITICAL)
Reason: File not found
Impact: Dashboard functionality unavailable
Recovery: Auto-recover available
* /workspace:archive (WARNING)
Reason: File not found
Impact: Workspace archive functionality missing
Recovery: Template creation available
```
### Auto-Recovery Mode
```bash
/validate:commands --recover
```
Output:
```
🔄 Automatic Command Recovery
📋 Missing Commands Found: 2
🔧 Recovery Progress:
✅ /monitor:dashboard restored from Git (commit: a4996ed)
❌ /workspace:archive recovery failed (no template available)
📊 Final Validation:
* Commands Present: 24/25
* Overall Score: 98/100 (+2 points)
```
### Discoverability Check
```bash
/validate:commands --discoverability
```
Output:
```
🔎 Command Discoverability Analysis
✅ Overall Discoverability: 87%
📊 Categories Analysis:
* dev: 100% discoverable
* analyze: 100% discoverable
* validate: 75% discoverable (2 issues)
* monitor: 50% discoverable (1 issue)
🎯 Common Issues:
* Missing usage examples: 3 commands
* Unclear descriptions: 2 commands
* No parameter docs: 5 commands
```
## Command Categories
### dev (Development Commands)
Critical for plugin development and maintenance.
- **Expected Commands**: auto, release, model-switch, pr-review
- **Critical Level**: Critical
- **Recovery Priority**: Immediate
### analyze (Analysis Commands)
Essential for code analysis and quality assessment.
- **Expected Commands**: project, quality, static, dependencies
- **Critical Level**: Critical
- **Recovery Priority**: Immediate
### validate (Validation Commands)
Core validation functionality for system integrity.
- **Expected Commands**: all, fullstack, plugin, patterns, integrity
- **Critical Level**: Critical
- **Recovery Priority**: Immediate
### debug (Debugging Commands)
Tools for debugging and troubleshooting.
- **Expected Commands**: eval, gui
- **Critical Level**: High
- **Recovery Priority**: High
### learn (Learning Commands)
Learning and analytics functionality.
- **Expected Commands**: init, analytics, performance, predict
- **Critical Level**: Medium
- **Recovery Priority**: Medium
### workspace (Workspace Commands)
Workspace organization and management.
- **Expected Commands**: organize, reports, improve
- **Critical Level**: Medium
- **Recovery Priority**: Medium
### monitor (Monitoring Commands)
System monitoring and recommendations.
- **Expected Commands**: recommend, dashboard
- **Critical Level**: Critical
- **Recovery Priority**: Immediate
## Validation Criteria
### Presence Validation
- **File Existence**: Command file exists in correct location
- **File Accessibility**: File is readable and not corrupted
- **Category Structure**: Commands organized in proper categories
### Syntax Validation
- **YAML Frontmatter**: Valid YAML with required fields
- **Markdown Structure**: Proper markdown formatting
- **Required Sections**: Essential sections present
- **Content Quality**: Adequate content length and structure
### Discoverability Validation
- **Clear Description**: Frontmatter description is clear and descriptive
- **Usage Examples**: Practical examples provided
- **Parameter Documentation**: Parameters documented (when applicable)
- **Accessibility**: Command can be discovered and understood
### Integration Validation
- **File System**: Command discoverable through file system
- **Category Organization**: Proper category placement
- **Naming Conventions**: Consistent naming patterns
- **Cross-references**: References in documentation
## Recovery Process
### Automatic Recovery
When `--recover` is enabled, missing commands are recovered using:
1. **Git History Recovery**
```bash
# Find in Git history
git log --all --full-history -- commands/monitor/dashboard.md
# Restore from commit
git checkout <commit> -- commands/monitor/dashboard.md
```
2. **Template Creation**
- Uses command templates
- Customizes with category and name
- Creates basic structure for completion
3. **Pattern-Based Recovery**
- Uses similar commands as reference
- Maintains consistency with existing commands
- Preserves category patterns
### Manual Recovery
For commands that can't be auto-recovered:
1. **Create from Template**
```markdown
---
name: monitor:dashboard
description: Launch system monitoring dashboard
usage: /monitor:dashboard [options]
category: monitor
subcategory: system
---
# Monitoring Dashboard
## Overview
Launch the autonomous agent monitoring dashboard...
```
2. **Use Similar Command**
- Copy structure from similar command
- Modify for specific functionality
- Ensure consistency with category
## Scoring System
Command validation score calculation:
- **Presence Score** (40 points): All expected commands present
- **Syntax Score** (25 points): Valid YAML and markdown structure
- **Discoverability Score** (25 points): Clear descriptions and examples
- **Integration Score** (10 points): Proper integration and organization
**Score Interpretation:**
- **90-100**: Excellent command system
- **80-89**: Good with minor issues
- **70-79**: Acceptable with some issues
- **60-69**: Needs improvement
- **0-59**: Serious command system issues
## Troubleshooting
### Missing Commands
**Symptoms**: Command validation shows missing commands
**Solutions**:
1. Run auto-recovery: `/validate:commands --recover`
2. Check Git history for deleted files
3. Create from template manually
4. Verify file system permissions
### Discoverability Issues
**Symptoms**: Commands exist but not easily discoverable
**Solutions**:
1. Add clear descriptions to frontmatter
2. Include practical usage examples
3. Document parameters clearly
4. Improve command categorization
### Syntax Errors
**Symptoms**: Invalid YAML frontmatter or markdown structure
**Solutions**:
1. Validate YAML syntax with linter
2. Check markdown formatting
3. Ensure required sections present
4. Review content quality guidelines
### File Organization Issues
**Symptoms**: Commands in wrong locations or disorganized
**Solutions**:
1. Use proper category structure
2. Follow naming conventions
3. Organize with consistent patterns
4. Run workspace organization: `/workspace:organize`
## Best Practices
### Command Development
1. **Use Templates**: Start from command templates
2. **Follow Structure**: Maintain consistent structure
3. **Include Examples**: Provide practical usage examples
4. **Document Parameters**: Clear parameter documentation
5. **Test Discoverability**: Verify command can be found and understood
### Maintenance
1. **Regular Validation**: Run command validation weekly
2. **Monitor Changes**: Validate after command modifications
3. **Backup Protection**: Ensure commands are backed up
4. **Documentation Sync**: Keep docs aligned with commands
### Organization
1. **Category Consistency**: Commands in appropriate categories
2. **Naming Patterns**: Consistent naming conventions
3. **File Structure**: Proper file organization
4. **Cross-references**: Maintain documentation links
## Integration Points
### Pre-Operation Validation
Automatically validates before:
- Command restructuring or organization
- Plugin updates affecting commands
- Release preparation
- File system operations
### Post-Operation Validation
Automatically validates after:
- Command creation or modification
- Category reorganization
- File system changes
- Version updates
### Continuous Monitoring
- Event-driven validation on file changes
- Periodic integrity checks
- Real-time missing command detection
- Automated recovery triggers
## Advanced Features
### Custom Validation Rules
```bash
# Validate with custom rules
/validate:commands --rules custom_rules.json
# Validate specific patterns
/validate:commands --pattern "*/monitor/*.md"
# Exclude specific commands
/validate:commands --exclude "*/test/*.md"
```
### Batch Operations
```bash
# Validate and fix issues
/validate:commands --fix-discoverability --add-examples
# Validate and generate report
/validate:commands --generate-report --output validation_report.md
```
## Monitoring and Analytics
Track command system health with:
- **Validation History**: Historical validation results
- **Issue Trends**: Recurring command issues
- **Recovery Success**: Auto-recovery effectiveness
- **Usage Patterns**: Command usage and discoverability
Use `/learn:performance` for analytics and `/learn:analytics` for comprehensive reporting.
## Related Commands
- `/validate:integrity` - Complete system integrity validation
- `/validate:all` - Full system validation
- `/workspace:organize` - Fix file organization issues
- `/learn:analytics` - Command system analytics
- `/monitor:recommend` - Get system improvement recommendations
## Configuration
### Validation Settings
```json
{
"command_validation": {
"auto_recover": true,
"critical_threshold": 80,
"validate_discoverability": true,
"exclude_patterns": ["*/test/*"],
"notification_level": "warning"
}
}
```
### Recovery Preferences
```json
{
"command_recovery": {
"strategies": ["git_history", "template_creation", "pattern_based"],
"create_backup_before_recovery": true,
"verify_after_recovery": true,
"notification_on_recovery": true
}
}
```

View File

@@ -0,0 +1,313 @@
---
name: validate:fullstack
description: Validate full-stack app (backend, frontend, database, API contracts) with auto-fix
delegates-to: autonomous-agent:orchestrator
---
# Validate Full-Stack Command
**Slash command**: `/validate:fullstack`
**Description**: Comprehensive validation workflow for full-stack applications. Automatically detects project structure, runs parallel validation for all components, validates API contracts, and auto-fixes common issues.
## What This Command Does
This command orchestrates a complete validation workflow for multi-component applications:
1. **Project Detection** (5-10 seconds)
- Identifies all technology components (backend, frontend, database, infrastructure)
- Detects frameworks and build tools
- Maps project structure
2. **Parallel Component Validation** (30-120 seconds)
- Backend: Dependencies, type hints, tests, API schema, database migrations
- Frontend: TypeScript, build, dependencies, bundle size
- Database: Schema, test isolation, query efficiency
- Infrastructure: Docker services, environment variables
3. **Cross-Component Validation** (15-30 seconds)
- API contract synchronization (frontend ↔ backend)
- Environment variable consistency
- Authentication flow validation
4. **Auto-Fix Application** (10-30 seconds)
- TypeScript unused imports removal
- SQLAlchemy text() wrapper addition
- React Query syntax updates
- Build configuration fixes
- Environment variable generation
5. **Quality Assessment** (5-10 seconds)
- Calculate quality score (0-100)
- Generate prioritized recommendations
- Create comprehensive report
## When to Use This Command
**Ideal scenarios**:
- Before deploying full-stack applications
- After significant code changes
- Setting up CI/CD pipelines
- Onboarding new team members
- Periodic quality checks
**Project types**:
- Monorepos with backend + frontend
- Separate repos with Docker Compose
- Microservices architectures
- Full-stack web applications
## Execution Flow
```
User runs: /validate:fullstack
v
Orchestrator Agent:
1. Load skills: fullstack-validation, code-analysis, quality-standards
2. Detect project structure
3. Create validation plan
v
Parallel Execution (background-task-manager):
+- [Frontend-Analyzer] TypeScript + Build validation
+- [Test-Engineer] Backend tests + coverage
+- [Quality-Controller] Code quality checks
+- [Build-Validator] Build config validation
v
Sequential Execution:
1. [API-Contract-Validator] Frontend ↔ Backend synchronization
2. [Quality-Controller] Cross-component quality assessment
v
Auto-Fix Loop (if quality score < 70):
1. Apply automatic fixes
2. Re-run validation
3. Repeat until quality ≥ 70 or max 3 attempts
v
Results:
- Terminal: Concise summary (15-20 lines)
- File: Detailed report saved to .claude/data/reports/
- Pattern Storage: Store results for future learning
```
## Expected Output
### Terminal Output (Concise)
```
✅ Full-Stack Validation Complete (2m 34s)
📊 Component Status:
+- Backend (FastAPI): ✅ 96/100 (42% coverage -> target 70%)
+- Frontend (React): ✅ 87/100 (0 errors, 882KB bundle)
+- API Contract: ✅ 23/23 endpoints matched
🔧 Auto-Fixed (11 issues):
[PASS] Removed 5 unused TypeScript imports
[PASS] Added text() wrapper to 3 SQL queries
[PASS] Fixed 2 React Query v5 syntax
[PASS] Generated vite-env.d.ts
[WARN] Recommended (2 actions):
1. Increase test coverage to 70% (currently 42%)
2. Add indexes to users.email, projects.created_at
🎯 Overall Score: 87/100 (Production Ready)
📄 Detailed report: .claude/data/reports/validate-fullstack-2025-10-22.md
```
### Detailed Report (File)
Saved to `.claude/data/reports/validate-fullstack-YYYY-MM-DD.md`:
- Complete project structure analysis
- All validation results with metrics
- Every issue found (auto-fixed and remaining)
- Complete recommendations with implementation examples
- Performance metrics and timing breakdown
- Pattern learning insights
- Historical comparison (if available)
## Auto-Fix Capabilities
### Automatically Fixed (No Confirmation)
| Issue | Detection | Fix | Success Rate |
|-------|-----------|-----|--------------|
| Unused TypeScript imports | ESLint | Remove import | 100% |
| Raw SQL strings | Regex | Add text() wrapper | 100% |
| ESM in .js file | File check | Rename to .mjs | 95% |
| Missing vite-env.d.ts | File check | Generate file | 100% |
| Database CASCADE | Error message | Add CASCADE | 100% |
| Missing .env.example | Env var scan | Generate file | 100% |
### Suggested Fixes (Confirmation Needed)
| Issue | Detection | Fix | Success Rate |
|-------|-----------|-----|--------------|
| React Query v4 syntax | Pattern match | Update to v5 | 92% |
| Missing type hints | mypy | Add annotations | 70% |
| Missing error handling | Pattern match | Add try-catch | 88% |
| Large bundle size | Size analysis | Code splitting | 85% |
| API contract mismatch | Schema compare | Generate types | 95% |
## Quality Score Calculation
```
Total Score (0-100):
+- Component Scores (60 points):
| +- Backend: 20 points max
| +- Frontend: 20 points max
| +- Integration: 20 points max
+- Test Coverage (15 points):
| +- 70%+ = 15, 50-69% = 10, <50% = 5
+- Auto-Fix Success (15 points):
| +- All fixed = 15, Some fixed = 10, None = 0
+- Best Practices (10 points):
+- Documentation, types, standards
Threshold:
✅ 70-100: Production Ready
[WARN] 50-69: Needs Improvement
❌ 0-49: Critical Issues
```
## Configuration Options
Create `.claude/config/fullstack-validation.json` to customize:
```json
{
"coverage_target": 70,
"quality_threshold": 70,
"auto_fix": {
"typescript_imports": true,
"sqlalchemy_text": true,
"react_query_syntax": false,
"build_configs": true
},
"parallel_validation": true,
"max_auto_fix_attempts": 3,
"skip_components": [],
"custom_validators": []
}
```
## Integration with Other Commands
**Before `/validate:fullstack`**:
- `/learn:init` - Initialize pattern learning
**After `/validate:fullstack`**:
- `/analyze:quality` - Deep dive into specific issues
- `/learn:performance` - Analyze performance trends
**Complementary**:
- `/monitor:recommend` - Get workflow suggestions based on validation results
## Success Criteria
Validation is considered successful when:
- ✅ All components validated
- ✅ Quality score ≥ 70/100
- ✅ No critical issues remaining
- ✅ API contracts synchronized
- ✅ Auto-fix success rate > 80%
- ✅ Execution time < 3 minutes
## Troubleshooting
**Validation takes too long (>5 min)**:
- Check for slow tests (timeout after 2 min)
- Disable parallel validation if causing issues
- Skip non-critical components
**Auto-fix failures**:
- Review `.claude/data/reports/` for detailed error messages
- Check autofix-patterns.json for pattern success rates
- Manual fixes may be required for complex issues
**Quality score unexpectedly low**:
- Review individual component scores
- Check test coverage (often the bottleneck)
- Review recommendations for quick wins
## Pattern Learning
This command automatically stores patterns for:
- Project structure (for faster detection next time)
- Common issues (for better detection)
- Auto-fix success rates (for reliability improvement)
- Validation performance (for optimization)
After 5-10 runs on similar projects, validation becomes significantly faster and more accurate.
## Example Use Cases
**Use Case 1: Pre-Deployment Check**
```bash
/validate:fullstack
# Wait for validation
# Review score and recommendations
# If score ≥ 70: Deploy
# If score < 70: Address critical issues and re-validate
```
**Use Case 2: CI/CD Integration**
```bash
# In CI pipeline
claude-code /validate:fullstack --ci-mode
# Exit code 0 if score ≥ 70
# Exit code 1 if score < 70
```
**Use Case 3: Code Review Preparation**
```bash
/validate:fullstack
# Auto-fixes applied automatically
# Review recommendations
# Commit fixes
# Create PR with validation report
```
## Performance Benchmarks
Typical execution times for different project sizes:
| Project Size | Components | Validation Time |
|--------------|------------|-----------------|
| Small | Backend + Frontend | 45-60 seconds |
| Medium | Backend + Frontend + DB | 90-120 seconds |
| Large | Microservices + Frontend | 120-180 seconds |
| Extra Large | Complex monorepo | 180-240 seconds |
Auto-fix adds 10-30 seconds depending on issue count.
## Version History
- **v2.0.0**: Full-stack validation with auto-fix capabilities
- **v2.2.0** (planned): Docker container validation
- **v2.2.0** (planned): Security vulnerability scanning
- **v2.3.0** (planned): Performance profiling integration
---
**Note**: This command requires the following agents to be available:
- `autonomous-agent:orchestrator`
- `autonomous-agent:frontend-analyzer`
- `autonomous-agent:api-contract-validator`
- `autonomous-agent:build-validator`
- `autonomous-agent:test-engineer`
- `autonomous-agent:quality-controller`
- `autonomous-agent:background-task-manager`
All agents are included in the autonomous-agent plugin v2.0+.

View File

@@ -0,0 +1,306 @@
---
name: validate:integrity
description: Comprehensive integrity validation and automatic recovery for missing components
usage: /validate:integrity [options]
category: validate
subcategory: system
---
# Comprehensive Integrity Validation
## Overview
The integrity validation command provides comprehensive analysis of plugin integrity with automatic recovery capabilities. It detects missing components, validates system structure, and can automatically restore lost components using multiple recovery strategies.
This command prevents issues like the missing `/monitor:dashboard` command by maintaining continuous integrity monitoring and providing immediate recovery options.
## Usage
```bash
/validate:integrity --auto-recover # Validate and auto-recover missing components
/validate:integrity --dry-run # Validate without making changes
/validate:integrity --critical-only # Check only critical components
/validate:integrity --detailed # Show detailed validation results
/validate:integrity --backup-check # Check backup system integrity
```
## Parameters
### --auto-recover
Automatically attempt to recover any missing components found during validation.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:integrity --auto-recover`
### --dry-run
Perform validation without executing any recovery operations.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:integrity --dry-run`
### --critical-only
Only validate critical components (core agents, essential commands, key configs).
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:integrity --critical-only`
### --detailed
Show detailed validation results including all issues and recommendations.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:integrity --detailed`
### --backup-check
Validate the backup system integrity and check for available backups.
- **Type**: Flag
- **Default**: False
- **Example**: `/validate:integrity --backup-check`
## Examples
### Basic Integrity Check
```bash
/validate:integrity
```
Output:
```
🔍 Plugin Integrity Validation
✅ Overall Integrity: 92/100
📊 Components: 56/58 present
[WARN] Issues: 2 non-critical
📦 Backups: 3 recent backups available
💡 Recommendations: 2 improvement suggestions
```
### Auto-Recovery Mode
```bash
/validate:integrity --auto-recover
```
Output:
```
🔄 Automatic Recovery Mode
📋 Missing Components Found:
* /monitor:dashboard (CRITICAL)
* /commands/workspace/archive (WARNING)
🔧 Recovery Attempting:
✅ /monitor:dashboard restored from backup (backup_20250127_143022)
❌ /commands/workspace:archive recovery failed (no template available)
📊 Final Integrity: 98/100 (+6 points)
```
### Critical Components Only
```bash
/validate:integrity --critical-only
```
Output:
```
🔍 Critical Components Validation
✅ All critical components present
📋 Critical Inventory:
* Commands: 22/22 present
* Agents: 7/7 present
* Core Skills: 6/6 present
* Plugin Config: 1/1 present
```
## Output Format
### Summary Section
- **Overall Integrity**: System integrity score (0-100)
- **Components Present**: Found vs. expected component count
- **Issues**: Number and severity of detected issues
- **Backup Status**: Availability and health of backup system
### Detailed Results (when using --detailed)
- **Component Analysis**: Breakdown by category (commands, agents, skills, configs)
- **Missing Components**: List of missing components with severity levels
- **Integrity Issues**: Detailed description of each issue
- **Recovery Options**: Available recovery strategies for each issue
### Recovery Results (when using --auto-recover)
- **Recovery Session**: Session ID and timestamp
- **Components Recovered**: Successfully recovered components
- **Failed Recoveries**: Components that couldn't be recovered
- **Recovery Strategies**: Strategies used and their success rates
## Integrity Scoring
The integrity score is calculated based on:
- **Component Presence** (40 points): All expected components present
- **Discoverability** (25 points): Components are discoverable and accessible
- **System Structure** (20 points): Proper file organization and structure
- **Backup Coverage** (15 points): Adequate backup protection exists
**Score Interpretation:**
- **90-100**: Excellent integrity, no issues
- **80-89**: Good integrity, minor issues
- **70-79**: Acceptable integrity, some issues present
- **60-69**: Poor integrity, significant issues
- **0-59**: Critical integrity problems
## Recovery Strategies
The validation system uses multiple recovery strategies in order of preference:
1. **Backup Restore** (95% success rate)
- Restores from recent automated backups
- Preserves original content and metadata
- Fastest recovery option
2. **Git Recovery** (85% success rate)
- Recovers from Git history
- Useful for recently deleted components
- Preserves version history
3. **Template Creation** (70% success rate)
- Creates components from templates
- Provides basic structure for new components
- Requires manual customization
4. **Pattern-Based** (60% success rate)
- Uses similar components as reference
- Maintains consistency with existing components
- May need manual adjustments
5. **Manual Guidance** (100% guidance rate)
- Provides step-by-step manual recovery instructions
- References similar existing components
- Includes best practices and examples
## Integration Points
### Pre-Operation Validation
Automatically triggered before:
- `/workspace:improve` - Plugin modifications
- `/dev:release` - Release preparation
- Major command restructuring
- Agent or skill modifications
### Post-Operation Validation
Automatically triggered after:
- File system operations
- Command modifications
- Plugin updates
- Version releases
### Continuous Monitoring
- Periodic integrity checks (configurable interval)
- Event-driven validation after file changes
- Real-time missing component detection
## Best Practices
### Prevention
1. **Run regularly**: Perform weekly integrity checks
2. **Auto-recover**: Enable auto-recovery for critical issues
3. **Backup verification**: Regularly verify backup system health
4. **Monitor trends**: Track integrity score over time
### Response Protocol
1. **Critical issues**: Immediate response with auto-recovery
2. **High issues**: Review and address within 24 hours
3. **Medium issues**: Plan fixes in next maintenance window
4. **Low issues**: Include in regular improvement cycle
### System Health
1. **Maintain 90+ score**: Target excellent integrity
2. **Zero missing critical**: Never accept missing critical components
3. **Regular backups**: Ensure recent backups available
4. **Documentation sync**: Keep documentation aligned with actual structure
## Troubleshooting
### Recovery Failures
When auto-recovery fails:
1. Check backup availability: `/validate:integrity --backup-check`
2. Verify Git repository status: `git status`
3. Review manual guidance provided
4. Consider manual creation using templates
### Validation Errors
Common validation issues:
1. **File permission errors**: Check file system permissions
2. **Locked files**: Close other programs using plugin files
3. **Git conflicts**: Resolve Git conflicts before validation
4. **Corrupted backups**: Verify backup system integrity
### Performance Issues
If validation is slow:
1. Use `--critical-only` for faster checks
2. Reduce scope with specific category validation
3. Check system resources and disk space
4. Verify plugin directory isn't excessively large
## Related Commands
- `/validate:commands` - Command-specific validation
- `/validate:all` - Full system validation
- `/workspace:organize` - File organization fixes
- `/dev:auto "validate integrity"` - Automated integrity management
## Configuration
### Validation Settings
```json
{
"validation": {
"auto_recover": true,
"critical_threshold": 70,
"backup_check_interval": "daily",
"notification_level": "warning"
}
}
```
### Recovery Preferences
```json
{
"recovery": {
"preferred_strategies": ["backup_restore", "git_recovery"],
"max_recovery_attempts": 3,
"require_confirmation": false,
"create_backup_before_recovery": true
}
}
```
## Advanced Usage
### Custom Validation Profiles
```bash
# Create custom validation profile
/validate:integrity --profile production --critical-only
# Validate specific categories
/validate:integrity --categories commands,agents --detailed
# Validate with custom thresholds
/validate:integrity --threshold 85 --strict-mode
```
### Batch Operations
```bash
# Validate and create recovery plan
/validate:integrity --dry-run --save-plan
# Execute recovery from saved plan
/validate:integrity --execute-plan recovery_plan_20250127.json
```
## Monitoring and Analytics
The integrity validation maintains comprehensive analytics:
- **Historical Trends**: Track integrity score over time
- **Issue Patterns**: Identify recurring component loss
- **Recovery Success**: Monitor recovery strategy effectiveness
- **System Health**: Overall plugin health assessment
Use `/learn:performance` to view detailed analytics and `/learn:analytics` for comprehensive reporting.

View File

@@ -0,0 +1,285 @@
---
name: validate:patterns
description: Validate pattern learning database integrity and generate health reports
delegates-to: autonomous-agent:orchestrator
---
# Command: `/validate:patterns`
Validates the pattern learning system across all commands and agents. Ensures patterns are being stored correctly, consistently formatted, and effectively used for improving performance over time.
## Purpose
- Validate pattern learning is working across all commands
- Check pattern format consistency and completeness
- Analyze learning effectiveness and trends
- Identify commands that aren't storing patterns
- Generate comprehensive learning analytics
## What It Does
### 1. **Command Coverage Validation** (10-20 seconds)
- Scan all commands in `commands/` directory
- Check which commands store patterns vs. utility commands
- Validate pattern storage code presence
- Identify missing pattern integration
### 2. **Agent Learning Validation** (10-15 seconds)
- Verify all agents contribute to pattern learning
- Check learning-engine integration points
- Validate agent effectiveness tracking
- Ensure proper handoff protocols
### 3. **Pattern Storage Analysis** (15-30 seconds)
- Validate `.claude-patterns/patterns.json` format
- Check for required fields and data types
- Analyze pattern quality and completeness
- Detect duplicate or corrupted patterns
### 4. **Learning Effectiveness Metrics** (10-20 seconds)
- Calculate pattern reuse rates
- Analyze success rates by task type
- Track skill effectiveness over time
- Identify improvement trends
### 5. **Cross-Reference Validation** (10-15 seconds)
- Validate skill references in patterns
- Check agent consistency with stored patterns
- Verify tool usage compliance
- Ensure documentation alignment
### 6. **Learning Analytics Report** (20-40 seconds)
- Generate comprehensive learning dashboard
- Create visualizations and charts
- Provide improvement recommendations
- Export data for external analysis
## Usage
```bash
# Basic pattern validation
/validate:patterns
# Include detailed analytics (slower but comprehensive)
/validate:patterns --analytics
# Quick validation skip analytics
/validate:patterns --quick
# Validate specific command or agent
/validate:patterns --filter orchestrator
/validate:patterns --filter release-dev
```
## Output
### Terminal Summary (concise)
```
Pattern Learning Validation Complete ✅
+- Commands Validated: 18/18 (100%)
+- Pattern Storage: Healthy ✅
+- Learning Effectiveness: 94% ✅
+- Issues Found: 0 critical, 2 minor
+- Duration: 1m 45s
📊 Full analytics: .claude/data/reports/validate-patterns-2025-01-15.md
```
### Detailed Report (file)
- Command-by-command validation results
- Pattern storage format validation
- Learning effectiveness metrics with charts
- Agent performance tracking
- Specific issues and fixes needed
- Trend analysis over time
## Validation Categories
### 1. Commands Pattern Storage
**Analysis Commands** (should store patterns):
- `/analyze:project`
- `/analyze:quality`
- `/validate:fullstack`
- `/dev:pr-review`
- And 12 more...
**Utility Commands** (don't store patterns - expected):
- `/monitor:dashboard` - Display only
- `/workspace:reports` - File management only
### 2. Pattern Format Validation
Required fields checked:
```json
{
"task_type": "string",
"context": "object",
"execution": {
"skills_used": "array",
"agents_delegated": "array",
"approach_taken": "string"
},
"outcome": {
"success": "boolean",
"quality_score": "number",
"duration_ms": "number"
},
"reuse_count": "number",
"last_used": "string"
}
```
### 3. Learning Effectiveness Metrics
- **Pattern Reuse Rate**: How often patterns are reused
- **Success Rate by Task Type**: Performance across different tasks
- **Skill Effectiveness**: Which skills perform best
- **Agent Performance**: Agent reliability and speed
- **Improvement Trend**: Learning progress over time
## Integration
The `/validate-patterns` command integrates with:
- **learning-engine agent**: Validates pattern capture and storage
- **pattern-learning skill**: Validates pattern format and structure
- **performance-analytics skill**: Generates learning metrics
- **orchestrator**: Uses validation to improve pattern selection
## Expected Validation Results
### Successful Validation (what you should see)
- 18/18 commands validated
- All analysis commands storing patterns
- Pattern format consistent
- Learning effectiveness > 80%
- No critical issues
### Common Issues and Fixes
1. **Missing Pattern Storage**
- Issue: Command not storing patterns when it should
- Fix: Add pattern learning integration
2. **Format Inconsistencies**
- Issue: Missing required fields in patterns
- Fix: Update pattern generation code
3. **Low Reuse Rate**
- Issue: Patterns not being reused effectively
- Fix: Improve pattern matching algorithm
4. **Storage Location Issues**
- Issue: Patterns not in `.claude-patterns/`
- Fix: Update storage path configuration
## Analytics Dashboard
When using `--analytics` flag, generates:
### Learning Metrics
- Total patterns stored: 247
- Average reuse count: 3.2
- Success rate: 89%
- Most reused pattern: "refactor-auth-module" (12 times)
### Skill Performance
```
Top Performing Skills:
1. code-analysis (94% success, 45 uses)
2. quality-standards (91% success, 38 uses)
3. pattern-learning (89% success, 52 uses)
```
### Agent Performance
```
Agent Reliability:
1. orchestrator: 96% success
2. code-analyzer: 94% success
3. quality-controller: 92% success
```
## Usage Examples
### Example 1: Basic Validation
```bash
User: /validate:patterns
System: ✅ Pattern learning system healthy
Commands storing patterns: 16/16
Pattern format: Valid
Learning effectiveness: 91%
```
### Example 2: With Analytics
```bash
User: /validate:patterns --analytics
System: 📊 Generated comprehensive analytics
Learning trends: Improving (+12% over 30 days)
Top skill: code-analysis (95% success)
Recommendation: Increase pattern reuse threshold
```
### Example 3: Filter Validation
```bash
User: /validate:patterns --filter orchestrator
System: ✅ Orchestrator pattern integration validated
Patterns contributed: 89
Effectiveness score: 96%
Integration quality: Excellent
```
## When to Use
Run `/validate:patterns` when:
- After implementing new commands or agents
- Suspecting pattern learning issues
- Regular system health checks
- Before major releases
- Analyzing learning effectiveness
## Automation
The orchestrator can automatically run `/validate:patterns`:
- Every 50 tasks to ensure system health
- When learning effectiveness drops below 75%
- After adding new commands or agents
- During system diagnostics
## Troubleshooting
### Common Validation Failures
1. **Pattern Database Missing**
```
Error: .claude-patterns/patterns.json not found
Fix: Run /learn:init to initialize
```
2. **Permission Issues**
```
Error: Cannot read pattern database
Fix: Check file permissions in .claude-patterns/
```
3. **Corrupted Patterns**
```
Error: Invalid JSON in patterns
Fix: Manual repair or reset patterns
```
## Related Commands
- `/learn:init` - Initialize pattern learning system
- `/analyze:project` - Analyze project and learn patterns
- `/analyze:quality` - Check overall system quality
## See Also
- [Learning-Engine Agent](../agents/learning-engine.md)
- [Pattern-Learning Skill](../skills/pattern-learning/SKILL.md)
- [Analytics Dashboard Guide](../docs/guidelines/ANALYTICS_GUIDE.md)
---

376
commands/validate/plugin.md Normal file
View File

@@ -0,0 +1,376 @@
---
name: validate:plugin
description: Validate Claude Code plugin against official guidelines
delegates-to: autonomous-agent:orchestrator
---
# Validate Claude Plugin
Comprehensive validation for Claude Code plugins against official development guidelines to prevent installation failures and ensure marketplace compatibility.
## Command: `/validate:plugin`
Validates the current plugin against Claude Code official guidelines, checking for common installation failures, compatibility issues, and marketplace requirements.
## How It Works
1. **Plugin Manifest Validation**: Validates .claude-plugin/plugin.json against Claude Code schema requirements
2. **Directory Structure Check**: Ensures proper plugin directory layout and required files
3. **File Format Compliance**: Validates Markdown files with YAML frontmatter
4. **Command Execution Validation**: Checks agent delegation and command-to-agent mappings
5. **Installation Readiness**: Checks for common installation blockers
6. **Cross-Platform Compatibility**: Validates plugin works on Windows, Linux, and Mac
### Command Execution Validation Details
The validator now checks for command execution issues that cause runtime failures:
**Agent Delegation Validation**:
- Verifies all command frontmatter includes proper `delegates-to` field
- Validates referenced agents exist in the `agents/` directory
- Checks agent identifiers use correct prefix format (`autonomous-agent:name`)
- Ensures command documentation matches delegation targets
**Common Command Execution Failures Detected**:
- Missing `delegates-to` field in command YAML frontmatter
- Agent names without `autonomous-agent:` prefix
- References to non-existent agent files
- Mismatched delegation between documentation and frontmatter
## Validation Criteria
### Critical Issues (Installation Blockers)
- Missing or invalid plugin.json manifest
- Invalid JSON syntax in manifest
- Missing required fields (name, version, description, author)
- Invalid version format (must be x.y.z semantic versioning)
- Non-UTF-8 file encoding
- Missing .claude-plugin directory
### Command Execution Issues (Runtime Failures)
- Invalid agent delegation references in commands
- Missing or incorrect agent identifiers
- Commands that reference non-existent agents
- Broken command-to-agent mappings
- Missing `delegates-to` field in command frontmatter
### Warnings (Non-Critical)
- Long file paths (Windows limit 260 characters)
- Missing optional YAML frontmatter fields
- Inconsistent line endings
- Very long or short descriptions
- Agent names without proper prefixes in documentation
### Quality Score
- **100**: Perfect - No issues found
- **90-99**: Ready - Minor warnings only
- **70-89**: Usable - Some fixes recommended
- **< 70**: Needs fixes before release
## Usage
### Quick Validation
```bash
/validate:plugin
```
### Strict Validation (treat warnings as errors)
```bash
/validate:plugin --strict
```
### Validate Specific Plugin Directory
```bash
/validate:plugin --dir /path/to/plugin
```
## Expected Output
### Successful Validation (Perfect)
```
============================================================
VALIDATE CLAUDE PLUGIN RESULTS
============================================================
[+] Plugin Validation PASSED - Ready for Release!
Validation Summary:
+- Plugin Manifest: [OK] Valid JSON schema
+- Directory Structure: [OK] Compliant layout
+- File Formats: [OK] Valid Markdown/YAML
+- Installation Readiness: [OK] No blockers
+- Cross-Platform Compatibility: [OK] Ready for all platforms
Quality Score: 100/100 (Perfect)
Detailed report: .claude/data/reports/validate-claude-plugin-2025-10-23.md
Completed in 1.2 minutes
[+] Assessment stored in pattern database for dashboard monitoring
[+] Plugin is fully compliant with Claude Code guidelines
Ready for immediate distribution and installation
```
### Issues Found
```
============================================================
VALIDATE CLAUDE PLUGIN RESULTS
============================================================
[WARN] Plugin Validation Issues Found
📊 Validation Summary:
+- Plugin Manifest: ❌ 2 critical issues
+- Directory Structure: ✅ Compliant layout
+- File Formats: [WARN] 3 warnings
+- Installation Readiness: ❌ 2 blockers
+- Cross-Platform Compatibility: ✅ Ready for all platforms
🚨 Critical Issues (Installation Blockers):
* Missing required field: version
* Invalid JSON syntax: trailing comma in plugin.json
* File encoding error: agents/orchestrator.md (not UTF-8)
[WARN] Command Execution Issues (Runtime Failures):
* Invalid agent delegation: commands/quality-check.md references 'orchestrator' (should be 'autonomous-agent:orchestrator')
* Missing delegates-to field: commands/auto-analyze.md lacks agent delegation specification
* Non-existent agent: commands/example.md references 'missing-agent' (file not found)
[WARN] Warnings:
* YAML frontmatter missing in 2 agent files
* Long file paths (Windows limit): 3 files
* Description too short (< 10 chars)
🔧 Auto-Fix Available:
* JSON syntax errors: Can be automatically corrected
* Missing required fields: Can be added with defaults
* File encoding: Can be converted to UTF-8
* Agent delegation errors: Can auto-correct prefixes and add missing fields
🛠️ Command Execution Fixes Applied:
* Fixed commands/quality-check.md: Added `delegates-to: autonomous-agent:orchestrator`
* Auto-corrected agent identifier: `orchestrator` -> `autonomous-agent:orchestrator`
* Updated command documentation: Explicit agent references with proper prefixes
🎯 Quality Score: 65/100 (Needs Fixes)
💡 Recommendations:
1. [HIGH] Fix JSON syntax in plugin.json
2. [HIGH] Add missing version field (use semantic versioning)
3. [HIGH] Convert files to UTF-8 encoding
4. [MED] Add missing YAML frontmatter to agents
5. [LOW] Reduce file path lengths
📄 Detailed report: .claude/data/reports/validate-claude-plugin-2025-10-23.md
⏱ Completed in 1.5 minutes
❌ Plugin needs fixes before release
Run recommended fixes and re-validate
```
## Files Created
The validation command creates detailed reports in:
1. **Console Output**: Concise summary with key findings
2. **Detailed Report**: `.claude/data/reports/validate-claude-plugin-YYYY-MM-DD.md`
3. **JSON Report**: Machine-readable validation results
## Integration with Development Workflow
### Pre-Release Checklist
```bash
# Required validation before any release
/validate:plugin --strict
# Only proceed if validation passes
if [ $? -eq 0 ]; then
echo "✅ Ready for release"
else
echo "❌ Fix issues before release"
exit 1
fi
```
### Continuous Integration
```yaml
# GitHub Actions example
- name: Validate Claude Plugin
run: |
/validate:plugin --strict
if [ $? -ne 0 ]; then
echo "Plugin validation failed - blocking release"
exit 1
fi
```
### Local Development
```bash
# During development
make validate-plugin # Custom command that runs validation
# Before committing changes
git add .
git commit -m "Update plugin (validated: ✅)"
```
## Common Installation Failure Prevention
The validator specifically targets the most common causes of plugin installation failures:
### 1. JSON Syntax Errors
```json
// ❌ INVALID (trailing comma)
{
"name": "my-plugin",
"version": "1.0.0",
}
// ✅ VALID
{
"name": "my-plugin",
"version": "1.0.0"
}
```
### 2. Missing Required Fields
```json
// ❌ MISSING VERSION
{
"name": "my-plugin",
"description": "A great plugin"
}
// ✅ COMPLETE
{
"name": "my-plugin",
"version": "1.0.0",
"description": "A great plugin",
"author": "Developer Name"
}
```
### 3. File Encoding Issues
```bash
# Check file encoding
file .claude-plugin/plugin.json
# Convert to UTF-8 if needed
iconv -f ISO-8859-1 -t UTF-8 input.txt > output.txt
```
### 4. Directory Structure
```
my-plugin/
+-- .claude-plugin/
| +-- plugin.json # REQUIRED
+-- agents/ # OPTIONAL
+-- skills/ # OPTIONAL
+-- commands/ # OPTIONAL
+-- lib/ # OPTIONAL
```
## Marketplace Compatibility
The validation ensures compatibility with Claude Code plugin marketplaces:
### Installation Methods Supported
- ✅ GitHub repository URLs
- ✅ Git repository URLs
- ✅ Local directory paths
- ✅ Team distribution sources
- ✅ Marketplace listing files
### Requirements Met
- ✅ JSON manifest schema compliance
- ✅ Semantic versioning format
- ✅ UTF-8 encoding throughout
- ✅ Cross-platform file paths
- ✅ Proper directory structure
- ✅ Valid file formats
## Error Recovery
### Auto-Fix Capabilities
The validator can automatically correct many common issues:
1. **JSON Syntax**: Remove trailing commas, fix quotes
2. **Missing Fields**: Add defaults (version: "1.0.0", author: "Unknown")
3. **File Encoding**: Convert to UTF-8 automatically
4. **Line Endings**: Normalize line endings for platform
5. **Agent Delegation**: Auto-correct agent identifier prefixes (`orchestrator` -> `autonomous-agent:orchestrator`)
6. **Command Frontmatter**: Add missing `delegates-to` fields based on command content analysis
7. **Agent Mapping**: Verify and fix command-to-agent mappings by cross-referencing agents directory
### Manual Fixes Required
1. **Structural Issues**: Directory reorganization
2. **Content Issues**: Improve documentation quality
3. **Naming Conflicts**: Resolve duplicate names
4. **Version Conflicts**: Semantic versioning corrections
## Troubleshooting
### Common Validation Failures
**Error**: "Missing plugin manifest"
- **Cause**: No `.claude-plugin/plugin.json` file
- **Fix**: Create manifest with required fields
**Error**: "Invalid JSON syntax"
- **Cause**: Syntax errors in plugin.json
- **Fix**: Use JSON linter, check for trailing commas
**Error**: "Missing required fields"
- **Cause**: Required JSON fields absent
- **Fix**: Add name, version, description, author fields
**Error**: "File encoding error"
- **Cause**: Non-UTF-8 encoded files
- **Fix**: Convert all files to UTF-8 encoding
**Error**: "Agent type not found" (Runtime Command Failure)
- **Cause**: Command references incorrect agent identifier
- **Example**: `/quality-check` tries to delegate to `orchestrator` instead of `autonomous-agent:orchestrator`
- **Fix**: Update command frontmatter with correct `delegates-to: autonomous-agent:agent-name`
**Error**: "Missing delegates-to field"
- **Cause**: Command YAML frontmatter lacks delegation specification
- **Fix**: Add `delegates-to: autonomous-agent:agent-name` to command frontmatter
**Error**: "Command execution failed"
- **Cause**: Referenced agent file doesn't exist in `agents/` directory
- **Fix**: Create missing agent file or update delegation to existing agent
### Getting Help
```bash
# Detailed validation with debugging
/validate:plugin --debug
# Check specific file
/validate:plugin --file .claude-plugin/plugin.json
# Show validation rules
/validate:plugin --show-rules
```
## Best Practices
### Development Workflow
1. **Create Plugin Structure**: Follow standard layout
2. **Write Manifest**: Complete all required fields
3. **Add Content**: Agents, skills, commands
4. **Validate**: Run `/validate:plugin`
5. **Fix Issues**: Address any problems found
6. **Re-validate**: Ensure all issues resolved
7. **Release**: Publish with confidence
### Quality Assurance
- Run validation before every commit
- Use `--strict` mode for pre-release checks
- Monitor validation scores over time
- Keep documentation up to date
- Test on multiple platforms
---
This validation command ensures your Claude Code plugin meets official guidelines and will install successfully across all supported platforms and marketplace types.

753
commands/validate/web.md Normal file
View File

@@ -0,0 +1,753 @@
---
name: validate:web
description: Validate web pages and detect JavaScript errors automatically using headless browser automation
category: validation
---
# Validate Web Command
**Slash command**: `/validate:web`
Automatically validate web pages (like dashboard.py) and detect JavaScript errors, console issues, and performance problems without manual browser inspection.
## Usage
```bash
/validate:web <URL> [options]
```
## Examples
```bash
# Validate local dashboard
/validate:web http://127.0.0.1:5000
# Validate with detailed output
/validate:web http://127.0.0.1:5000 --verbose
# Validate and auto-fix issues
/validate:web http://127.0.0.1:5000 --auto-fix
# Save validation report
/validate:web http://127.0.0.1:5000 --report
# Crawl and validate all subpages
/validate:web http://127.0.0.1:5000 --crawl
# Crawl with depth limit
/validate:web http://127.0.0.1:5000 --crawl --max-depth 2
# Crawl specific subpages only
/validate:web http://127.0.0.1:5000 --crawl --include "/api/*,/analytics/*"
# Exclude certain paths from crawling
/validate:web http://127.0.0.1:5000 --crawl --exclude "/admin/*,/debug/*"
```
## Implementation
```python
#!/usr/bin/env python3
import sys
import os
import json
import subprocess
from pathlib import Path
from datetime import datetime
# Add plugin lib directory to path
plugin_lib = Path(__file__).parent.parent.parent / 'lib'
sys.path.insert(0, str(plugin_lib))
try:
from web_page_validator import WebPageValidator, format_validation_report
VALIDATOR_AVAILABLE = True
except ImportError:
VALIDATOR_AVAILABLE = False
# Import additional modules for crawling
try:
from urllib.parse import urljoin, urlparse, urlunparse
from fnmatch import fnmatch
import re
import time
from collections import deque
CRAWLING_AVAILABLE = True
except ImportError:
CRAWLING_AVAILABLE = False
def crawl_and_validate(validator, start_url, max_depth=3, max_pages=50,
include_patterns=None, exclude_patterns=None,
same_domain=True, wait_for_load=3, verbose=False):
"""Crawl and validate all pages discovered from the start URL."""
if not CRAWLING_AVAILABLE:
raise ImportError("Required crawling modules not available")
from urllib.parse import urljoin, urlparse, urlunparse
from fnmatch import fnmatch
import time
from collections import deque
start_domain = urlparse(start_url).netloc
visited = set()
queue = deque([(start_url, 0)]) # (url, depth)
results = []
print(f"[INFO] Starting crawl from: {start_url}")
print(f"[INFO] Domain: {start_domain}")
print()
while queue and len(results) < max_pages:
current_url, depth = queue.popleft()
# Skip if already visited
if current_url in visited:
continue
visited.add(current_url)
# Check depth limit
if depth > max_depth:
continue
# Check domain restriction
if same_domain and urlparse(current_url).netloc != start_domain:
continue
# Check include/exclude patterns
if not should_crawl_url(current_url, include_patterns, exclude_patterns):
continue
print(f"[INFO] Validating (depth {depth}): {current_url}")
try:
# Validate the current page
result = validator.validate_url(current_url, wait_for_load=wait_for_load)
result.depth = depth # Add depth information
results.append(result)
# Show progress
status = "✅ PASS" if result.success else "❌ FAIL"
errors = len(result.console_errors) + len(result.javascript_errors)
print(f"[{status}] {errors} errors, {len(result.console_warnings)} warnings")
# Extract links for further crawling (only from successful pages)
if result.success and depth < max_depth:
links = extract_links_from_page(current_url, result.page_content or "")
for link in links:
if link not in visited and len(visited) + len(queue) < max_pages:
queue.append((link, depth + 1))
# Brief pause to avoid overwhelming the server
time.sleep(0.5)
except Exception as e:
print(f"[ERROR] Failed to validate {current_url}: {e}")
# Create a failed result object
from types import SimpleNamespace
failed_result = SimpleNamespace(
url=current_url,
success=False,
load_time=0,
page_title="Error",
console_errors=[f"Validation failed: {e}"],
console_warnings=[],
javascript_errors=[],
network_errors=[],
depth=depth,
page_content=""
)
results.append(failed_result)
print()
print(f"[INFO] Crawling completed: {len(results)} pages validated")
print(f"[INFO] Pages discovered: {len(visited)}")
return results
def should_crawl_url(url, include_patterns=None, exclude_patterns=None):
"""Check if URL should be crawled based on include/exclude patterns."""
from urllib.parse import urlparse
parsed = urlparse(url)
path = parsed.path
# Skip non-HTML resources
if any(path.endswith(ext) for ext in ['.css', '.js', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.pdf', '.zip']):
return False
# Skip hash fragments
if parsed.fragment:
return False
# Check include patterns
if include_patterns:
if not any(fnmatch(path, pattern.strip()) for pattern in include_patterns):
return False
# Check exclude patterns
if exclude_patterns:
if any(fnmatch(path, pattern.strip()) for pattern in exclude_patterns):
return False
return True
def extract_links_from_page(base_url, page_content):
"""Extract all valid links from page content."""
from urllib.parse import urljoin, urlparse
import re
if not page_content:
return []
# Extract links using regex patterns
link_patterns = [
r'href=["\']([^"\']+)["\']', # href attributes
r'action=["\']([^"\']+)["\']', # form actions
r'src=["\']([^"\']+)["\']', # src attributes (for some dynamic content)
]
links = set()
for pattern in link_patterns:
matches = re.findall(pattern, page_content, re.IGNORECASE)
for match in matches:
# Convert relative URLs to absolute
absolute_url = urljoin(base_url, match)
# Validate URL
parsed = urlparse(absolute_url)
if parsed.scheme in ['http', 'https'] and parsed.netloc:
links.add(absolute_url)
return list(links)
def display_crawling_results(results):
"""Display comprehensive crawling results."""
if not results:
print("[ERROR] No pages were validated")
return
# Sort results by URL for consistent output
results.sort(key=lambda r: r.url)
# Summary statistics
total_pages = len(results)
successful_pages = sum(1 for r in results if r.success)
failed_pages = total_pages - successful_pages
total_errors = sum(len(r.console_errors) + len(r.javascript_errors) for r in results)
total_warnings = sum(len(r.console_warnings) for r in results)
print("=" * 80)
print(f"🕷️ CRAWLING VALIDATION RESULTS")
print("=" * 80)
print(f"Total Pages: {total_pages}")
print(f"Successful: {successful_pages}")
print(f"Failed: {failed_pages}")
print(f"Total Errors: {total_errors}")
print(f"Total Warnings: {total_warnings}")
print(f"Success Rate: {(successful_pages/total_pages)*100:.1f}%")
print()
# Show failed pages first
failed_results = [r for r in results if not r.success]
if failed_results:
print("❌ FAILED PAGES:")
for i, result in enumerate(failed_results, 1):
print(f" {i}. {result.url}")
print(f" Status: FAILED")
errors = len(result.console_errors) + len(result.javascript_errors)
if errors > 0:
print(f" Errors: {errors}")
print()
# Show successful pages with warnings
successful_with_warnings = [r for r in results if r.success and
(len(r.console_warnings) > 0 or
len(r.console_errors) > 0 or
len(r.javascript_errors) > 0)]
if successful_with_warnings:
print("[WARN] SUCCESSFUL PAGES WITH ISSUES:")
for i, result in enumerate(successful_with_warnings[:10], 1): # Limit to first 10
errors = len(result.console_errors) + len(result.javascript_errors)
warnings = len(result.console_warnings)
status_parts = []
if errors > 0:
status_parts.append(f"{errors} errors")
if warnings > 0:
status_parts.append(f"{warnings} warnings")
print(f" {i}. {result.url}")
print(f" Issues: {', '.join(status_parts)}")
if len(successful_with_warnings) > 10:
print(f" ... and {len(successful_with_warnings) - 10} more pages with issues")
print()
# Show top errors across all pages
all_errors = []
for result in results:
for error in result.console_errors:
all_errors.append(f"[{error.level.upper()}] {error.message[:100]}")
for error in result.javascript_errors:
all_errors.append(f"[JS] {str(error)[:100]}")
if all_errors:
print("🔍 TOP ERRORS ACROSS ALL PAGES:")
from collections import Counter
error_counts = Counter(all_errors)
for i, (error, count) in enumerate(error_counts.most_common(10), 1):
print(f" {i}. ({count}×) {error}")
print()
# Overall status
if successful_pages == total_pages:
print("🎉 OVERALL STATUS: ALL PAGES PASSED ✅")
elif successful_pages > total_pages * 0.8:
print("✅ OVERALL STATUS: MOSTLY HEALTHY ({successful_pages}/{total_pages} pages passed)")
else:
print("[WARN] OVERALL STATUS: NEEDS ATTENTION ({successful_pages}/{total_pages} pages passed)")
print("=" * 80)
def save_crawling_report(results, base_url):
"""Save comprehensive crawling report to file."""
from datetime import datetime
report_dir = Path('.claude/reports')
report_dir.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime('%Y-%m-%d_%H%M%S')
report_file = report_dir / f'web-crawling-{timestamp}.md'
# Generate report content
content = generate_crawling_report_content(results, base_url)
report_file.write_text(content, encoding='utf-8')
print(f"[OK] Comprehensive crawling report saved to: {report_file}")
def generate_crawling_report_content(results, base_url):
"""Generate comprehensive markdown report for crawling results."""
from datetime import datetime
total_pages = len(results)
successful_pages = sum(1 for r in results if r.success)
failed_pages = total_pages - successful_pages
total_errors = sum(len(r.console_errors) + len(r.javascript_errors) for r in results)
total_warnings = sum(len(r.console_warnings) for r in results)
content = f"""{'='*80}
WEB CRAWLING VALIDATION REPORT
{'='*80}
**Base URL**: {base_url}
**Timestamp**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
**Status**: {'PASSED' if successful_pages == total_pages else 'FAILED'}
## SUMMARY
{'-'*40}
- **Total Pages**: {total_pages}
- **Successful**: {successful_pages}
- **Failed**: {failed_pages}
- **Success Rate**: {(successful_pages/total_pages)*100:.1f}%
- **Total Errors**: {total_errors}
- **Total Warnings**: {total_warnings}
## DETAILED RESULTS
{'-'*40}
"""
# Sort results by status and URL
results.sort(key=lambda r: (not r.success, r.url))
for i, result in enumerate(results, 1):
status_icon = "" if result.success else ""
content += f"""
### {i}. {result.url} {status_icon}
**Status**: {'PASSED' if result.success else 'FAILED'}
**Load Time**: {result.load_time:.2f}s
**Page Title**: {result.page_title}
"""
if not result.success:
errors = len(result.console_errors) + len(result.javascript_errors)
content += f"**Total Errors**: {errors}\n"
if result.console_errors:
content += "\n**Console Errors:**\n"
for j, error in enumerate(result.console_errors[:5], 1):
content += f" {j}. [{error.level.upper()}] {error.message}\n"
if len(result.console_errors) > 5:
content += f" ... and {len(result.console_errors) - 5} more errors\n"
if result.javascript_errors:
content += "\n**JavaScript Errors:**\n"
for j, error in enumerate(result.javascript_errors[:5], 1):
content += f" {j}. {str(error)}\n"
if len(result.javascript_errors) > 5:
content += f" ... and {len(result.javascript_errors) - 5} more errors\n"
if result.console_warnings:
content += f"**Warnings**: {len(result.console_warnings)}\n"
if len(result.console_warnings) <= 3:
for j, warning in enumerate(result.console_warnings, 1):
content += f" {j}. {warning.message}\n"
else:
content += f" Top 3 warnings:\n"
for j, warning in enumerate(result.console_warnings[:3], 1):
content += f" {j}. {warning.message}\n"
content += f" ... and {len(result.console_warnings) - 3} more warnings\n"
content += "\n---\n"
# Add recommendations section
content += f"""
## RECOMMENDATIONS
{'-'*40}
"""
if failed_pages > 0:
content += f"""### 🚨 Priority Fixes ({failed_pages} pages failed)
1. **Fix JavaScript Errors**: Review and fix syntax errors in failed pages
2. **Check Server Configuration**: Ensure all resources load correctly
3. **Validate HTML Structure**: Check for malformed HTML causing issues
4. **Test Functionality**: Verify interactive elements work properly
"""
if total_errors > 0:
content += f"""### 🔧 Technical Improvements ({total_errors} total errors)
1. **Console Error Resolution**: Fix JavaScript runtime errors
2. **Resource Loading**: Ensure all assets (CSS, JS, images) are accessible
3. **Network Issues**: Check for failed API calls or missing resources
4. **Error Handling**: Implement proper error handling in JavaScript
"""
if total_warnings > 0:
content += f"""### [WARN] Code Quality ({total_warnings} warnings)
1. **Deprecation Warnings**: Update deprecated API usage
2. **Performance Optimization**: Address performance warnings
3. **Best Practices**: Follow modern web development standards
4. **Code Cleanup**: Remove unused code and console logs
"""
content += f"""
## VALIDATION METRICS
{'-'*40}
- **Validation Date**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
- **Tool**: Web Page Validator with Crawling
- **Scope**: Full site validation with subpage discovery
- **Coverage**: {total_pages} pages analyzed
- **Effectiveness**: {((successful_pages/total_pages)*100):.1f}% success rate
{'='*80}
"""
return content
def main():
"""Main execution function"""
import argparse
parser = argparse.ArgumentParser(description='Validate web pages automatically')
parser.add_argument('url', nargs='?', default='http://127.0.0.1:5000',
help='URL to validate (default: http://127.0.0.1:5000)')
parser.add_argument('--verbose', '-v', action='store_true',
help='Show detailed output including warnings')
parser.add_argument('--auto-fix', action='store_true',
help='Attempt to automatically fix detected issues')
parser.add_argument('--report', action='store_true',
help='Save detailed report to .claude/data/reports/')
parser.add_argument('--timeout', type=int, default=30,
help='Page load timeout in seconds')
parser.add_argument('--wait', type=int, default=3,
help='Wait time after page load in seconds')
# Crawling options
parser.add_argument('--crawl', action='store_true',
help='Crawl and validate all subpages found on the site')
parser.add_argument('--max-depth', type=int, default=3,
help='Maximum crawl depth (default: 3)')
parser.add_argument('--max-pages', type=int, default=50,
help='Maximum number of pages to crawl (default: 50)')
parser.add_argument('--include', type=str, default='',
help='Comma-separated list of path patterns to include (e.g., "/api/*,/analytics/*")')
parser.add_argument('--exclude', type=str, default='',
help='Comma-separated list of path patterns to exclude (e.g., "/admin/*,/debug/*")')
parser.add_argument('--same-domain', action='store_true', default=True,
help='Only crawl pages on the same domain (default: True)')
args = parser.parse_args()
print("[INFO] Web Page Validation")
print(f"[INFO] Target URL: {args.url}")
print()
if not VALIDATOR_AVAILABLE:
print("[ERROR] Web page validator not available")
print("[INFO] Install dependencies: pip install selenium")
print("[INFO] Install ChromeDriver: https://chromedriver.chromium.org/")
return 1
# Run validation
if args.crawl:
print("[INFO] Starting web page crawling and validation...")
print(f"[INFO] Max depth: {args.max_depth}, Max pages: {args.max_pages}")
print("[INFO] This may take several minutes depending on site size...")
print()
if args.include:
print(f"[INFO] Including only: {args.include}")
if args.exclude:
print(f"[INFO] Excluding: {args.exclude}")
print()
else:
print("[INFO] Starting headless browser validation...")
print("[INFO] This may take a few seconds...")
print()
try:
with WebPageValidator(headless=True, timeout=args.timeout) as validator:
if args.crawl:
# Enhanced crawling functionality
results = crawl_and_validate(
validator, args.url,
max_depth=args.max_depth,
max_pages=args.max_pages,
include_patterns=args.include.split(',') if args.include else [],
exclude_patterns=args.exclude.split(',') if args.exclude else [],
same_domain=args.same_domain,
wait_for_load=args.wait,
verbose=args.verbose
)
# Display crawling results
display_crawling_results(results)
# Save comprehensive report
if args.report or not all(r.success for r in results):
save_crawling_report(results, args.url)
# Return appropriate exit code
return 0 if all(r.success for r in results) else 1
else:
# Single page validation (existing logic)
result = validator.validate_url(args.url, wait_for_load=args.wait)
# Display results
if result.success:
print("=" * 80)
print("[OK] VALIDATION PASSED")
print("=" * 80)
print(f"URL: {result.url}")
print(f"Page Title: {result.page_title}")
print(f"Load Time: {result.load_time:.2f}s")
print(f"Console Errors: 0")
print(f"Console Warnings: {len(result.console_warnings)}")
print(f"JavaScript Errors: 0")
print()
print("[OK] No errors detected - page is functioning correctly")
print()
if result.console_warnings and args.verbose:
print("WARNINGS:")
for i, warning in enumerate(result.console_warnings[:5], 1):
print(f" {i}. {warning.message}")
if len(result.console_warnings) > 5:
print(f" ... and {len(result.console_warnings) - 5} more warnings")
print()
else:
print("=" * 80)
print("[ERROR] VALIDATION FAILED")
print("=" * 80)
print(f"URL: {result.url}")
print(f"Page Title: {result.page_title}")
print(f"Load Time: {result.load_time:.2f}s")
print()
print("ERROR SUMMARY:")
print(f" Console Errors: {len(result.console_errors)}")
print(f" Console Warnings: {len(result.console_warnings)}")
print(f" JavaScript Errors: {len(result.javascript_errors)}")
print(f" Network Errors: {len(result.network_errors)}")
print()
# Show top errors
if result.console_errors:
print("TOP CONSOLE ERRORS:")
for i, error in enumerate(result.console_errors[:3], 1):
print(f" {i}. [{error.level.upper()}] {error.message[:80]}")
if error.source and error.source != 'unknown':
print(f" Source: {error.source}")
if len(result.console_errors) > 3:
print(f" ... and {len(result.console_errors) - 3} more errors")
print()
# Show JavaScript errors
if result.javascript_errors:
print("JAVASCRIPT ERRORS:")
for i, js_error in enumerate(result.javascript_errors[:3], 1):
print(f" {i}. {js_error[:80]}")
if len(result.javascript_errors) > 3:
print(f" ... and {len(result.javascript_errors) - 3} more errors")
print()
# Auto-fix suggestions
if args.auto_fix:
print("AUTO-FIX ANALYSIS:")
print(" Analyzing errors for automatic fixes...")
print()
# Check for string escaping issues
has_escape_issues = any(
'SyntaxError' in str(e) or 'unexpected token' in str(e).lower()
for e in result.javascript_errors
)
if has_escape_issues:
print(" [DETECTED] String escaping issues in JavaScript")
print(" [FIX] Use Python raw strings (r'...') for JavaScript escape sequences")
print(" [EXAMPLE] Change 'Value\\n' to r'Value\\n' in Python source")
print()
print(" [ACTION] Would you like to apply automatic fixes? (y/n)")
else:
print(" [INFO] No auto-fixable issues detected")
print(" [INFO] Manual review required for detected errors")
print()
# Save detailed report
if args.report or not result.success:
report_dir = Path('.claude/reports')
report_dir.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime('%Y-%m-%d_%H%M%S')
report_file = report_dir / f'web-validation-{timestamp}.md'
report_content = format_validation_report(result, verbose=True)
report_file.write_text(report_content, encoding='utf-8')
print(f"[OK] Detailed report saved to: {report_file}")
print()
# Performance metrics
if args.verbose and result.performance_metrics:
print("PERFORMANCE METRICS:")
for key, value in result.performance_metrics.items():
if isinstance(value, (int, float)):
print(f" {key}: {value:.2f}ms")
else:
print(f" {key}: {value}")
print()
print("=" * 80)
return 0 if result.success else 1
except KeyboardInterrupt:
print("\n[WARN] Validation interrupted by user")
return 130
except Exception as e:
print(f"[ERROR] Validation failed: {e}")
import traceback
traceback.print_exc()
return 1
if __name__ == '__main__':
sys.exit(main())
```
## Features
- **Automated Error Detection**: Captures JavaScript errors without manual browser inspection
- **Console Log Monitoring**: Captures errors, warnings, and info logs from browser console
- **Network Monitoring**: Detects failed HTTP requests and resource loading issues
- **Performance Metrics**: Measures page load time and resource usage
- **Auto-Fix Suggestions**: Provides guidance on fixing detected issues
- **Detailed Reports**: Saves comprehensive validation reports to `.claude/data/reports/`
- **🆕 Subpage Crawling**: Automatically discovers and validates all subpages on a website
- **🆕 Comprehensive Coverage**: Crawl with configurable depth limits (default: 3 levels)
- **🆕 Smart Filtering**: Include/exclude specific paths with pattern matching
- **🆕 Site-wide Analysis**: Aggregates errors and warnings across entire website
- **🆕 Progress Tracking**: Real-time crawling progress with detailed status updates
## Requirements
**Recommended** (for full functionality):
```bash
pip install selenium
```
**ChromeDriver** (for Selenium):
- Download from: https://chromedriver.chromium.org/
- Or install automatically: `pip install webdriver-manager`
**Alternative** (if Selenium unavailable):
```bash
pip install playwright
playwright install chromium
```
## Integration with Dashboard
This command is automatically invoked when starting dashboards via `/monitor:dashboard` to ensure no JavaScript errors exist before displaying to the user.
## Output Format
**Terminal Output** (concise summary):
```
[OK] VALIDATION PASSED
URL: http://127.0.0.1:5000
Page Title: Autonomous Agent Dashboard
Load Time: 1.23s
Console Errors: 0
JavaScript Errors: 0
```
**Report File** (detailed analysis):
```markdown
# WEB PAGE VALIDATION REPORT
## Summary
- URL: http://127.0.0.1:5000
- Status: PASSED
- Load Time: 1.23s
- Console Errors: 0
- JavaScript Errors: 0
## Console Errors
(none detected)
## Performance Metrics
- Load Time: 1234ms
- DOM Ready: 456ms
- Resources: 15 loaded successfully
```
## Error Categories
1. **JavaScript Syntax Errors**: Invalid JavaScript code
2. **Runtime Errors**: Uncaught exceptions during execution
3. **Reference Errors**: Undefined variables or functions
4. **Type Errors**: Invalid type operations
5. **Network Errors**: Failed HTTP requests
6. **Resource Errors**: Missing CSS, JS, or image files
## Best Practices
- Run validation after making changes to web components
- Always validate before committing dashboard changes
- Use `--auto-fix` for common issues like string escaping
- Save reports for debugging with `--report` flag
- Increase `--timeout` for slow-loading pages
- Use `--verbose` for detailed troubleshooting
## See Also
- `/monitor:dashboard` - Start dashboard with automatic validation
- `/analyze:quality` - Comprehensive quality control including web validation
- Skill: web-validation - Detailed methodology and best practices

View File

@@ -0,0 +1,507 @@
---
name: workspace:distribution-ready
description: Clean and optimize repository for marketplace/public distribution
delegates-to: autonomous-agent:workspace-organizer
---
# Command: `/workspace:distribution-ready`
**Prepares the repository for public marketplace distribution** by removing all computer-specific files, local patterns, performance data, and unnecessary files while preserving local functionality.
## Purpose
- Clean repository for public marketplace distribution
- Remove computer-specific files and local data
- Optimize repository structure for plugin marketplace
- Preserve local functionality while cleaning remote repository
- Ensure cross-platform compatibility
## What It Does
### 1. **Repository Analysis** (5-10 seconds)
- Scan repository for computer-specific files
- Identify local patterns and performance data
- Detect unnecessary files for marketplace
- Analyze current .gitignore coverage
### 2. **File Classification** (10-15 seconds)
- **Essential Files**: Plugin core functionality (agents, skills, commands, lib)
- **Computer-Specific**: .claude*, .reports, local patterns, performance data
- **Local Development**: improvements/, patterns/, generated reports
- **Marketplace Ready**: Documentation, plugin manifest, core components
### 3. **Git Repository Cleanup** (30-60 seconds)
- Remove computer-specific files from Git tracking
- Update .gitignore with comprehensive exclusions
- Clean repository while preserving local files
- Optimize for public distribution
### 4. **Structure Verification** (10-15 seconds)
- Verify all 22 agents are present and functional
- Confirm 17 skills are accessible
- Validate 39 commands are properly structured
- Check 140+ Python scripts for cross-platform compatibility
### 5. **Marketplace Readiness Check** (15-20 seconds)
- Validate plugin manifest completeness
- Check essential documentation presence
- Verify repository size optimization
- Confirm privacy and security compliance
## Key Features
### **Smart File Preservation**
```
Computer-Specific Files (Removed from tracking, kept locally):
+- .claude*/ # Claude AI local directories
+- .reports*/ # Local reports and data
+- improvements/ # Local improvement analysis
+- patterns/ # Local auto-fix patterns
+- *performance*.json # Performance metrics
+- *metrics*.json # Local metrics
+- quality_history*.json # Quality tracking
+- Generated release notes # Local changelogs
Essential Files (Kept in repository):
+- agents/ # 22 specialized agents
+- skills/ # 17 knowledge packages
+- commands/ # 39 slash commands
+- lib/ # 140+ Python utilities
+- .claude-plugin/ # Plugin manifest
+- docs/ # Essential documentation
+- README.md # Main documentation
+- assets/ # Plugin assets
```
### **Enhanced Gitignore Protection**
```gitignore
# Claude AI local directories (computer-specific)
.claude/
.claude-patterns/
.claude-unified/
.claude-preferences/
.claude-quality/
.claude-test/
data/reports/
.claudedata/reports/
# User-specific reports and data
.data/reports/
.reportscurrent/
.reportscurrentvalidation/
# Local patterns and performance data (computer-specific)
patterns/
improvements/
local_config.json
user_settings.json
*performance*.json
*metrics*.json
quality_history*.json
debugging_performance*.json
dashboard_*.json
*_backup*
# Temporary and backup files
*.tmp
*.log
*.backup
*~
.DS_Store
Thumbs.db
# OS generated files
lib/__pycache__/
__pycache__/
*.pyc
*.pyo
# Test files (local only)
dashboard_test.html
*.test.*
test_.*
# Local development files
.env.local
.env.local.*
local_settings.json
settings.local.json
# Generated reports (keep structure, clean content)
data/reports/generated/*
!data/reports/generated/.gitkeep
# Python cache and environment
*.egg-info/
.venv/
venv/
env/
ENV/
```
### **Cross-Platform Compatibility**
- ✅ Windows path compatibility
- ✅ Linux/Unix compatibility
- ✅ macOS compatibility
- ✅ Python scripts work across platforms
- ✅ File locking handled properly
### **Automatic Learning Integration**
The command integrates with the pattern learning system:
- **Store distribution patterns**: Record successful repository cleaning patterns
- **Learn optimization**: Improve file classification over time
- **Track effectiveness**: Monitor distribution success rates
- **Share patterns**: Cross-project distribution knowledge
## Usage Examples
### **Basic Usage**
```bash
# Prepare repository for marketplace distribution
/workspace:distribution-ready
# Include verbose output
/workspace:distribution-ready --verbose
# Dry run to see what would be removed
/workspace:distribution-ready --dry-run
```
### **Advanced Options**
```bash
# Prepare with specific file preservation
/workspace:distribution-ready --keep "custom-data/"
# Force cleanup of additional patterns
/workspace:distribution-ready --aggressive
# Create backup before cleanup
/workspace:distribution-ready --backup
# Skip confirmation prompts
/workspace:distribution-ready --force
```
### **Analysis Mode**
```bash
# Analyze only, don't make changes
/workspace:distribution-ready --analyze-only
# Show detailed file classification
/workspace:distribution-ready --classification
# Generate cleanup report
/workspace:distribution-ready --report
```
## Output Format
### **Terminal Output (Concise)**
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 MARKETPLACE DISTRIBUTION PREPARATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Repository Analysis Complete
Files Scanned: 340
Essential Files: 304
Computer-Specific: 36
Cleanup Strategy: Optimize for marketplace
Files to Remove from Tracking:
+- .claude-patterns/ (23 files)
+- improvements/ (3 files)
+- patterns/ (1 file)
+- Generated reports (9 files)
+- Performance data (12 files)
Local Files Preserved: ✅ All 36 files
Git Protection: ✅ Enhanced .gitignore
Cross-Platform: ✅ Verified
Execute cleanup? [Y/n]: Y
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ DISTRIBUTION READY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[PASS] Repository cleaned for marketplace distribution
[PASS] 36 computer-specific files removed from tracking
[PASS] 304 essential files preserved
[PASS] Enhanced gitignore protection implemented
[PASS] Cross-platform compatibility verified
Final Repository: 304 files (11MB reduction)
Ready for: Marketplace distribution and GitHub release
⏱ Completed in 2 minutes 15 seconds
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
### **Detailed Report File**
```
📄 Detailed report: .claude/data/reports/distribution-ready-2025-10-30.md
```
## File Classification Details
### **Essential Files (Preserved)**
- **Plugin Core**: agents/, skills/, commands/, lib/
- **Documentation**: README.md, docs/, assets/
- **Configuration**: .claude-plugin/, .github/workflows/
- **Templates**: Essential templates and examples
- **Utilities**: Core Python scripts and tools
### **Computer-Specific Files (Removed from Tracking)**
- **Local Patterns**: .claude-patterns/ (all JSON files)
- **Performance Data**: quality history, metrics, debugging data
- **Local Reports**: .data/reports/, validation reports
- **Development Files**: improvements/, patterns/, test files
- **Generated Content**: Release notes, changelogs, generated docs
### **Protected but Local**
- All removed files remain available locally
- Accessible for continued development and testing
- Automatically excluded from future commits
- Preserved across system reboots and updates
## Integration with Existing Commands
### **Development Workflow**
```bash
# Complete development work
/dev:commit --auto
# Prepare for marketplace release
/workspace:distribution-ready
# Create release
/dev:release
# Validate plugin readiness
/validate:plugin
```
### **Quality Assurance**
```bash
# Check code quality
/analyze:quality
# Prepare repository
/workspace:distribution-ready
# Validate full structure
/validate:all
# Test plugin functionality
/debug:eval plugin-installation-test
```
### **Continuous Integration**
```bash
# Automated cleanup in CI/CD
/workspace:distribution-ready --force
# Validate structure
/validate:fullstack
# Run tests
/test:comprehensive
```
## Learning System Integration
### **Pattern Storage**
```json
{
"distribution_patterns": {
"computer_specific_files": [
".claude-patterns/*.json",
"improvements/*.json",
"patterns/*.json",
"*performance*.json"
],
"essential_directories": [
"agents/",
"skills/",
"commands/",
"lib/",
"docs/"
],
"gitignore_patterns": [
".claude*",
".reports*",
"*performance*",
"*metrics*"
],
"success_rate": 0.98,
"avg_cleanup_time": 135,
"file_preservation_accuracy": 1.0
}
}
```
### **Continuous Improvement**
- **File Classification Learning**: Improve file type recognition
- **Cleanup Strategy Optimization**: Learn optimal cleanup approaches
- **Cross-Project Patterns**: Share successful distribution patterns
- **Effectiveness Tracking**: Monitor distribution success rates
## Best Practices
### **When to Use**
**Before marketplace submission**
**Before GitHub releases**
**Before plugin distribution**
**After major development cycles**
**When repository size becomes an issue**
### **What Gets Preserved**
**All plugin functionality** - Commands work identically
**Learning capabilities** - Pattern learning preserved locally
**Cross-platform compatibility** - All scripts work
**Development workflow** - Local development unaffected
**Performance tracking** - Local metrics preserved
### **What Gets Removed**
**Computer-specific patterns** (preserved locally, not tracked)
**Performance metrics** (preserved locally, not tracked)
**Local reports** (preserved locally, not tracked)
**Generated content** (preserved locally, not tracked)
**Development artifacts** (preserved locally, not tracked)
## Troubleshooting
### **Common Issues**
**Repository not clean enough**
```bash
# Run with aggressive mode
/workspace:distribution-ready --aggressive
# Manually review remaining files
/workspace:distribution-ready --classification
```
**Essential files accidentally removed**
```bash
# Restore from Git history
git checkout HEAD~1 -- path/to/essential/file
# Check what was removed
git log --name-status -5
```
**Local files missing after cleanup**
```bash
# Verify local files still exist
ls -la .claude-patterns/ improvements/ patterns/
# Check gitignore protection
git status --ignored
```
### **Recovery Options**
```bash
# Undo all changes (if needed)
git reset --hard HEAD~1
# Restore specific directories
git checkout HEAD~1 -- improvements/ patterns/
# Generate new patterns
/workspace:organize --regenerate-patterns
```
## Performance Metrics
Expected performance:
| Task | Time | Success Rate |
|------|------|--------------|
| Repository analysis | 5-10s | 100% |
| File classification | 10-15s | 98% |
| Git cleanup | 30-60s | 95% |
| Structure verification | 10-15s | 99% |
| Marketplace validation | 15-20s | 97% |
**Repository Size Reduction**: 10-15MB average
**File Count Optimization**: 30-50 files removed
**Learning Improvement**: 25% faster classification after 5 uses
## Examples
### **Example 1: Standard Distribution Prep**
```bash
$ /workspace:distribution-ready
Scanning repository...
Found: 340 files total, 36 computer-specific
Classification:
[PASS] Essential: 304 files (agents, skills, commands, lib)
[PASS] Computer-specific: 36 files (patterns, metrics, reports)
Cleanup complete:
- Removed 36 files from tracking
- Enhanced .gitignore protection
- Preserved all local functionality
- Ready for marketplace distribution
Result: ✅ Distribution ready (304 files, 12MB reduction)
```
### **Example 2: Analysis Mode**
```bash
$ /workspace:distribution-ready --analyze-only
Repository Analysis Report:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Essential Components ([PASS] Keep):
+- agents/ (22 files) - Core plugin functionality
+- skills/ (17 files) - Knowledge packages
+- commands/ (39 files) - Slash commands
+- lib/ (140 files) - Python utilities
+- docs/ (15 files) - Essential documentation
Computer-Specific Files (🗑 Remove from tracking):
+- .claude-patterns/ (23 files) - Local patterns
+- improvements/ (3 files) - Local improvements
+- patterns/ (1 file) - Auto-fix patterns
+- Generated content (9 files) - Reports/changelogs
Recommendation: Ready for marketplace distribution cleanup
```
### **Example 3: Aggressive Cleanup**
```bash
$ /workspace:distribution-ready --aggressive --force
Aggressive cleanup mode enabled...
Additional patterns detected:
+- *.log files (5)
+- *.backup files (8)
+- Cache directories (3)
+- Temporary artifacts (12)
Executing comprehensive cleanup...
[PASS] Standard cleanup: 36 files removed
[PASS] Aggressive cleanup: 28 additional files removed
[PASS] Total optimization: 64 files removed
[PASS] Repository size reduction: 18MB
Marketplace ready: ✅ Optimized for distribution
```
---
**Version**: 1.0.0
**Integration**: Uses workspace-organizer, git-repository-manager agents
**Skills**: git-automation, pattern-learning, code-analysis, validation-standards
**Platform**: Cross-platform (Windows, Linux, Mac)
**Learning**: Full integration with pattern learning system
**Scope**: Repository optimization for marketplace distribution only

View File

@@ -0,0 +1,499 @@
---
name: workspace:improve
description: Analyze plugin and suggest improvements based on best practices and patterns
delegates-to: autonomous-agent:orchestrator
---
# Improve Plugin Command
## Command: `/workspace:improve`
Analyzes user interactions with the autonomous agent plugin and automatically generates structured improvement prompts for continuous plugin development. This command implements the key innovation of automatic learning by transforming user experiences into actionable development insights.
## Purpose
The `/improve-plugin` command serves as a bridge between user experiences and plugin evolution. It systematically analyzes how users interact with the plugin, identifies patterns, generates improvement suggestions, and stores them in a unified format that can drive continuous development.
## How It Works
### 1. Experience Data Collection
**Sources Analyzed**:
- **Pattern Database**: Task execution patterns and outcomes
- **Performance Metrics**: Quality scores, success rates, time efficiency
- **Usage Patterns**: Command frequency, skill utilization, agent delegation
- **Error Logs**: Common failures and recovery patterns
- **Feedback Traces**: Implicit feedback from task outcomes
- **Learning Evolution**: How performance has improved over time
### 2. Pattern Recognition
**Analysis Dimensions**:
- **Effectiveness Patterns**: Which approaches consistently succeed
- **Efficiency Patterns**: Time-to-resolution trends
- **Error Patterns**: Common failure modes and their contexts
- **Learning Patterns**: Skill acquisition and improvement rates
- **Usage Patterns**: Command popularity and feature utilization
- **Quality Patterns**: Factors influencing task quality scores
### 3. Improvement Prompt Generation
**Prompt Types Generated**:
- **Feature Enhancement**: New functionality suggestions based on usage gaps
- **Performance Optimization**: Speed and efficiency improvements
- **User Experience**: Workflow and interface improvements
- **Error Prevention**: Proactive measures to reduce common failures
- **Learning Enhancement**: Pattern recognition and knowledge transfer improvements
- **Integration Opportunities**: Ways to better connect components
### 4. Unified Storage System
**Storage Location**: `./improvements/unified-improvements.json`
**JSON Structure**:
```json
{
"analysis_id": "exp_analysis_2025_10_25_16_35_42",
"timestamp": "2025-10-25T16:35:42.123Z",
"model_used": "Claude Sonnet 4.5",
"analysis_scope": {
"timeframe": "last_30_days",
"data_sources": ["patterns", "performance", "usage", "errors"],
"total_patterns_analyzed": 47,
"performance_records_analyzed": 12,
"command_usage_analyzed": 89
},
"key_findings": {
"top_success_patterns": [
{
"pattern_type": "bug_fix",
"success_rate": 0.95,
"avg_quality_score": 92,
"common_approach": "systematic_error_analysis + pattern matching"
}
],
"improvement_opportunities": [
{
"area": "debugging_performance",
"current_score": 87,
"potential_improvement": 15,
"suggested_approach": "enhanced_error_pattern matching"
}
]
},
"improvement_prompts": [
{
"id": "improve_debugging_speed",
"priority": "high",
"category": "performance",
"prompt": "Based on analyzing 47 debugging tasks, implement pattern-based error detection that reduces average resolution time from 8.2 minutes to under 5 minutes. Focus on common error patterns: JavaScript ReferenceErrors, missing variables in destructuring, and API integration issues.",
"evidence": {
"sample_size": 47,
"current_performance": "8.2 min avg",
"target_performance": "<5 min avg",
"success_rate_impact": "Could improve from 87% to 95%"
}
}
],
"usage_insights": {
"most_used_commands": [
{"command": "/auto-analyze", "usage_count": 23, "success_rate": 0.91},
{"command": "/dashboard", "usage_count": 18, "success_rate": 1.0},
{"command": "/eval-debug", "usage_count": 12, "success_rate": 0.92}
],
"least_used_features": [
{"feature": "workspace organization", "usage_count": 3, "potential": "high"},
{"feature": "pattern validation", "usage_count": 5, "potential": "medium"}
]
},
"learning_trends": {
"quality_improvement_rate": "+0.8 points per week",
"speed_improvement_rate": "-12% time per task per week",
"pattern_utilization_efficiency": "+5% per week",
"areas_needing_attention": ["cross-project pattern transfer", "error prediction"]
},
"next_steps": {
"immediate_actions": [
"Implement debugging pattern database",
"Enhance error prediction capabilities",
"Create cross-project learning transfer"
],
"medium_term_goals": [
"Achieve 95% debugging success rate",
"Reduce average task time by 30%",
"Implement predictive error prevention"
],
"long_term_vision": [
"Autonomous error resolution",
"Self-optimizing performance",
"Continuous improvement without manual intervention"
]
}
}
```
## Usage
### Basic Analysis
```bash
/improve-plugin
```
**Default Behavior**:
- Analyzes last 30 days of experience data
- Generates 3-5 high-priority improvement prompts
- Stores results in unified improvements file
- Provides summary in terminal
- Creates detailed analysis report
### Custom Timeframe
```bash
# Analyze last 7 days
/improve-plugin --days 7
# Analyze last 90 days
/improve-plugin --days 90
# Analyze since specific date
/improve-plugin --since 2025-09-01
```
### Specific Analysis Focus
```bash
# Focus on debugging performance
/improve-plugin --focus debugging
# Focus on quality improvements
/improve-plugin --focus quality
# Focus on speed/efficiency
/improve-plugin --focus efficiency
# Focus on user experience
/improve-plugin --focus ux
```
### Output Options
```bash
# Detailed JSON output
/improve-plugin --verbose
# Summary only
/improve-plugin --summary
# Save custom report location
/improve-plugin --output ./custom-improvements.json
# Generate actionable checklist
/improve-plugin --checklist
```
## Command Delegation
The `/improve-plugin` command delegates to the **learning-engine** agent for comprehensive pattern analysis:
### Learning-Engine Agent Responsibilities
1. **Experience Data Aggregation**
- Collect pattern database entries
- Analyze performance metrics
- Review command usage statistics
- Identify success/failure patterns
2. **Pattern Recognition**
- Detect recurring successful approaches
- Identify common failure modes
- Analyze learning progression
- Recognize optimization opportunities
3. **Improvement Generation**
- Create structured improvement prompts
- Prioritize by impact and feasibility
- Provide evidence-based recommendations
- Generate actionable next steps
4. **Learning Integration**
- Store analysis results in unified format
- Update effectiveness metrics
- Identify new patterns for future learning
- Track improvement implementation success
## Skills Utilized
### pattern-learning
- Recognize recurring successful patterns
- Identify knowledge transfer opportunities
- Analyze learning curve effectiveness
### code-analysis
- Analyze code quality improvement patterns
- Identify common code issues and their solutions
- Track refactoring effectiveness
### quality-standards
- Analyze quality score trends
- Identify quality improvement opportunities
- Track standards compliance patterns
### validation-standards
- Analyze error prevention effectiveness
- Identify validation pattern improvements
- Track proactive error detection
## Analysis Output
### Terminal Summary
```
🔍 PLUGIN IMPROVEMENT ANALYSIS COMPLETE
Timeframe: Last 30 days
Data Analyzed: 47 patterns, 89 command usages, 12 performance records
📊 KEY INSIGHTS:
* Average Quality Score: 88.7/100 (+3.2 vs previous period)
* Task Success Rate: 91% (+4% improvement)
* Average Resolution Time: 6.8 minutes (-18% improvement)
* Learning Velocity: Accelerating 🚀
🎯 TOP IMPROVEMENT OPPORTUNITIES:
1. Debugging Performance Optimization (High Priority)
- Current: 87% success rate, 8.2 min avg time
- Target: 95% success rate, <5 min avg time
2. Cross-Project Pattern Transfer (Medium Priority)
- Currently 12% transfer efficiency
- Target: 35% transfer efficiency
3. Error Prediction System (Medium Priority)
- Could prevent 23% of current failures
💾 IMPROVEMENTS STORED:
File: ./improvements/unified-improvements.json
Prompts Generated: 5
Priority: High (2), Medium (2), Low (1)
📈 LEARNING TRENDS:
Quality Score: +0.8 points/week
Speed Improvement: -12% time/week
Pattern Utilization: +5%/week
⏱ Analysis completed in 2.3 seconds
```
### Detailed Report File
**Location**: `.claude/data/reports/plugin-improvement-YYYY-MM-DD.md`
**Contents**:
- Complete analysis methodology
- Detailed pattern recognition results
- Comprehensive improvement prompts
- Usage statistics and trends
- Learning progression analysis
- Actionable implementation checklist
## Integration with Plugin Development
### Continuous Improvement Loop
1. **User Interaction** -> Plugin executes tasks
2. **Pattern Storage** -> Learning patterns captured
3. **Experience Analysis** -> `/improve-plugin` generates insights
4. **Improvement Implementation** -> Developers apply suggested improvements
5. **Performance Monitoring** -> Dashboard tracks impact
6. **Repeat** -> Continuous cycle of improvement
### Claude Code Integration
The unified improvements JSON file can be consumed by Claude Code to:
- Automatically suggest plugin improvements
- Prioritize development tasks based on user experience data
- Track the impact of implemented improvements
- Generate new feature ideas from usage patterns
### Example Improvement Implementation
```javascript
// Claude Code could read improvements.json and suggest:
// "Based on user experience analysis, implement debugging pattern database
// to reduce resolution time from 8.2 to <5 minutes"
```
## Data Sources Analyzed
### Pattern Database (`.claude-patterns/patterns.json`)
- Task execution patterns and outcomes
- Skill and agent effectiveness
- Quality score trends
- Learning progression data
### Performance Records (`.claude-patterns/enhanced_patterns.json`)
- Debugging performance metrics
- Quality improvement scores
- Time efficiency measurements
- Success rates by task type
### Command Usage Logs
- Command frequency and popularity
- Success rates by command
- Common usage patterns
- Feature utilization metrics
### Error Logs
- Common failure modes
- Error context analysis
- Recovery patterns
- Prevention opportunities
### Dashboard Analytics
- Real-time performance monitoring
- User interaction patterns
- Feature usage statistics
- System health trends
## Improvement Prompt Categories
### 1. Performance Optimization
- Faster task execution
- Better resource utilization
- Improved response times
- Enhanced efficiency metrics
### 2. Quality Enhancement
- Higher success rates
- Better error prevention
- Improved accuracy
- Enhanced reliability
### 3. User Experience
- Simplified workflows
- Better feedback systems
- More intuitive interfaces
- Enhanced discoverability
### 4. Feature Enhancement
- New functionality suggestions
- Expanded capabilities
- Better integration
- Enhanced automation
### 5. Error Prevention
- Proactive error detection
- Better validation systems
- Improved error messages
- Enhanced recovery mechanisms
### 6. Learning Enhancement
- Better pattern recognition
- Improved knowledge transfer
- Enhanced adaptation capabilities
- Smarter decision making
## Quality Assurance
### Validation Criteria
- **Data Completeness**: All relevant data sources analyzed
- **Pattern Accuracy**: Recognized patterns validated against actual outcomes
- **Prompt Quality**: Improvement prompts are actionable and evidence-based
- **Priority Accuracy**: High-impact improvements prioritized correctly
- **Format Consistency**: JSON structure follows unified schema
### Continuous Learning
- Analysis effectiveness is tracked and improved
- Prompt accuracy is measured against implementation results
- Pattern recognition is refined based on outcomes
- Learning algorithms are optimized continuously
## Examples of Generated Prompts
### Example 1: Debugging Performance
```json
{
"id": "debugging_pattern_database",
"priority": "high",
"category": "performance",
"prompt": "Implement a comprehensive debugging pattern database that stores successful debugging approaches and automatically suggests solutions for similar issues. Based on analysis of 47 debugging tasks, this could reduce average resolution time from 8.2 minutes to under 5 minutes and improve success rate from 87% to 95%.",
"evidence": {
"sample_size": 47,
"current_performance": "8.2 min avg, 87% success",
"target_performance": "<5 min avg, 95% success",
"confidence": "high"
}
}
```
### Example 2: Cross-Project Learning
```json
{
"id": "cross_project_pattern_transfer",
"priority": "medium",
"category": "learning",
"prompt": "Enhance the pattern learning system to transfer knowledge between different projects automatically. Current transfer efficiency is only 12%, but analysis shows potential for 35% efficiency by implementing context-aware pattern matching and project-agnostic skill identification.",
"evidence": {
"projects_analyzed": 8,
"current_efficiency": "12%",
"target_efficiency": "35%",
"implementation_complexity": "medium"
}
}
```
### Example 3: User Experience Enhancement
```json
{
"id": "predictive_error_prevention",
"priority": "medium",
"category": "ux",
"prompt": "Implement a predictive error prevention system that identifies potential issues before they occur based on pattern analysis. This could prevent 23% of current failures and improve overall user satisfaction by providing proactive guidance.",
"evidence": {
"failure_patterns_analyzed": 156,
"preventable_failures": "23%",
"implementation_approach": "pattern-based prediction",
"expected_impact": "high"
}
}
```
## Benefits
### For Users
- Continuous improvement based on actual usage patterns
- Proactive identification and resolution of pain points
- Enhanced performance and reliability over time
- Personalized optimization based on individual usage
### For Developers
- Data-driven development priorities
- Clear evidence-based improvement suggestions
- Understanding of real-world usage patterns
- Measurable impact of improvements
### For the Plugin
- Autonomous self-improvement capabilities
- Adaptive performance optimization
- Enhanced learning and pattern recognition
- Continuous evolution without manual intervention
## Implementation Notes
### Requirements
- Existing pattern database with sufficient history (minimum 10 tasks)
- Performance tracking system
- Command usage logging
- Access to learning patterns and metrics
### Limitations
- Requires minimum data volume for meaningful analysis
- Improvement prompts are suggestions, not guaranteed solutions
- Pattern recognition accuracy depends on data quality
- Implementation of improvements requires developer action
### Future Enhancements
- Real-time experience analysis
- Automatic improvement implementation
- Cross-plugin pattern sharing
- AI-driven improvement prioritization
---
This command represents a key innovation in autonomous plugin development, creating a continuous feedback loop where user experiences directly drive plugin evolution and improvement.

View File

@@ -0,0 +1,186 @@
---
name: workspace:organize
description: Automatically organize workspace files, consolidate reports, and validate links
delegates-to: autonomous-agent:orchestrator
# Command: `/workspace:organize`
Automatically organizes your workspace by moving files to appropriate directories, consolidating scattered reports, and fixing broken links. Improves project hygiene and maintains professional structure.
## Purpose
- Move misplaced files to their proper directories
- Consolidate scattered reports into organized structure
- Validate and fix documentation links
- Maintain clean workspace for better productivity
- Track workspace health over time
## What It Does
### 1. **Report File Organization** (15-30 seconds)
- Move `*.md` reports from root -> `data/reports/generated/`
- Consolidate `.reports*` directories into single location
- Archive reports older than 30 days to `data/reports/archive/`
- Create/update `data/reports/README.md` index
### 2. **Python Utility Organization** (10-20 seconds)
- Move standalone Python scripts from root to `lib/`
- Validate scripts still function after move
- Check for import dependencies that need updating
- Create `lib/README.md` if missing
### 3. **Pattern Storage Consolidation** (10-15 seconds)
- Migrate any `patterns/` directories to `.claude-patterns/`
- Validate pattern JSON format consistency
- Remove old pattern locations if empty
- Ensure `.claude-patterns/.gitignore` exists
### 4. **Link Validation & Fixing** (20-40 seconds)
- Scan all `.md` files for internal links
- Identify broken links to moved files
- Update relative paths to new locations
- Generate link validation report
### 5. **Gitignore Management** (5-10 seconds)
- Check for `.gitignore` entries for organized directories
- Add entries for `.claude/`, `.claude-patterns/`, `data/reports/generated/`
- Prompt if major changes should be gitignored
### 6. **Workspace Health Report** (5-10 seconds)
- Calculate before/after workspace health score
- Show files organized and links fixed
- Provide recommendations for further improvement
## Usage
```bash
# Basic workspace organization
/organize-workspace
# Dry run to see what would be moved
/organize-workspace --dry-run
# Include archive cleanup (remove reports > 90 days)
/organize-workspace --cleanup
# Skip link validation for faster execution
/organize-workspace --no-validate-links
```
## Output
### Terminal Summary (concise)
```
Workspace Organization Complete
+- Health Score: 78/100 -> 92/100 ✅ (+14)
+- Files Organized: 7 files moved
+- Links Fixed: 3 links updated
+- Reports Archived: 2 files
+- Duration: 1m 23s
📄 Detailed report: .claude/data/reports/organize-workspace-2025-01-15.md
```
### Detailed Report (file)
- Complete list of files moved with source/destination
- All links that were updated
- Any broken links that need manual attention
- Workspace health scoring breakdown
- Recommendations for maintaining organization
## Directory Structure After Organization
```
project/
+-- docs/
| +-- data/reports/
| +-- README.md # Report index
| +-- generated/ # Auto-generated reports
| +-- archive/ # Old reports (>30 days)
+-- lib/ # Python utilities
| +-- README.md # Utility documentation
+-- .claude-patterns/ # Learning patterns
+-- .claude/ # Claude Code data
+-- [other project files]
```
## Integration
The `/organize-workspace` command integrates with:
- **workspace-organizer agent**: Handles the actual file operations
- **validation-standards skill**: Ensures links are properly validated
- **orchestrator**: Suggests organization when workspace health < 70
## Safety Features
- **Dry Run Mode**: Preview changes before executing
- **Backup Creation**: Creates `.claude/backup/` before major moves
- **Selective Execution**: Can skip specific organization steps
- **Rollback Support**: Can undo last organization if needed
## Examples
### Example 1: Basic Organization
```bash
User: /organize-workspace
System: Moved 3 reports to data/reports/generated/
Fixed 2 broken links in README.md
Health score improved: 65/100 -> 85/100
```
### Example 2: With Cleanup
```bash
User: /organize-workspace --cleanup
System: Archived 5 old reports (>90 days)
Consolidated 2 .reports directories
Created data/reports/README.md index
```
## When to Use
Run `/organize-workspace` when:
- Root directory has many report files
- Multiple `.reports*` directories exist
- Documentation links are broken
- Workspace health score is below 70
- Before major releases or code reviews
## Automation
The orchestrator can automatically suggest `/organize-workspace` when:
- Workspace health drops below 70/100
- More than 5 report files in root directory
- Broken links detected in documentation
## Notes
- Always creates backup before major file moves
- Preserves file history and timestamps
- Updates all internal documentation links
- Respects existing `.gitignore` entries
- Works with any project structure
## Best Practices
1. **Run before releases**: Clean workspace for professional presentation
2. **Check after analysis**: Analysis commands often generate reports
3. **Regular maintenance**: Run monthly to prevent accumulation
4. **Review changes**: Check the detailed report after organization
5. **Update team**: Inform team members about new file locations
## Related Commands
- `/validate-patterns` - Validate pattern learning consistency
- `/quality-check` - Run after organization to ensure quality
- `/learn-patterns` - Initialize pattern learning system
## See Also
- [Workspace Organization Guide](../docs/guidelines/WORKSPACE_ORGANIZATION.md)
- [Link Validation Standards](../skills/validation-standards/SKILL.md)
- [Workspace-Organizer Agent](../agents/workspace-organizer.md)
---

View File

@@ -0,0 +1,556 @@
---
name: workspace:reports
description: Organize and consolidate scattered reports into clean directory structure
delegates-to: autonomous-agent:orchestrator
---
# Organize Reports Command
## Command: `/workspace:reports`
Automated report organization and management system that categorizes, archives, and optimizes all validation, quality, and analysis reports with intelligent cleanup and searchable storage.
## How It Works
1. **Report Discovery**: Scans repository for all report files and analyzes content
2. **Intelligent Categorization**: Classifies reports by type, importance, and relevance
3. **Organized Storage**: Moves reports to structured directory hierarchy
4. **Automated Archival**: Archives old reports based on retention policies
5. **Duplicate Management**: Identifies and merges duplicate or redundant reports
6. **Search Indexing**: Creates searchable metadata index for all reports
7. **Cleanup Optimization**: Removes obsolete files and optimizes storage
## Usage
### Basic Organization
```bash
# Organize all reports with default settings
/workspace:reports
# Quick organization (current reports only)
/organize-reports --quick
# Deep organization (includes archival and compression)
/organize-reports --deep
```
### Advanced Organization Options
```bash
# Custom organization with specific rules
/organize-reports \
--archive-policy 90days \
--compress-old \
--remove-duplicates \
--create-index
# Organize specific report types
/organize-reports --type validation
/organize-reports --type quality,performance
# Organize by date range
/organize-reports --date-range "2024-01-01..2024-01-31"
/organize-reports --older-than 30days
```
### Dry Run and Preview
```bash
# Preview organization without making changes
/organize-reports --dry-run
# Show detailed analysis before organizing
/organize-reports --analyze
# Interactive mode with confirmation prompts
/organize-reports --interactive
```
## Organization Structure
### Target Directory Structure
```
.data/reports/
+-- current/ # Active reports (last 30 days)
| +-- validation/ # Plugin validation reports
| | +-- plugin-validation-2024-01-15.md
| | +-- claude-plugin-validation-2024-01-14.md
| | +-- installation-validation-2024-01-13.md
| +-- quality/ # Quality assessment reports
| | +-- code-quality-2024-01-15.md
| | +-- standards-compliance-2024-01-14.md
| | +-- best-practices-2024-01-13.md
| +-- performance/ # Performance analysis reports
| | +-- execution-time-analysis-2024-01-15.md
| | +-- resource-usage-2024-01-14.md
| +-- security/ # Security scan reports
| | +-- vulnerability-scan-2024-01-15.md
| | +-- dependency-security-2024-01-14.md
| +-- testing/ # Test execution reports
| | +-- test-coverage-2024-01-15.md
| | +-- test-results-2024-01-14.md
| +-- summary/ # Executive summary reports
| +-- weekly-summary-2024-01-15.md
| +-- monthly-report-2024-01-01.md
+-- recent/ # Recent reports (30-90 days)
| +-- 2024-01/ # Monthly organization
| | +-- validation/
| | +-- quality/
| | +-- performance/
| +-- 2023-12/
+-- archive/ # Archived reports (90+ days)
| +-- 2023/ # Yearly organization
| | +-- Q1/ # Quarterly organization
| | | +-- validation/
| | | +-- quality/
| | | +-- performance/
| | +-- Q2/
| | +-- Q3/
| | +-- Q4/
| +-- 2022/
+-- templates/ # Report templates
| +-- validation-template.md
| +-- quality-template.md
| +-- performance-template.md
+-- metrics/ # Aggregated metrics and trends
| +-- quality-trends.json
| +-- performance-metrics.json
| +-- validation-history.json
+-- index/ # Search indices and metadata
+-- reports-index.json
+-- search-index.json
+-- metadata-db.json
```
## Command Line Options
### Organization Mode
```bash
--quick # Quick organization (current reports only)
--deep # Deep organization (includes archival, compression)
--analyze # Analyze reports without organizing
--dry-run # Preview changes without executing
--interactive # Interactive mode with confirmations
```
### Report Selection
```bash
--type <types> # Specific report types to organize
# Values: validation,quality,performance,security,
# testing,documentation,summary
# Default: all
--date-range <range> # Date range for reports (YYYY-MM-DD..YYYY-MM-DD)
--older-than <period> # Reports older than period (e.g., 30days, 3months)
--newer-than <period> # Reports newer than period
--pattern <pattern> # File pattern matching (glob)
```
### Archival Options
```bash
--archive-policy <policy> # Archival retention policy
# Values: 30days, 60days, 90days, 6months, 1year
# Default: 90days
--compress-old # Compress reports older than archival period
--compress-level <level> # Compression level (1-9, default: 6)
--keep-critical # Keep critical reports indefinitely
--keep-high-importance # Keep high importance reports longer
```
### Cleanup Options
```bash
--remove-duplicates # Remove duplicate reports
--merge-similar # Merge similar reports
--remove-obsolete # Remove superseded reports
--cleanup-temp # Clean temporary and intermediate files
--storage-limit <size> # Maximum storage usage (e.g., 500MB, 2GB)
--free-space <size> # Target free space to maintain
```
### Index and Search
```bash
--create-index # Create searchable index
--update-index # Update existing index
--rebuild-index # Rebuild index from scratch
--extract-metadata # Extract and store metadata
--generate-thumbnails # Generate report thumbnails/summaries
--create-summaries # Generate executive summaries
```
### Output Control
```bash
--verbose # Detailed output logging
--quiet # Minimal output
--summary # Show organization summary only
--report-file <file> # Save detailed report to file
--json-output # Output in JSON format
--csv-output # Output in CSV format
```
## Workflow Stages
### Stage 1: Report Discovery (10-30 seconds)
**Scans and identifies**:
- All report files in repository
- Report types based on content analysis
- File metadata (size, dates, hashes)
- Duplicate or similar reports
**Output**:
```
============================================================
REPORT DISCOVERY
============================================================
📁 Report Files Found: 18
+- Root Directory: 3 files
+- Subdirectories: 15 files
+- Hidden Reports: 0 files
📊 Report Types Detected:
+- Validation Reports: 6
+- Quality Reports: 4
+- Performance Reports: 3
+- Plugin Reports: 2
+- Security Reports: 1
+- Summary Reports: 2
🔍 Analysis Results:
+- Total Size: 2.4 MB
+- Duplicate Files: 2
+- Obsolete Reports: 1
+- Critical Reports: 3
+- High Importance: 7
⏱ Discovery completed in 23 seconds
```
### Stage 2: Categorization and Analysis (30-60 seconds)
**Analyzes and categorizes**:
- Report content and structure
- Importance and relevance scoring
- Date-based categorization
- Cross-reference relationships
**Output**:
```
============================================================
CATEGORIZATION ANALYSIS
============================================================
📋 Classification Results:
+- Current Reports (≤30 days): 8 files
+- Recent Reports (30-90 days): 6 files
+- Archive Candidates (>90 days): 4 files
+- Template Files: 0 files
🎯 Importance Distribution:
+- Critical Issues: 3 reports
| +- Security vulnerabilities
| +- Breaking validation failures
| +- Critical quality issues
+- High Priority: 7 reports
+- Medium Priority: 5 reports
+- Low Priority: 3 reports
🔗 Report Relationships:
+- Related Report Groups: 4
+- Duplicate Pairs: 2
+- Sequential Reports: 3
+- Cross-References: 12
📈 Quality Metrics:
+- Average Report Score: 82/100
+- Completeness Rate: 94%
+- Consistency Score: 88%
+- Actionability Index: 76%
⏱ Categorization completed in 47 seconds
```
### Stage 3: Organization Execution (1-3 minutes)
**Executes organization**:
- Creates directory structure
- Moves files to appropriate locations
- Updates file names and metadata
- Creates cross-references and links
**Output**:
```
============================================================
ORGANIZATION EXECUTION
============================================================
📂 Directory Structure Created:
+- .data/reports/current/validation/ [PASS]
+- .data/reports/current/quality/ [PASS]
+- .data/reports/current/performance/ [PASS]
+- .data/reports/recent/2024-01/ [PASS]
+- .data/reports/archive/2023/Q4/ [PASS]
+- .data/reports/metrics/ [PASS]
📁 Files Organized:
+- Current Reports: 8 files moved
+- Recent Reports: 6 files moved
+- Archived Reports: 4 files moved
+- Duplicates Removed: 2 files
+- Obsolete Reports: 1 file removed
🏷️ File Naming Applied:
+- Standardized format: {type}-{date}-{id}.md
+- Consistent date format: YYYY-MM-DD
+- Unique identifiers added: 12 files
+- Metadata embedded: 18 files
🔗 Cross-References Created:
+- Related reports linked: 12 links
+- Sequential reports grouped: 3 groups
+- Summary reports updated: 2 summaries
+- Index entries created: 18 entries
📊 Storage Optimization:
+- Space Saved: 156 KB (6.5% reduction)
+- Compression Applied: 4 files
+- Duplicates Removed: 320 KB
+- Index Size: 45 KB
🎯 Organization Status: SUCCESS
⏱ Organization completed in 2.1 minutes
```
### Stage 4: Index Creation and Search (30-60 seconds)
**Creates search infrastructure**:
- Full-text search index
- Metadata database
- Cross-reference map
- Trend analysis data
**Output**:
```
============================================================
SEARCH INDEX CREATION
============================================================
🔍 Search Index Built:
+- Full-Text Index: 18 documents indexed
+- Metadata Database: 18 records
+- Cross-Reference Map: 32 relationships
+- Trend Data: 6 months of history
📊 Index Statistics:
+- Total Terms: 3,247 unique terms
+- Document Count: 18 reports
+- Average Document Size: 15.2 KB
+- Index Size: 127 KB
+- Search Speed: <50ms average
🎯 Search Capabilities:
+- Content Search: Full-text search across all reports
+- Metadata Search: Search by type, date, importance
+- Trend Analysis: Track metrics over time
+- Comparative Analysis: Compare similar reports
+- Custom Queries: Advanced search with filters
📈 Analytics Data Generated:
+- Quality Trends: Monthly quality score progression
+- Issue Patterns: Common issues and frequencies
+- Resolution Times: Average time to address issues
+- Improvement Metrics: Progress tracking over time
🔗 Integration Ready:
+- CLI Search Interface: Available
+- Web Dashboard: Optional
+- API Access: RESTful API available
+- Export Formats: JSON, CSV, PDF
🎯 Index Creation: SUCCESS
⏱ Index creation completed in 54 seconds
```
## Search and Retrieval
### Built-in Search Commands
```bash
# Search by content
search-reports "validation failed" --type validation
# Search by metadata
search-reports --importance critical --date-range "2024-01-01..2024-01-31"
# Trend analysis
analyze-trends --metric quality_score --period monthly
# Generate summaries
generate-summary --type validation --period "last_30_days"
# Compare reports
compare-reports --type validation --date-range "2023-12..2024-01"
```
### Search Query Examples
```bash
# Find critical security issues
search-reports "security vulnerability" --importance critical --type security
# Track quality improvements
search-reports --type quality --metric score --trend improving
# Find all validation reports from January
search-reports --type validation --date 2024-01
# Generate performance summary
generate-summary --type performance --format markdown --output performance-summary.md
```
## Integration with Other Commands
### With Validation Commands
```bash
# Run validation then organize results
/validate-fullstack
/organize-reports --type validation --quick
```
### With Quality Commands
```bash
# Quality check with report organization
/quality-check
/organize-reports --type quality --create-index
```
### With Learning Commands
```bash
# Analyze patterns and organize findings
/auto-analyze
/organize-reports --deep --extract-metadata
```
## Retention Policies
### Default Retention Rules
```yaml
retention_policies:
current_reports:
duration: 30 days
compression: false
backup: true
recent_reports:
duration: 90 days
compression: true
backup: true
archived_reports:
duration: 1 year
compression: true
backup: true
critical_reports:
duration: permanent
compression: false
backup: true
multiple_copies: true
```
### Custom Retention Rules
```bash
# Set custom retention policy
/organize-reports \
--archive-policy 6months \
--keep-critical \
--compress-old \
--storage-limit 1GB
```
## Best Practices
### Regular Organization
- **Daily**: Quick organization of new reports
- **Weekly**: Deep organization with archival
- **Monthly**: Index rebuilding and optimization
- **Quarterly**: Complete cleanup and retention review
### Storage Management
- Monitor storage usage regularly
- Set appropriate retention policies
- Compress old reports to save space
- Maintain backups of critical reports
### Search Optimization
- Update index regularly
- Use descriptive file names
- Add relevant metadata and tags
- Create executive summaries for quick reference
## Troubleshooting
### Common Issues
**Insufficient Permissions**:
```bash
# Check permissions
ls -la .data/reports/
# Fix permissions
chmod -R 755 .data/reports/
```
**Storage Space Issues**:
```bash
# Check disk usage
df -h
# Free up space
/organize-reports --compress-old --archive-policy 30days
```
**Search Index Corruption**:
```bash
# Rebuild index
/organize-reports --rebuild-index
```
### Recovery Procedures
**Lost Reports**:
```bash
# Check for moved files
find . -name "*validation*" -type f
# Restore from backup if available
```
**Damaged Index**:
```bash
# Remove corrupted index
rm -f .data/reports/index/*.json
# Rebuild from scratch
/organize-reports --rebuild-index --deep
```
## Integration with Learning System
The Report Organizer learns from organization patterns to improve future operations:
**Pattern Learning**:
- Optimal categorization rules for different report types
- User preferences for report organization and access
- Common report patterns and relationships
- Storage optimization strategies based on usage
**Continuous Improvement**:
- Improved duplicate detection algorithms
- Better relevance scoring for reports
- Enhanced search result ranking
- Optimized retention policies
---
**Version**: 1.0.0
**Platform**: Cross-platform (Windows, Linux, Mac)
**Dependencies**: Standard file system tools
**Integration**: Works with all validation and quality reporting commands

View File

@@ -0,0 +1,124 @@
---
name: workspace:update-about
description: Update GitHub About section with SEO-optimized description, topics, and links
delegates-to: autonomous-agent:documentation-generator
---
# Workspace Update-About Command
## Command: `/workspace:update-about`
**GitHub About section optimization** - Updates the repository's About section (description, topics, website) on GitHub with current project information and optimizes for search and discovery.
**🏷️ About Section Management:**
- **Description Update**: Concise, accurate project description
- **Topic Optimization**: Relevant tags for discoverability
- **Website Link**: Updates project website if available
- **SEO Optimization**: Optimizes for GitHub search
- **Keyword Strategy**: Uses effective keywords
- **Consistency**: Matches README and documentation
## Usage
```bash
# Basic update (analyzes and updates)
/workspace:update-about
# With custom description
/workspace:update-about --description "AI-powered autonomous development plugin for Claude Code"
# Add/update topics
/workspace:update-about --add-topics "ai,automation,claude,agents"
# SEO focus
/workspace:update-about --seo-optimize
# Complete refresh
/workspace:update-about --refresh-all
```
## How It Works
1. **Current State Analysis**
- Reads current About section via GitHub API
- Analyzes current description and topics
- Reviews project for accurate information
2. **Content Generation**
- Generates concise description (max 350 chars)
- Identifies relevant topics/tags
- Optimizes for GitHub search
- Ensures accuracy and clarity
3. **SEO Optimization**
- Includes key searchable terms
- Uses popular relevant topics
- Balances specificity and discoverability
- Follows GitHub best practices
4. **Update Execution**
- Updates via GitHub API (requires token)
- Validates changes
- Preserves manual customizations if requested
## Output Format
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏷️ ABOUT SECTION UPDATED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Description (Updated):
"Autonomous AI agents for Claude Code with pattern learning,
quality control, and full-stack validation. Zero-config,
intelligent development automation."
Topics (Added 3):
artificial-intelligence, automation, code-quality,
pattern-learning, autonomous-agents, claude-code
SEO Score: 92/100
+- Keywords: 8 high-value terms [PASS]
+- Topic relevance: 95% [PASS]
+- Discoverability: High [PASS]
[PASS] Updated on GitHub successfully
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Requirements
- GitHub personal access token with repo permissions
- Set in environment variable: `GITHUB_TOKEN`
- Repository must be on GitHub (GitLab support coming)
## Best Practices
### Description Guidelines
- Keep under 350 characters
- Lead with main benefit/purpose
- Include key features/differentiators
- Use searchable keywords naturally
- Avoid jargon unless necessary
### Topic Selection
- Use 5-10 relevant topics
- Mix general and specific terms
- Include language/framework tags
- Add domain-specific terms
- Check GitHub's suggested topics
### SEO Optimization
- Include primary keywords in description
- Use popular, relevant topics
- Match common search terms
- Balance specificity and breadth
- Monitor GitHub search results
---
**Version**: 1.0.0
**Delegates-to**: documentation-generator agent
**Requires**: GitHub API access (GITHUB_TOKEN)
**Platform**: GitHub (GitLab support planned)
**SEO**: Optimized for GitHub discovery

View File

@@ -0,0 +1,111 @@
---
name: workspace:update-readme
description: Smart README update that learns your style and reflects current project state
delegates-to: autonomous-agent:documentation-generator
---
# Workspace Update-README Command
## Command: `/workspace:update-readme`
**Intelligent README maintenance** - Analyzes current README to understand its style, structure, and content approach, then intelligently updates it based on project changes while preserving the established voice and organization.
**📝 Smart README Updates:**
- **Style Learning**: Understands current writing style and tone
- **Structure Preservation**: Maintains existing section organization
- **Content Synchronization**: Updates content to match current project state
- **User Feedback Integration**: Incorporates user suggestions
- **SEO Optimization**: Optimizes for GitHub search and discovery
- **Quality Maintenance**: Ensures clarity and completeness
## Usage
```bash
# Basic update (preserve style and structure)
/workspace:update-readme
# With user suggestions
/workspace:update-readme --suggestions "add installation video, improve examples"
# Change structure
/workspace:update-readme --restructure "move installation first, add troubleshooting section"
# Update specific sections only
/workspace:update-readme --sections "features,usage,examples"
# Complete rewrite (keep data, new style)
/workspace:update-readme --rewrite --style "concise and technical"
```
## How It Works
1. **Current README Analysis**
- Analyzes existing style (formal, casual, technical, etc.)
- Maps current structure and section organization
- Identifies content patterns and conventions
- Notes tone, voice, and audience level
2. **Project State Analysis**
- Scans project for new features
- Identifies changed functionality
- Checks for outdated information
- Reviews code comments and docstrings
3. **Update Strategy**
- Plans sections to update
- Determines what to add/remove/modify
- Preserves user-provided style choices
- Integrates user suggestions
4. **Implementation**
- Updates content while maintaining style
- Preserves formatting and structure
- Adds new sections if needed
- Validates links and examples
5. **Quality Check**
- Verifies all links work
- Tests code examples
- Checks formatting
- Validates completeness
## Output Format
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 README UPDATE COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Style Preserved: Professional with examples
Structure: Maintained (8 sections)
Changes Made:
* Updated features list (+3 new features)
* Refreshed usage examples
* Added 2 new troubleshooting items
* Updated installation instructions
Quality: 94/100
+- All links verified [PASS]
+- Code examples tested [PASS]
+- Formatting consistent [PASS]
📄 Updated: README.md
⏱ Completed in 45 seconds
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
## Integration with Learning
Learns README patterns:
- Effective structures for project types
- Successful writing styles
- Common section organizations
- User preferences
---
**Version**: 1.0.0
**Delegates-to**: documentation-generator agent
**Preserves**: Style, tone, structure (unless told otherwise)
**Updates**: Content, examples, links, accuracy