Skip to main content
ClaudeWave
Skill1.2k repo starsupdated yesterday

optimizer

The Optimizer skill analyzes and automatically improves existing agents by examining their system prompts and tool configurations using abstract syntax tree analysis. Use this skill when needing to enhance agent behavior, correct flaws, or expand agent capabilities through targeted modifications to core behavioral drivers without manual code editing.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/inclusionAI/AWorld /tmp/optimizer && cp -r /tmp/optimizer/aworld-skills/optimizer ~/.claude/skills/optimizer
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Agent Optimization Skill (Optimizer)

## 📌 Mandatory Usage Guidelines
**CRITICAL: READ BEFORE USE.** Adherence to these rules is essential for the skill to function correctly.

1.  **Tool Calls are Direct**:
    *   ✅ **DO** call tool functions like `CAST_ANALYSIS(...)` and `CAST_CODER(...)` directly.
    *   ❌ **DO NOT** write or show Python code examples that import or manually implement tool logic (e.g., `from aworld.experimental.ast import ACast`). The tools are pre-loaded and ready for direct invocation.

2.  **`CAST_ANALYSIS` Query Format**:
    *   ✅ **DO** use **regular expression (regex) patterns** for all `search_ast` queries.
        *   *Example*: `.*MyClassName.*|.*my_function_name.*`
    *   ❌ **DO NOT** use natural language for `search_ast` queries.
        *   *Incorrect*: `"Show me the implementation of the MyClassName class"`

3.  **`CAST_CODER` Workflow**:
    *   ✅ **DO** use `CAST_CODER.generate_snapshot` to create a backup before any modifications.
    *   ✅ **DO** generate patch content (either structured JSON for `search_replace` or `diff` format text) based on your analysis. The LLM's role is to *create* the patch content.
    *   ✅ **DO** use `CAST_CODER` actions (like `search_replace`) to *apply* the generated patch content to the source code.
    *   ❌ **DO NOT** show Python lists of patches to the user (e.g., `patches = [...]`).

4.  **Patch Content Rules**:
    *   ✅ **DO** ensure each patch operation targets **only one file**.
    *   ✅ **DO** create focused patches that modify **one logical block of code at a time** for clarity and safety.
    *   ✅ **DO** verify code with `CAST_ANALYSIS.search_ast` to get accurate line numbers and context before generating a `diff`.

## 📜 Skill Overview
The **Optimizer Skill** is an advanced agent capability designed to analyze and enhance other agents. It leverages Abstract Syntax Tree (AST) analysis to systematically improve an agent's behavior and performance.

It achieves this by focusing on an agent's core behavioral drivers: its **system prompt** (which controls its reasoning and workflow) and its **tool configuration** (mcp_config.py) (which defines its capabilities). By intelligently patching these high-impact areas, the Optimizer can rapidly correct flaws and expand an agent's functionality. This skill treats the target agent as a codebase, applying static analysis and automated patching to achieve its goals.

## ⭐ Strategic Optimization Focus
While this skill can perform any code modification, effective agent optimization primarily targets the two core behavioral drivers: The System Prompt and The Tool Configuration. Your analysis and proposed solutions must prioritize these areas.

1. **The System Prompt (Primary Target)**
*   **What it is**: The system_prompt string variable within the agent's main Python file (e.g., simple_agent.py).
*   **Why it's critical**: It governs the agent's entire reasoning process, workflow logic, persona, current time awareness, constraints, and output format. Most behavioral problems (e.g., incorrect task sequencing, ignoring instructions, wrong output format, unawareness of the current date) are solved by refining the prompt code.
*   **Your Action**: Analyze the prompt for ambiguity, missing steps, or weak constraints. Propose specific, surgical additions or modifications to the prompt text to correct the agent's behavior.
    Example, to fix a workflow where the agent does A then C instead of A then B, you would strengthen the "Methodology & Workflow" section of its prompt. Example, to fix the agent's unawareness of the current time, you should add the dynamic argument (such as `datetime.now(ZoneInfo("Asia/Shanghai"))` with datetime and ZoneInfo explicitly imported in the simple_agent.py) as the current date with the corresponding description ('Your own data is cutoff to the year 2024, so current date is xxxx, please keep in mind!') in the prompt code, to let the agent be aware of the current time.

2. **The Tool Configuration (mcp_config.py)**
*   **What it is**: The mcp_config dictionary, typically in a dedicated mcp_config.py file.
*   **Why it's critical**: It defines the agent's capabilities. A missing capability (e.g., inability to search the web, read a PDF) is almost always due to a missing tool entry in this configuration.
*   **Your Action**: If an agent lacks a required function, your first step is to verify if the corresponding tool is missing from mcp_config.py. Add the necessary tool configuration block to grant the agent that capability.
*   **MCP Configuration**: Which MCP servers (e.g., pptx, google) are required? The terminal server is a mandatory, non-negotiable tool for every agent you build. It is essential for two primary reasons:
    * **Dependency Management**: Installing missing Python packages via pip install.
    * **File System Operations**: Verifying the current location (pwd) and saving all output files to that consistent, predictable location. You must ensure this tool is always included.

**Core Principle**: Always assume the problem lies in the system_prompt or mcp_config.py first. Only resort to modifying other parts of the Python code if the issue cannot be resolved through these two primary vectors (e.g., adding support for a dynamic variable in the prompt).

## 🎯 Core Features
*   **Agent Discovery**: Locates target agents within the environment using the `AGENT_REGISTRY`.
*   **Deep Code Analysis**: Performs comprehensive AST-based analysis via the `CAST_ANALYSIS` tool to identify bottlenecks, security risks, and architectural flaws.
*   **Intelligent Refactoring**: Generates specific, actionable optimization strategies and code modification plans based on the analysis.
*   **Automated Patching**: Creates codebase snapshots and applies structured code changes using the `CAST_CODER` toolset.

## 🔄 Core Workflow: Each time only use one tool call!
### Phase 1: Discovery and Selection
1.  **Identify Target**: Receive an agent identifier
ad_image_createSkill

Create ad-ready product images (single or collage) by back-solving sub-image sizes from target output ratio, grounding scene design with media_comprehension, generating images via image_generator with strict request params and actor-count control, and pairing each deliverable with a short social tagline for 小红书/抖音.

ad_video_createSkill

Create ad-ready product video from product images, with or without character/subject images. The workflow leverages AI-powered image composition, scene understanding, and video generation. Video prompts should follow commercial shot language—visual hooks, product presence, hero shots, detail showcase, function expression, and dynamic visuals.

agent-browserSkill

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

app_evaluatorSkill

A professional skill for App Evaluation (evaluating app's performance with score) and App Improvement (giving professional suggestions for improving the app's performance).

embedded-video-pip-smooth-playbackSkill

>-

last_7_days_newsSkill

Search and summarize the latest 7 days of AI news and X discussions using public sources plus browser-based X collection. Use for recent AI news, trends, X discussions, industry briefs, and summaries organized into hot topics, viewpoints, and opportunity areas.

media_comprehensionSkill

An intelligent assistant specialized in handling media files (images/audio/video). **Only for media file analysis**, does not handle document types.\n\n✅ Media files that can be processed:\n- Images: .jpg, .jpeg, .png, .gif, .bmp, .webp, .svg\n- Audio: .mp3, .wav, .m4a, .flac, .aac, .ogg\n- Video: .mp4, .avi, .mov, .mkv, .webm, .flv\n\n❌ Files that cannot be processed (please do not trigger this skill):\n- Documents: .pdf, .doc, .docx, .txt, .md, .rtf\n- Spreadsheets: .xlsx, .xls, .csv, .tsv\n- Presentations: .pptx, .ppt, .key\n- Code: .py, .js, .ts, .java, .cpp, .go, .rs\n- Archives: .zip, .tar, .gz, .rar, .7z\n- Executables: .exe, .bin, .app, .dmg\n- Databases: .db, .sqlite, .sql\n- Configuration files: .json, .xml, .yaml, .yml, .toml, .ini\n- Web pages: .html, .htm, .css\n\n**Trigger conditions**: When the user explicitly requests to analyze image/audio/video content, or when the file extension belongs to the aforementioned media types.".

text2agentSkill

Creates new agents from user requirements by generating Python implementation and mcp_config.