scripts-batch-update-agents-claude45
#!/usr/bin/env python3 """
title: "Base directory" component_type: script version: "1.0.0" audience: contributor status: stable summary: "Batch update P2 support agents with Claude 4.5 optimization patterns. Applies standardized pa..." keywords: ['agents', 'analysis', 'batch', 'claude45', 'optimization'] tokens: ~500 created: 2025-12-22 updated: 2025-12-22 script_name: "batch-update-agents-claude45.py" language: python executable: true usage: "python3 scripts/batch-update-agents-claude45.py [options]" python_version: "3.10+" dependencies: [] modifies_files: false network_access: false requires_auth: false
Batch update P2 support agents with Claude 4.5 optimization patterns. Applies standardized patterns to remaining 21 agents. """
import argparse import os from pathlib import Path
Base directory
AGENTS_DIR = Path(file).parent.parent / "agents"
Remaining P2 agents to update (excluding the 5 already done)
REMAINING_AGENTS = [ # Project Lifecycle (2 more) ("production-cleanup-orchestrator.md", "proactive"), ("submodule-orchestrator.md", "proactive"),
# Specialized Support (21 agents)
("ai-specialist.md", "proactive"),
("cloud-architect-code-reviewer.md", "conservative"),
("generative-ui-accessibility-auditor.md", "conservative"),
("novelty-detection-specialist.md", "conservative"),
("orchestrator-code-review.md", "conservative"),
("orchestrator-detailed-backup.md", "conservative"),
("prompt-analyzer-specialist.md", "conservative"),
("rust-qa-specialist.md", "conservative"),
("script-utility-analyzer.md", "conservative"),
("software-design-architect.md", "proactive"),
("software-design-document-specialist.md", "proactive"),
("terminal-integration-specialist.md", "proactive"),
("testing-specialist.md", "proactive"),
("thoughts-analyzer.md", "conservative"),
("thoughts-locator.md", "conservative"),
("wasm-optimization-expert.md", "proactive"),
("websocket-protocol-designer.md", "proactive"),
]
def get_claude45_section(agent_name, action_policy): """Generate Claude 4.5 section with appropriate action policy."""
# Map agent to specific metrics
agent_metrics = {
"production-cleanup-orchestrator.md": ("Cleanup Score", "95/100"),
"submodule-orchestrator.md": ("Submodules Configured", "3"),
"ai-specialist.md": ("Response Time", "<2s"),
"cloud-architect-code-reviewer.md": ("Issues Found", "12"),
"generative-ui-accessibility-auditor.md": ("WCAG Score", "AA compliant"),
"novelty-detection-specialist.md": ("Novel Patterns", "5"),
"orchestrator-code-review.md": ("Code Quality", "4.5/5.0"),
"orchestrator-detailed-backup.md": ("Files Backed Up", "150"),
"prompt-analyzer-specialist.md": ("Optimization Potential", "30%"),
"rust-qa-specialist.md": ("Test Coverage", "95%"),
"script-utility-analyzer.md": ("Scripts Analyzed", "8"),
"software-design-architect.md": ("Architecture Complete", "Yes"),
"software-design-document-specialist.md": ("Documents Generated", "3"),
"terminal-integration-specialist.md": ("Integration Tests", "Passing"),
"testing-specialist.md": ("Tests Created", "45"),
"thoughts-analyzer.md": ("Insights Extracted", "12"),
"thoughts-locator.md": ("Documents Found", "8"),
"wasm-optimization-expert.md": ("Binary Size", "1.2MB → 800KB"),
"websocket-protocol-designer.md": ("Protocol Defined", "Yes"),
}
metric1, value1 = agent_metrics.get(agent_name, ("Operations Complete", "5"))
policy_section = ""
if action_policy == "proactive":
policy_section = """**Proactive Implementation:**
<default_to_action> When task requirements are clear, proceed with implementation without requiring explicit instructions for each step. Infer best practices from domain knowledge. </default_to_action>""" else: policy_section = """Conservative Analysis: <do_not_act_before_instructions> Provide analysis and recommendations before making changes. Only proceed with modifications when explicitly requested to ensure alignment with user intent. </do_not_act_before_instructions>"""
return f"""---
Claude 4.5 Optimization Patterns
Communication Style
Concise Progress Reporting: Provide brief, fact-based updates after operations without excessive framing. Focus on actionable results.
Tool Usage
Parallel Operations: Use parallel tool calls when analyzing multiple files or performing independent operations.
Action Policy
{policy_section}
Code Exploration
Pre-Implementation Analysis: Always Read relevant code files before proposing changes. Never hallucinate implementation details - verify actual patterns.
Avoid Overengineering
Practical Solutions: Provide implementable fixes and straightforward patterns. Avoid theoretical discussions when concrete examples suffice.
Progress Reporting
After completing major operations:
## Operation Complete
**{metric1}:** {value1}
**Status:** Ready for next phase
Next: [Specific next action based on context]
"""
def update_agent(agent_file, action_policy): """Add Claude 4.5 section to agent file.""" filepath = AGENTS_DIR / agent_file
if not filepath.exists():
print(f"❌ Not found: {agent_file}")
return False
content = filepath.read_text()
# Check if already has Claude 4.5 section
if "## Claude 4.5 Optimization Patterns" in content:
print(f"⏭️ Already updated: {agent_file}")
return True
# Add section at end
claude45_section = get_claude45_section(agent_file, action_policy)
updated_content = content.rstrip() + "\n\n" + claude45_section
filepath.write_text(updated_content)
print(f"✅ Updated: {agent_file}")
return True
def parse_args(): """Parse command line arguments""" parser = argparse.ArgumentParser( description='Batch update agent files with Claude 4.5 optimization patterns.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog=''' Examples: %(prog)s # Update all remaining P2 agents %(prog)s --dry-run # Show what would be changed without modifying files %(prog)s --list # List agents that would be updated %(prog)s --verbose # Show detailed output
Adds to each agent file:
- Claude 4.5 Optimization Patterns section
- Communication Style guidelines
- Action Policy (proactive or conservative)
- Progress Reporting templates ''' ) parser.add_argument('--dry-run', action='store_true', help='Show what would be changed without modifying files') parser.add_argument('--list', action='store_true', help='List agents that would be updated') parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output') parser.add_argument('--agent', type=str, help='Update only a specific agent file') return parser.parse_args()
def main(): """Update all remaining P2 agents.""" args = parse_args()
# Handle --list
if args.list:
print("Agents to update:")
for agent_file, action_policy in REMAINING_AGENTS:
print(f" - {agent_file} ({action_policy})")
return
print("🚀 Batch updating P2 agents with Claude 4.5 patterns...\n")
updated = 0
failed = 0
agents_to_process = REMAINING_AGENTS
if args.agent:
agents_to_process = [(a, p) for a, p in REMAINING_AGENTS if args.agent in a]
if not agents_to_process:
print(f"No matching agent found for: {args.agent}")
return
for agent_file, action_policy in agents_to_process:
if update_agent(agent_file, action_policy):
updated += 1
else:
failed += 1
print(f"\n📊 Summary:")
print(f" ✅ Updated: {updated}")
print(f" ❌ Failed: {failed}")
print(f" 📝 Total: {updated + failed}")
if name == "main": main()