#!/usr/bin/env python3 """ Agent Generator Script Creates custom subagents with built-in communication protocol """ import json import argparse from pathlib import Path from datetime import datetime from typing import Dict, List class AgentGenerator: """Generates custom subagents with communication protocol""" AGENT_TEMPLATES = { # ===== CORE AGENTS (Always available) ===== 'project-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Intelligently analyzes projects to identify type, pain points, and automation opportunities', 'mission': '''Analyze projects with intelligence and context, not just pattern matching. Focus areas: - Project type and purpose (understand, don't just count files) - Technology stack and existing tools - Real pain points (ask user, don't guess) - High-value automation opportunities - Integration with existing workflow''', 'process': '''1. Read metrics from collect_project_metrics.py 2. Read key files (README, package.json, main files) 3. Understand project context and purpose 4. Check for existing automation tools 5. Ask user clarifying questions 6. Identify real pain points 7. Recommend high-value automation 8. Write analysis to project-analysis.json''', 'tools': 'Read, Glob, Grep, Bash, AskUserQuestion' }, 'security-analyzer': { 'color': 'Red', 'model': 'sonnet', 'description': 'Analyzes code for security vulnerabilities, authentication flaws, and sensitive data exposure', 'mission': '''Perform comprehensive security analysis of the codebase. Focus areas: - SQL injection vulnerabilities - XSS and CSRF protection - Authentication and authorization flaws - Sensitive data exposure (API keys, passwords) - Input validation - Secure communication (HTTPS, encryption) - Dependencies with known vulnerabilities''', 'process': '''1. Scan codebase for security patterns using Grep 2. Analyze authentication/authorization logic 3. Check for exposed secrets 4. Review dependencies for CVEs 5. Generate prioritized vulnerability list 6. Provide remediation recommendations''', 'tools': 'Read, Grep, Glob, Bash' }, 'performance-analyzer': { 'color': 'Yellow', 'model': 'sonnet', 'description': 'Identifies performance bottlenecks, inefficient algorithms, and optimization opportunities', 'mission': '''Analyze application performance and identify optimization opportunities. Focus areas: - Slow database queries - N+1 query problems - Inefficient algorithms (O(n²) or worse) - Memory leaks - Large bundle sizes - Unoptimized assets - Missing caching opportunities''', 'process': '''1. Profile critical paths 2. Analyze database query patterns 3. Identify algorithmic inefficiencies 4. Check asset sizes and loading strategies 5. Review caching implementation 6. Generate optimization recommendations''', 'tools': 'Read, Grep, Glob, Bash' }, 'code-quality-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Evaluates code quality, maintainability, and adherence to best practices', 'mission': '''Assess code quality and maintainability. Focus areas: - Code complexity (cyclomatic complexity) - Code duplication - Naming conventions - Function/method length - Documentation quality - Error handling patterns - SOLID principles adherence''', 'process': '''1. Analyze code complexity metrics 2. Detect code duplication 3. Review naming conventions 4. Check documentation coverage 5. Evaluate error handling 6. Suggest refactoring opportunities''', 'tools': 'Read, Grep, Glob, Bash' }, 'dependency-analyzer': { 'color': 'Magenta', 'model': 'sonnet', 'description': 'Analyzes project dependencies, identifies outdated packages, and security issues', 'mission': '''Analyze project dependencies and dependency graph. Focus areas: - Outdated dependencies - Security vulnerabilities in dependencies - Unused dependencies - Dependency conflicts - License compliance - Circular dependencies''', 'process': '''1. Parse dependency files (package.json, requirements.txt, etc.) 2. Check for outdated versions 3. Scan for known vulnerabilities 4. Identify unused dependencies 5. Analyze dependency graph 6. Generate update recommendations''', 'tools': 'Read, Bash, Grep' }, 'documentation-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Evaluates documentation completeness and suggests improvements', 'mission': '''Assess documentation quality and coverage. Focus areas: - README completeness - API documentation - Code comments quality - Setup instructions - Architecture documentation - Usage examples''', 'process': '''1. Review README and docs/ 2. Check code comment coverage 3. Validate API documentation 4. Assess example quality 5. Identify missing sections 6. Generate documentation plan''', 'tools': 'Read, Grep, Glob' }, 'skill-generator': { 'color': 'Green', 'model': 'sonnet', 'description': 'Generates custom skills based on analysis findings', 'mission': '''Create custom skills tailored to project needs. Based on analysis reports, generate skills for: - Repetitive workflows - Domain-specific tasks - Quality assurance - Testing automation - Documentation generation''', 'process': '''1. Read all analysis reports 2. Identify automation opportunities 3. Design skill specifications 4. Generate SKILL.md files 5. Create supporting scripts 6. Document usage''', 'tools': 'Read, Write, Bash' }, 'command-generator': { 'color': 'Green', 'model': 'sonnet', 'description': 'Generates custom slash commands for common workflows', 'mission': '''Create custom slash commands for frequent tasks. Generate commands for: - Testing workflows - Code review - Deployment - Documentation updates - Project-specific operations''', 'process': '''1. Read analysis reports 2. Identify command-worthy tasks 3. Design command specifications 4. Generate command .md files 5. Document usage examples''', 'tools': 'Write, Read' }, 'hook-generator': { 'color': 'Green', 'model': 'sonnet', 'description': 'Generates automation hooks for lifecycle events', 'mission': '''Create hooks for workflow automation. Generate hooks for: - Code formatting (PostToolUse) - Security validation (PreToolUse) - Test execution (PostToolUse) - Notifications (Stop) - Context injection (UserPromptSubmit)''', 'process': '''1. Read analysis reports 2. Identify hook opportunities 3. Design hook specifications 4. Generate Python hook scripts 5. Update settings.json 6. Document behavior''', 'tools': 'Write, Read' }, 'mcp-configurator': { 'color': 'Green', 'model': 'sonnet', 'description': 'Configures MCP servers for external integrations', 'mission': '''Set up MCP server integrations. Configure servers for: - GitHub (PR automation, issues) - Database (query optimization) - Slack (team notifications) - Cloud services - Project-specific APIs''', 'process': '''1. Read external service requirements 2. Design MCP configurations 3. Update settings.json 4. Document MCP usage 5. Provide setup instructions''', 'tools': 'Write, Read' }, 'integration-tester': { 'color': 'Purple', 'model': 'sonnet', 'description': 'Validates that all automation components work together', 'mission': '''Test the complete automation system. Validate: - Agents can read each other's reports - Skills invoke correctly - Commands execute properly - Hooks trigger appropriately - MCP servers connect''', 'process': '''1. Test agent communication 2. Invoke each skill 3. Execute each command 4. Trigger hooks 5. Validate MCP connections 6. Generate test report''', 'tools': 'Read, Bash, Write' }, 'documentation-validator': { 'color': 'Purple', 'model': 'sonnet', 'description': 'Ensures all automation is properly documented', 'mission': '''Validate documentation completeness. Check that: - Each agent is documented - Skills have usage examples - Commands have clear descriptions - Hooks are explained - MCP setup is documented - README is comprehensive''', 'process': '''1. Check each component for docs 2. Validate README completeness 3. Ensure examples are present 4. Test documentation clarity 5. Generate doc improvements''', 'tools': 'Read, Write, Grep' }, # ===== UNIVERSAL AGENTS (work across all domains) ===== 'structure-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Analyzes organization patterns, folder hierarchies, naming conventions across any project type', 'mission': '''Analyze project structure and organization patterns. Focus areas: - Directory hierarchy and depth - Naming conventions consistency - File organization patterns - Structural patterns and conventions - Navigation efficiency - Scalability of structure''', 'process': '''1. Map directory structure 2. Analyze naming patterns 3. Identify organization conventions 4. Check consistency across project 5. Evaluate findability and navigation 6. Recommend structural improvements''', 'tools': 'Read, Glob, Bash' }, 'workflow-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Identifies processes, repetitive tasks, and bottlenecks in any project workflow', 'mission': '''Analyze workflows and identify automation opportunities. Focus areas: - Repetitive manual tasks - Process bottlenecks - Workflow inefficiencies - Task dependencies - Time-consuming operations - Automation candidates''', 'process': '''1. Map current workflows 2. Identify repetitive patterns 3. Measure task frequency 4. Find bottlenecks 5. Estimate time savings potential 6. Prioritize automation opportunities''', 'tools': 'Read, Grep, Glob, Bash' }, 'asset-analyzer': { 'color': 'Yellow', 'model': 'sonnet', 'description': 'Inventories resources, identifies gaps, and finds duplicates across any project type', 'mission': '''Analyze project assets and resources. Focus areas: - Asset inventory and cataloging - Missing or incomplete assets - Duplicate resources - Asset quality and consistency - Usage patterns - Storage optimization''', 'process': '''1. Inventory all assets 2. Categorize by type and purpose 3. Identify duplicates 4. Find gaps in coverage 5. Assess quality consistency 6. Recommend optimization''', 'tools': 'Read, Glob, Bash' }, 'metadata-analyzer': { 'color': 'Magenta', 'model': 'sonnet', 'description': 'Reviews tags, properties, and categorization across files and resources', 'mission': '''Analyze metadata completeness and consistency. Focus areas: - Metadata coverage - Tagging consistency - Property completeness - Categorization accuracy - Search/findability - Metadata standards adherence''', 'process': '''1. Survey metadata usage 2. Check completeness 3. Validate consistency 4. Assess categorization 5. Evaluate searchability 6. Recommend metadata improvements''', 'tools': 'Read, Grep, Glob, Bash' }, # ===== EDUCATIONAL DOMAIN AGENTS ===== 'learning-path-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Analyzes learning progression, difficulty curve, and prerequisite relationships in educational content', 'mission': '''Analyze learning path structure and progression. Focus areas: - Lesson sequencing and dependencies - Difficulty progression curve - Prerequisite relationships - Learning objective coverage - Skill progression - Knowledge gaps''', 'process': '''1. Map lesson dependencies 2. Analyze difficulty progression 3. Validate prerequisites 4. Check objective coverage 5. Identify skill gaps 6. Recommend sequencing improvements''', 'tools': 'Read, Grep, Glob' }, 'assessment-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Reviews quiz coverage, difficulty distribution, and learning validation in educational projects', 'mission': '''Analyze assessment quality and coverage. Focus areas: - Assessment coverage per lesson - Difficulty distribution - Question quality - Learning objective alignment - Knowledge validation - Assessment variety''', 'process': '''1. Map assessments to lessons 2. Analyze difficulty levels 3. Check objective coverage 4. Review question quality 5. Evaluate variety 6. Recommend assessment improvements''', 'tools': 'Read, Grep, Glob' }, 'engagement-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Evaluates interactivity, variety, and retention mechanisms in educational content', 'mission': '''Analyze content engagement and interactivity. Focus areas: - Interactive elements - Content variety - Engagement techniques - Media diversity - Practice opportunities - Retention mechanisms''', 'process': '''1. Survey interactive elements 2. Analyze content variety 3. Check engagement patterns 4. Evaluate media usage 5. Review practice distribution 6. Recommend engagement improvements''', 'tools': 'Read, Grep, Glob' }, # ===== PROJECT MANAGEMENT DOMAIN AGENTS ===== 'timeline-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Checks schedules, dependencies, and critical paths in project management contexts', 'mission': '''Analyze project timelines and schedules. Focus areas: - Schedule consistency - Task dependencies - Critical path identification - Milestone distribution - Timeline realism - Scheduling conflicts''', 'process': '''1. Parse timeline documents 2. Map task dependencies 3. Identify critical paths 4. Check milestone spacing 5. Validate schedule feasibility 6. Recommend timeline improvements''', 'tools': 'Read, Grep, Glob' }, 'resource-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Reviews resource allocation, capacity, and utilization in project management', 'mission': '''Analyze resource allocation and capacity. Focus areas: - Resource allocation patterns - Capacity utilization - Over/under allocation - Skill matching - Resource conflicts - Efficiency opportunities''', 'process': '''1. Map resource allocations 2. Calculate utilization rates 3. Identify conflicts 4. Check skill alignment 5. Find bottlenecks 6. Recommend optimization''', 'tools': 'Read, Grep, Glob' }, 'risk-analyzer': { 'color': 'Red', 'model': 'sonnet', 'description': 'Identifies risks, blockers, and mitigation strategies in project management', 'mission': '''Analyze project risks and mitigation strategies. Focus areas: - Risk identification - Impact assessment - Likelihood evaluation - Mitigation coverage - Blocker patterns - Contingency planning''', 'process': '''1. Identify potential risks 2. Assess impact and likelihood 3. Review mitigation plans 4. Check for blockers 5. Evaluate contingencies 6. Recommend risk improvements''', 'tools': 'Read, Grep, Glob' }, # ===== FILE ORGANIZATION DOMAIN AGENTS ===== 'categorization-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Reviews folder structure, taxonomy consistency, and categorization in file organization projects', 'mission': '''Analyze file categorization and taxonomy. Focus areas: - Category structure - Taxonomy consistency - Classification accuracy - Category distribution - Naming conventions - Hierarchy depth''', 'process': '''1. Map category structure 2. Analyze taxonomy patterns 3. Check classification consistency 4. Review distribution 5. Validate naming 6. Recommend categorization improvements''', 'tools': 'Read, Glob, Bash' }, 'duplication-analyzer': { 'color': 'Yellow', 'model': 'sonnet', 'description': 'Finds duplicate and similar files in file organization projects', 'mission': '''Identify duplicate and similar files. Focus areas: - Exact duplicates - Similar content - Version variations - Naming differences - Storage waste - Consolidation opportunities''', 'process': '''1. Scan for duplicate files 2. Identify similar content 3. Group by similarity 4. Calculate storage impact 5. Suggest merging strategy 6. Recommend deduplication''', 'tools': 'Read, Glob, Bash' }, 'archiving-analyzer': { 'color': 'Magenta', 'model': 'sonnet', 'description': 'Identifies archiving candidates and optimization opportunities in file organization', 'mission': '''Analyze archiving opportunities and strategies. Focus areas: - Stale content identification - Access pattern analysis - Archive candidates - Compression opportunities - Retention policies - Storage optimization''', 'process': '''1. Identify rarely accessed files 2. Analyze age and usage 3. Find archive candidates 4. Calculate storage savings 5. Recommend archiving strategy 6. Suggest retention policies''', 'tools': 'Read, Glob, Bash' }, # ===== CONTENT CREATION DOMAIN AGENTS ===== 'consistency-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Checks style, tone, formatting consistency in content creation projects', 'mission': '''Analyze content consistency and style adherence. Focus areas: - Writing style consistency - Tone uniformity - Formatting standards - Brand voice adherence - Terminology consistency - Template usage''', 'process': '''1. Survey content style 2. Analyze tone patterns 3. Check formatting consistency 4. Validate terminology 5. Review template adherence 6. Recommend consistency improvements''', 'tools': 'Read, Grep, Glob' }, 'distribution-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Reviews publishing channels, formats, and distribution in content projects', 'mission': '''Analyze content distribution and publishing. Focus areas: - Publishing channels - Format coverage - Distribution schedule - Platform optimization - Repurposing opportunities - Reach optimization''', 'process': '''1. Map publishing channels 2. Analyze format distribution 3. Check publishing schedule 4. Review platform optimization 5. Identify repurposing opportunities 6. Recommend distribution improvements''', 'tools': 'Read, Grep, Glob' }, 'seo-analyzer': { 'color': 'Yellow', 'model': 'sonnet', 'description': 'Evaluates discoverability, keywords, and metadata in content projects', 'mission': '''Analyze content SEO and discoverability. Focus areas: - Keyword usage - Meta descriptions - Title optimization - Header structure - Link structure - Discoverability''', 'process': '''1. Analyze keyword usage 2. Review meta tags 3. Check title optimization 4. Validate header structure 5. Examine link patterns 6. Recommend SEO improvements''', 'tools': 'Read, Grep, Glob' }, # ===== RESEARCH DOMAIN AGENTS ===== 'literature-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Reviews reference coverage, citations, and literature quality in research projects', 'mission': '''Analyze literature coverage and citations. Focus areas: - Citation completeness - Reference quality - Coverage breadth - Recency of sources - Citation format - Literature gaps''', 'process': '''1. Survey cited literature 2. Analyze coverage 3. Check recency 4. Validate citations 5. Identify gaps 6. Recommend literature improvements''', 'tools': 'Read, Grep, Glob' }, 'methodology-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Validates research methods, reproducibility, and rigor in research projects', 'mission': '''Analyze research methodology and rigor. Focus areas: - Method documentation - Reproducibility - Data collection procedures - Analysis approach - Control measures - Methodology consistency''', 'process': '''1. Review method documentation 2. Check reproducibility 3. Validate procedures 4. Analyze approach 5. Verify controls 6. Recommend methodology improvements''', 'tools': 'Read, Grep, Glob' }, 'results-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Checks data integrity, visualization quality, and results presentation in research', 'mission': '''Analyze results presentation and integrity. Focus areas: - Data integrity - Visualization quality - Results clarity - Statistical rigor - Presentation completeness - Reproducible figures''', 'process': '''1. Review data integrity 2. Analyze visualizations 3. Check results clarity 4. Validate statistics 5. Assess completeness 6. Recommend presentation improvements''', 'tools': 'Read, Grep, Glob, Bash' }, # ===== ACADEMIC/TECHNICAL WRITING DOMAIN AGENTS ===== 'latex-structure-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Analyzes LaTeX document structure, cross-references, figures, and bibliography', 'mission': '''Analyze LaTeX document structure and completeness. Focus areas: - Document structure (chapters, sections, subsections) - Cross-reference integrity (\\ref, \\label) - Figure and table references - Bibliography completeness - LaTeX compilation issues - Package usage and conflicts''', 'process': '''1. Parse LaTeX document structure 2. Validate \\ref and \\label pairs 3. Check figure/table references 4. Review bibliography entries 5. Identify compilation issues 6. Recommend structure improvements''', 'tools': 'Read, Grep, Glob, Bash' }, 'citation-analyzer': { 'color': 'Magenta', 'model': 'sonnet', 'description': 'Validates .bib entries, citation usage, and bibliography completeness', 'mission': '''Analyze citation and bibliography quality. Focus areas: - .bib entry completeness - Citation usage (\\cite commands) - Unused bibliography entries - Citation format consistency - Missing citations - Duplicate entries''', 'process': '''1. Parse .bib files 2. Find all \\cite commands 3. Cross-check usage 4. Identify unused entries 5. Check format consistency 6. Recommend bibliography improvements''', 'tools': 'Read, Grep, Glob' }, 'html-structure-analyzer': { 'color': 'Cyan', 'model': 'sonnet', 'description': 'Analyzes HTML document hierarchy, semantic structure, and navigation', 'mission': '''Analyze HTML document structure and semantics. Focus areas: - Page hierarchy and organization - Semantic HTML usage - Navigation structure - Heading levels consistency - Document outline - Cross-page relationships''', 'process': '''1. Parse HTML document structure 2. Analyze heading hierarchy 3. Check semantic elements 4. Review navigation 5. Map page relationships 6. Recommend structure improvements''', 'tools': 'Read, Grep, Glob, Bash' }, 'link-validator': { 'color': 'Yellow', 'model': 'sonnet', 'description': 'Validates all links (internal, external, wiki-style) across HTML and Markdown', 'mission': '''Validate all links in documents. Focus areas: - Internal link integrity - External link validity - Wiki-style [[links]] - Markdown []() links - Anchor references - Orphaned pages''', 'process': '''1. Find all links 2. Validate internal links 3. Check external links 4. Identify broken links 5. Find orphaned pages 6. Recommend link fixes''', 'tools': 'Read, Grep, Glob, Bash' }, 'cross-reference-analyzer': { 'color': 'Green', 'model': 'sonnet', 'description': 'Validates cross-references across LaTeX, HTML, and Markdown documents', 'mission': '''Analyze cross-reference integrity across documents. Focus areas: - LaTeX \\ref references - HTML anchor links - Markdown internal links - Figure/table references - Section references - Broken references''', 'process': '''1. Identify all reference types 2. Validate targets exist 3. Check reference format 4. Find broken references 5. Detect orphaned targets 6. Recommend reference improvements''', 'tools': 'Read, Grep, Glob' }, 'formatting-analyzer': { 'color': 'Blue', 'model': 'sonnet', 'description': 'Checks formatting consistency across LaTeX, HTML, and Markdown documents', 'mission': '''Analyze document formatting consistency. Focus areas: - Heading styles consistency - List formatting - Code block formatting - Table formatting - Image caption format - Spacing and indentation''', 'process': '''1. Survey formatting patterns 2. Identify inconsistencies 3. Check style adherence 4. Review spacing 5. Validate structure 6. Recommend formatting improvements''', 'tools': 'Read, Grep, Glob' }, 'accessibility-analyzer': { 'color': 'Magenta', 'model': 'sonnet', 'description': 'Checks WCAG compliance, alt text, and semantic HTML for accessibility', 'mission': '''Analyze document accessibility. Focus areas: - Alt text presence and quality - Semantic HTML usage - ARIA labels - Color contrast - Heading hierarchy - Keyboard navigation''', 'process': '''1. Check alt text coverage 2. Validate semantic HTML 3. Review ARIA usage 4. Test heading structure 5. Assess navigation 6. Recommend accessibility improvements''', 'tools': 'Read, Grep, Glob' } } def __init__(self, session_id: str): self.session_id = session_id def generate_agent(self, agent_type: str, output_path: str) -> None: """Generate a custom agent file""" if agent_type not in self.AGENT_TEMPLATES: raise ValueError(f"Unknown agent type: {agent_type}") template = self.AGENT_TEMPLATES[agent_type] agent_name = agent_type content = f'''--- name: {agent_name} description: {template['description']} tools: {template['tools']} color: {template['color']} model: {template['model']} --- # {agent_name.replace('-', ' ').title()} You are a specialized {agent_name} in a multi-agent automation system. ## Communication Protocol **Session ID**: `{self.session_id}` **Context Directory**: `.claude/agents/context/{self.session_id}/` ### Before You Start 1. **Check Dependencies**: Read coordination.json to see if prerequisite agents have finished 2. **Review Context**: Read reports from other agents that might inform your work 3. **Announce Yourself**: Log your startup to the message bus ```bash # Check coordination status cat .claude/agents/context/{self.session_id}/coordination.json | jq '.agents' # Read other agents' reports (if available) ls .claude/agents/context/{self.session_id}/reports/ cat .claude/agents/context/{self.session_id}/reports/*.json # Log your startup echo "{{\\"timestamp\\":\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\",\\"from\\":\\"{agent_name}\\",\\"type\\":\\"status\\",\\"message\\":\\"Starting analysis\\"}}" >> \\ .claude/agents/context/{self.session_id}/messages.jsonl ``` ## Your Mission {template['mission']} ## Process {template['process']} ## Communication Requirements ### 1. Log Progress As you work, log significant events: ```bash # Log a finding echo "{{\\"timestamp\\":\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\",\\"from\\":\\"{agent_name}\\",\\"type\\":\\"finding\\",\\"severity\\":\\"high\\",\\"data\\":{{\\"title\\":\\"Issue found\\",\\"location\\":\\"file:line\\"}}}}" >> \\ .claude/agents/context/{self.session_id}/messages.jsonl # Log progress updates echo "{{\\"timestamp\\":\\"$(date -u +%Y-%m-%dT%H:%M:\\%SZ)\\",\\"from\\":\\"{agent_name}\\",\\"type\\":\\"status\\",\\"message\\":\\"Analyzed 50% of codebase\\"}}" >> \\ .claude/agents/context/{self.session_id}/messages.jsonl ``` ### 2. Write Your Report Create a comprehensive report in standardized JSON format: ```bash cat > .claude/agents/context/{self.session_id}/reports/{agent_name}.json << 'EOF' {{ "agent_name": "{agent_name}", "timestamp": "2025-01-23T10:00:00Z", "status": "completed", "summary": "Brief overview of your findings (2-3 sentences)", "findings": [ {{ "type": "issue", "severity": "high", "title": "Finding title", "description": "Detailed description", "location": "file:line or component", "recommendation": "What to do about it", "example": "Code snippet or example" }} ], "metrics": {{ "items_analyzed": 150, "issues_found": 5, "time_taken": "2m 34s" }}, "data_artifacts": [ "data/{agent_name}-details.json" ], "next_actions": [ "Suggested follow-up action", "Another recommendation" ], "recommendations_for_automation": [ "Skill idea: Auto-fix common issues", "Command idea: /quick-security-scan", "Hook idea: Validate on commit" ] }} EOF ``` ### 3. Create Data Artifacts (if needed) Store detailed data for other agents to use: ```bash # Example: Detailed findings cat > .claude/agents/context/{self.session_id}/data/{agent_name}-details.json << 'EOF' {{ "detailed_findings": [...], "raw_data": {{...}} }} EOF ``` ### 4. Update Coordination Status ```bash # Update your status to completed cat .claude/agents/context/{self.session_id}/coordination.json | \\ jq '.agents["{agent_name}"] = {{ "status": "completed", "started_at": "2025-01-23T10:00:00Z", "completed_at": "2025-01-23T10:05:00Z", "report_path": "reports/{agent_name}.json" }}' > /tmp/coord.json && \\ mv /tmp/coord.json .claude/agents/context/{self.session_id}/coordination.json ``` ### 5. Final Announcement ```bash echo "{{\\"timestamp\\":\\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\",\\"from\\":\\"{agent_name}\\",\\"type\\":\\"completed\\",\\"message\\":\\"Analysis complete. Found X issues.\\"}}" >> \\ .claude/agents/context/{self.session_id}/messages.jsonl ``` ## Output Quality Standards Your report must be: - **Actionable**: Provide specific recommendations - **Prioritized**: Rank findings by severity/impact - **Evidence-based**: Include examples and locations - **Comprehensive**: Cover all aspects of your domain - **Useful for automation**: Suggest automation opportunities ## Success Criteria ✅ Completed analysis thoroughly ✅ Logged progress to message bus ✅ Created standardized report ✅ Updated coordination status ✅ Provided actionable recommendations ✅ Identified automation opportunities Remember: Your findings will be read by other agents and used to generate automation. Make them clear, specific, and actionable! ''' Path(output_path).parent.mkdir(parents=True, exist_ok=True) Path(output_path).write_text(content) print(f"Generated {agent_type} agent at {output_path}") @classmethod def get_available_agents(cls) -> List[str]: """Get list of available agent types""" return list(cls.AGENT_TEMPLATES.keys()) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Generate custom subagents') parser.add_argument('--session-id', required=True, help='Session ID for communication') parser.add_argument('--agent-type', required=True, help='Type of agent to generate') parser.add_argument('--output', required=True, help='Output file path') args = parser.parse_args() generator = AgentGenerator(args.session_id) generator.generate_agent(args.agent_type, args.output)