skill-opt
Skill1 starsChanged 2 months agoUnlicenseView on GitHub
Interactively optimize any agent skill or rule file using automated test generation, trajectory reflection, and validation gating across LLM providers. Use when asked to optimize a skill, refine prompt instructions, benchmark agent rules, or run /skill-opt.
- Reads credentials
- Installs packages
In this repository71 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ad-copy-writerSkill
- ae-inspect-describeSkill
- algorithmic-artSkill
- animation-directorSkill
- brainstorming-and-ideatingSkill
- brainstorming-research-ideasSkill
- brainstormingSkill
- brief-to-tasksSkill
- canvas-designSkill
- cli-designSkill
- cli-output-hierarchySkill
- commit-messageSkill
- craft-uiSkill
- creative-directorSkill
- design-briefSkill
- design-flowSkill
- design-mock-auditSkill
- design-reviewSkill
- design-system-patternsSkill
- design-tokensSkill
- deslopifySkill
- diagnoseSkill
- doc-restructureSkill
- eval-criticSkill
- formatting-open-markdownsSkill
- frontend-designSkill
- frontend-slidesSkill
- gdocs-tab-writerSkill
- gemini-apiSkill
- gif-creationSkill
- github_repo_researchSkill
- grill-meSkill
- grill-with-docsSkill
- hallmarkSkill
- handoffSkill
- html-presentationSkill
- humanizerSkill
- improve-codebase-architectureSkill
- information-architectureSkill
- install-skill-from-githubSkill
- markdown-output-hierarchySkill
- marketing-psychologySkill
- merge-latestSkill
- modern-web-performanceSkill
- motion-designSkill
- pdf-readerSkill
- pm-brainstormingSkill
- pm-discovery-brainstormSkill
- product-marketingSkill
- prototypeSkill
- pull-requestSkill
- ralph_loopSkill
- react-best-practicesSkill
- skill-creatorSkill
- steve-voiceSkill
- systematic-debuggingSkill
- tastemaker-styleSkill
- tech-doc-codelabSkill
- threejsSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
26 rules. About 0 are common, 14 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
If no path was provided, ask: *"Which skill or rule file(s) would you like to optimize?
- Distinctive: line 32
If the user provides a directory path:
- Distinctive: line 42
Read each target file completely to ingest its existing frontmatter, behavioral steps, tool calls, and lifecycle constraints.
- Distinctive: line 55
If logs are detected across multiple platforms:
- Distinctive: line 62
When merging, deduplicate identical friction traces and synthesize a unified training set.
- Distinctive: line 64
If exactly one log directory is detected, automatically scan it for turns referencing the target skill.
- Very specific: line 66
If no log directory is detected, prompt via ask_question:
- Distinctive: line 72
If the user provides a custom path or snippet, ingest it.
- Very specific: line 79
If optimizing interdependent skills (e.g., producer and consumer skills), read the related skill files.
- Distinctive: line 90
If the user provides custom scenarios, append them to the dataset splits.
- Distinctive: line 97
Ask the user which model provider they prefer:
- Very specific: line 103
Check os.environ for the provider's key (e.g.
- Very specific: line 117
If the user selects export, append export <PROVIDER>_API_KEY="<key>" to their ~/.bashrc.
- Distinctive: line 120
If the user provides an existing session directory, enter Session Resumption Mode (see §3.5).
- Very specific: line 138
Multi-Trace Batch Aggregation (Lightweight
aggregate): When multiple task rollouts fail in a training batch, concatenates all failed … - Very specific: line 145
If the user explicitly asks to run upstream Microsoft SkillOpt tools (e.g., launching skillopt_webui or running skillopt_sleep), the agent …
- Very specific: line 146
If missing, it runs git clone https://github.com/microsoft/SkillOpt.git and installs dependencies (pip install -e .[webui]) before …
- Distinctive: line 148
When re-running or resuming an existing session:
- Very specific: line 167
Read the resulting best_skill.md and compute the unified diff against seed_skill.md.
- Distinctive: line 168
Create a comprehensive comparison report containing the full assertion matrix, before/after trace comparisons, and complete unified diff.
- Very specific: line 173
#### Remaining Gaps: Document any remaining failing assertions with their qualitative root cause, followed by the clickable report link. - Very specific: line 181
If the user selects "Run another optimization epoch with adjusted criteria", elicit what parameters or test criteria should be adjusted, …
- Distinctive: line 187
If the user approves the in-place update:
- Very specific: line 188
Automatic Pre-Deployment Snapshot: Create a timestamped backup copy (SKILL.md.bak_YYYYMMDD_HHMM) in the target directory before modifying …
- Very specific: line 189
Write the contents of best_skill.md directly to the original absolute file path.
- Distinctive: line 190
Verify that YAML frontmatter and formatting integrity are strictly preserved.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/skill-opt — Interactive Skill & Rule Optimizer
Purpose: Interactively optimize any agent skill (SKILL.md) or rule file (*.md) using automated test generation, trajectory reflection, and validation gating across LLM providers.
Architectural Principles
- Decoupled Optimization Roles:
- Target Model (e.g.
gemini-2.5-flash,claude-3-7-sonnet,gpt-4o-mini): The runtime agent executing task rollouts to expose instructional blind spots and failure modes. - Optimizer Model (e.g.
gemini-2.5-pro,claude-3-5-sonnet,o3-mini): The meta-critic analyzing execution trajectories, diagnosing root-cause ambiguities, and synthesizing surgical Markdown patches.
- Target Model (e.g.
- Strict Validation Gating & Syntax Guards: Candidate edits are only accepted if they pass automated frontmatter/Markdown syntax checks and achieve a strict score improvement on unseen validation tasks.
- Universal Transcript Harvesting (Zero-UUID): Automatically mines recent session logs for real developer corrections and failure turns across multiple agent platforms without requiring manual lookup.
- Algorithmic Safety Modules: Employs deterministic edit distance bounding (clip <=35% line change), multi-trace batch aggregation, and heuristic step sizing to prevent catastrophic forgetting.
- Multi-Skill Cross-Alignment: Ensures interdependent skills (e.g., track planning and implementation) maintain synchronized handoff schemas by actively verifying consumer/producer files.
Protocol
Step 1: Target Ingestion & Verification
- Identify the target skill, rule path, directory, or multi-skill bundle requested by the user.
- If no path was provided, ask: "Which skill or rule file(s) would you like to optimize? Please provide the file path(s), directory, or skill name."
- Directory & Descendant Discovery:
- If the user provides a directory path:
- Scan the directory recursively for all descendant
SKILL.mdfiles and*.mdrule files. - Present the list of all discovered descendant files in chat.
- Prompt the user using
ask_question: - Question: "Directory contains N skills/rules. How should we proceed?"
- Options:
"(Recommended) Run batch optimization across all N discovered skills/rules""Let me select specific files from the list""Cancel"
- Scan the directory recursively for all descendant
- If the user provides a directory path:
- Absolute Path Resolution: Resolve all confirmed target path(s) to strict absolute paths.
- Read each target file completely to ingest its existing frontmatter, behavioral steps, tool calls, and lifecycle constraints.
Step 2: Automated Eval Synthesis & Targeted Transcript Mining
- Universal Multi-Platform Transcript Discovery & Aggregation:
- Automatically probe common agent transcript and session log locations across tools:
- Antigravity:
<appDataDir>/brain/or~/.gemini/antigravity/brain/ - Claude Code:
~/.claude/projects/,~/.claude/transcripts/,~/.claude/sessions/ - Cursor / Windsurf / VS Code Copilot:
~/.cursor/,~/.config/Code/User/globalStorage/,.vscode/ - Local Workspace / CLI:
./.sessions/,./logs/,~/.skillopt/logs/
- Antigravity:
- Handling Multiple Detected Platforms:
- If logs are detected across multiple platforms:
- Present the detected platforms and prompt via
ask_question:- Question: "Detected session logs across multiple platforms. How should we harvest friction?"
- Options:
"(Recommended) Harvest and merge friction turns across all detected platforms""Let me select specific platforms from the list""Skip log harvesting and synthesize from skill contract only"
- When merging, deduplicate identical friction traces and synthesize a unified training set.
- Single Platform or Custom Path:
- If exactly one log directory is detected, automatically scan it for turns referencing the target skill.
- Graceful Fallback When No Log Directory Exists:
- If no log directory is detected, prompt via
ask_question:- Question: "No default session logs detected. How would you like to build test scenarios?"
- Options:
"(Recommended) Auto-synthesize edge cases from the skill contract (no logs needed)""Specify a custom transcript directory or log file""Paste a recent failure or correction snippet manually"
- If the user provides a custom path or snippet, ingest it; otherwise proceed with pure contract-driven synthesis.
- If no log directory is detected, prompt via
- Automatically probe common agent transcript and session log locations across tools:
- Deconstruct the Behavioral Contract: Analyze the target file to identify:
- Mandatory prerequisite checks and inputs.
- Interactive flow requirements (e.g.,
ask_questionformatting, report-first ask-second). - Tool calling protocols and sequential stop barriers.
- Output artifact schemas and file modification constraints.
- Multi-Skill Schema Check (Interdependent Bundles):
- If optimizing interdependent skills (e.g., producer and consumer skills), read the related skill files.
- Cross-reference output schemas against consumer expectations to prevent handoff regressions.
- Synthesize Train & Val Datasets: Auto-generate 2–3 training scenarios (combining mined transcript turns with synthetic edge cases) and 1–2 held-out validation scenarios in distinct technical domains:
- Each scenario must define an
id,prompt, and 4–6 discreteeval_criteriaassertions.
- Each scenario must define an
- Present Matrix in Chat: Output the full generated test matrix in your response message body formatted as a clean Markdown table detailing the scenario prompt, target behavior, source (Mined vs. Synthetic), and assertion criteria.
- Interactive Elicitation: Invoke
ask_questionto confirm the test matrix:- Question: "Would you like to add any custom test scenarios or target specific failure cases?"
- Options:
"(Recommended) Proceed with the generated test matrix""I want to add custom test scenarios""Refine the existing assertions"
- If the user provides custom scenarios, append them to the dataset splits.
Step 3: Workspace Environment, Provider & Runner Setup
- Provider Selection & Environment Key Check:
- Ask the user which model provider they prefer:
Google Gemini(Default: Targetgemini-2.5-flash, Optimizergemini-2.5-pro, Key:GEMINI_API_KEY)Anthropic(Targetclaude-3-7-sonnet, Optimizerclaude-3-5-sonnet, Key:ANTHROPIC_API_KEY)OpenAI(Targetgpt-4o-mini, Optimizergpt-4ooro3-mini, Key:OPENAI_API_KEY)OpenRouter / Custom API(Custom target/optimizer model names, Key:OPENROUTER_API_KEY)
- Environment Variable Detection & Persistence Flow:
- Check
os.environfor the provider's key (e.g.GEMINI_API_KEY,ANTHROPIC_API_KEY,OPENAI_API_KEY,OPENROUTER_API_KEY). - If an environment variable exists:
- Prompt via
ask_question:- Question: "Found active {PROVIDER}_API_KEY in environment. Use this key?"
- Options:
"(Recommended) Yes, use the existing environment variable""No, I want to provide a different key for this session"
- If NO environment variable exists (or user wants to supply a different key):
- Solicit the API key from the user.
- Prompt via
ask_question:- Question: "Persist this API key to your environment for future sessions?"
- Options:
"(Recommended) Yes, export to ~/.bashrc for future sessions""No, keep it local to this session only (.env in scratch)"
- If the user selects export, append
export <PROVIDER>_API_KEY="<key>"to their~/.bashrc.
- Check
- Store the active key in a local
.envfile within the scratch directory or referenceos.environ["<PROVIDER>_API_KEY"]. Never embed keys in version-controlled files.
- Ask the user which model provider they prefer:
- Suggest Workspace Directory or Detect Existing Session:
- If the user provides an existing session directory, enter Session Resumption Mode (see §3.5).
- Otherwise, propose a new dedicated scratch path:
.scratch/skillopt_<slug>_<timestamp>/
- Confirm Workspace Path: Invoke
ask_question:- Question: "Where should the optimization session run?"
- Options:
"(Recommended) Use suggested scratch path: <suggested_path>""Resume/re-run an existing session directory""Specify a custom workspace directory"
- Generate Harness Files & Algorithmic Guard Modules:
- Self-Contained Runner (Default — Zero External Clones):
- SkillOpt generates a self-contained Python script (
run_optimizer.py) directly in the scratch directory using Python's standard library (urllib.request,json,re,difflib). skills/seed_skill.md: A pristine copy of the original target file.tasks/train.jsonl: Formatted training scenarios and rubrics.tasks/val.jsonl: Formatted held-out validation scenarios.run_optimizer.pyimplements:- Pre-Flight Key Validation: Performs an immediate probe against the selected provider's endpoint upon startup. If the key is missing, empty, or returns an authentication error (400/401/403), halts immediately with:
sys.exit("ERROR: Invalid or missing API key. Set <PROVIDER>_API_KEY before running."). - Frontmatter & Syntax Validation Guard: Pre-validates candidate mutations before running validation rollouts. Ensures valid YAML frontmatter (
name:,description:present) and non-truncated Markdown headers. Discards malformed mutations automatically. - Deterministic Edit Distance Bounding (Lightweight
clip): Computes line diff ratios usingdifflib. Automatically rejects candidate mutations that delete or modify more than 35% of existing lines in a single epoch or drop required markdown headers, preventing destructive hallucinations without spending extra API tokens. - Multi-Trace Batch Aggregation (Lightweight
aggregate): When multiple task rollouts fail in a training batch, concatenates all failed trajectory traces and assertion violations into a single unified reflection prompt, synthesizing one cohesive patch that addresses all failure modes simultaneously. - Heuristic Step Sizing (Lightweight
lr_autonomous): Dynamically injects granularity directives into the reflection prompt based on current validation performance:- Baseline score < 0.70: Directs the model to perform structural additions, missing procedural steps, and prerequisite guards.
- Baseline score ≥ 0.70: Directs the model to perform minimal surgical edits (targeted phrasing, single-line constraint additions) while strictly preserving all working sections.
- Exponential backoff retry handling on API endpoints.
- Rollout -> Multi-Trace Aggregated Reflection -> Syntax/Clip Guard -> Validation Gating loop across 2 epochs.
- SkillOpt generates a self-contained Python script (
- Upstream SkillOpt Repo Clone (Optional / WebUI / Sleep):
- If the user explicitly asks to run upstream Microsoft SkillOpt tools (e.g., launching
skillopt_webuior runningskillopt_sleep), the agent checks ifhttps://github.com/microsoft/SkillOpt.gitexists locally in~/.config/skillopt_repoor the scratch workspace. - If missing, it runs
git clone https://github.com/microsoft/SkillOpt.gitand installs dependencies (pip install -e .[webui]) before launching.
- If the user explicitly asks to run upstream Microsoft SkillOpt tools (e.g., launching
- Self-Contained Runner (Default — Zero External Clones):
- Session Resumption & Script Updates:
- When re-running or resuming an existing session:
- Cumulative Checkpointing: Set
seed_skill.mdto the previousbest_skill.mdso new epochs build upon prior improvements rather than resetting to the original draft. - Dataset & Parameter Edits: Allow appending new tasks to
train.jsonlor editingrun_optimizer.py(e.g., adjustingnum_epochs,max_edit_tokens, or prompt constraints) without regenerating the entire workspace.
- Cumulative Checkpointing: Set
- When re-running or resuming an existing session:
Step 4: Execution & Continuous Progress Updates
- Launch
run_optimizer.pyin the background (or run directly with streaming output). - Mandatory Frequent Progress Streaming (Behavior-Grouped & Exception-Driven): The agent must NEVER stay silent during execution. Whenever awakened by a notification timeout, task completion, or log event, immediately output a concise status summary formatted as follows:
- Progress Gauge & Pass Rate: Render a visual progress bar (e.g.,
Progress: [████████████████░░░░] 26 / 29 scenarios completed (90%)) and current aggregate pass rate. - Active Scenario: State the currently executing scenario in plain English (e.g.,
"Evaluating multi-turn interview on a database schema migration (Turn 4/14)"), avoiding rawSCREAMING_SNAKE_CASEdumps. - Exceptions & Failures Only: Suppress routine passing test rows. List only failing or degraded criteria alongside their qualitative failure reason (e.g.,
"- Auth Protocol Inquiry (TRAIN_23): 3/4 passed — Failed: Agent omitted token expiration edge cases").
- Progress Gauge & Pass Rate: Render a visual progress bar (e.g.,
- Maintain execution until all epochs conclude and the final
best_skill.mdis saved.
Step 5: Report Artifact Generation & Deployment Gate
- Read the resulting
best_skill.mdand compute the unified diff againstseed_skill.md. - Create a comprehensive comparison report containing the full assertion matrix, before/after trace comparisons, and complete unified diff.
- Render Final Summary in Chat: Output a structured chat summary containing:
- Top-Line Baseline Delta: Lead with the overall pass rate and prominent percentage improvement over baseline (e.g.,
Overall Result: 50 / 54 scenarios passed (92.6%) · **+25.9% over baseline** (36 / 54)) alongside instruction diff statistics (+24 lines, -6 lines (3.8% surgical edit)). - Behavioral Health Scorecard Table: Present a clean Markdown table with columns
Behavioral Discipline | Baseline | Optimized | Target Range | Statustranslating raw evaluation metrics into plain-English capabilities (e.g., Single-Question Pacing, Anti-Assumption Guard, Consult-First Discipline, Devil's Advocate Probing, ADR Candidate Detection, Probing Depth with calibrated target1.0–2.0). #### What Changed in Practice: Highlight 3–5 concrete, user-visible behavioral improvements explaining what the agent now does or stops doing in plain English.#### Remaining Gaps: Document any remaining failing assertions with their qualitative root cause, followed by the clickable report link.
- Top-Line Baseline Delta: Lead with the overall pass rate and prominent percentage improvement over baseline (e.g.,
- Prompt the user for deployment confirmation using
ask_question:- Question: "Would you like to deploy the optimized skill to its original path?"
- Options:
"(Recommended) Approve and update original file in-place""Keep optimized file in scratch directory only""Run another optimization epoch with adjusted criteria"
- Handling Re-Runs from the Deployment Gate:
- If the user selects
"Run another optimization epoch with adjusted criteria", elicit what parameters or test criteria should be adjusted, updatetasks/train.jsonlorrun_optimizer.pyin-place, setseed_skill.md=best_skill.md, and re-launch Step 4.
- If the user selects
Step 6: In-Place Source Update & Snapshot Backup
- If the user approves the in-place update:
- Automatic Pre-Deployment Snapshot: Create a timestamped backup copy (
SKILL.md.bak_YYYYMMDD_HHMM) in the target directory before modifying the original file. - Write the contents of
best_skill.mddirectly to the original absolute file path. - Verify that YAML frontmatter and formatting integrity are strictly preserved.
- Automatic Pre-Deployment Snapshot: Create a timestamped backup copy (
- Announce completion with a direct link to the updated source file.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

