codex/skills/opt/SKILL.md
Orchestrate Codex skill optimization during active sessions through $cas goal control, $shadow single-session evidence, $tune diagnosis/refinement briefs, and the skill-optimizer custom subagent. Trigger for $opt, skill optimization loops, session-driven skill tuning, meta-skill audits, or explicit validated skill edits. Do not use for general code optimization, product optimization, or performance tuning.
npx skillsauth add tkersey/dotfiles optInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use $opt to optimize Codex skills during an active session.
$opt is an orchestration wrapper, not the specialist itself:
$cas owns durable parent goal control and app-server/thread lifecycle evidence.$shadow owns following exactly one watched session through a target-skill lens.$tune owns intended-vs-observed skill-use diagnosis and refinement briefs.skill-optimizer owns bounded skill-package audit, proposal, patch, and validation work after the parent has supplied scope.Core question:
Given the target skill, the selected evidence, and the current session goal,
what is the smallest evidence-backed change or validation step that improves the skill without broadening its trigger surface?
Use $opt when the user asks to:
$cas, $shadow, and $tune for a skill-improvement loop.Example prompts:
$opt on $cas; focus on goal-management ergonomics."$opt with $shadow on session <id> and tune the target skill from the evidence."$cas goal to optimize $tune, then spawn skill-optimizer for one bounded audit pass."$opt to patch codex/skills/shadow/SKILL.md; keep edits minimal and validate frontmatter."$opt regression mode for the false activation we just saw."Do not use $opt to:
$tune for evidence diagnosis.$shadow for watched-session monitoring.$cas for goal lifecycle control.complete_candidate as final goal completion without parent validation.Identify these before delegating work:
audit, propose, tune, shadow-diagnose, patch, validate, regression, or goal-loop.$shadow report, $tune brief, validation output, worktree state, or mixed.no_edit, propose_patch, or edit_allowed.$cas goal should be created, inspected, updated, or left alone.Default only when unspecified:
propose with no_edit.tune or propose with current-turn evidence first.shadow-diagnose through $shadow, then propose.patch with edit_allowed after the apply gate passes.Use when the user asks whether a skill is well-shaped or what is wrong.
Behavior:
skill-optimizer in audit mode.Use when the user asks what should change, asks for deep analysis, or says "optimize" without explicit file-change language.
Behavior:
skill-optimizer in propose mode.Use when evidence comes from intended-vs-observed behavior, false activation, missed activation, or workflow drift.
Behavior:
$tune to declare the evidence source and produce or update a refinement brief when useful.$tune brief to skill-optimizer.Use when the evidence source is one running or completed session.
Behavior:
$shadow on exactly one watched session and one target skill lens.$shadow in observe or propose unless the user explicitly requested apply behavior.$shadow output as evidence; do not inspect raw watched-session JSONL unless separately authorized.skill-optimizer with mode=shadow-diagnose to classify the skill implication.$tune if the watched-session evidence implies a refinement brief.Use only when the user explicitly asks to edit files now.
Apply gate:
Behavior:
skill-optimizer in patch mode with apply_policy=edit_allowed.Use when the user asks whether a skill edit is safe, complete, or regression-resistant.
Behavior:
codex/skills/opt/scripts/opt-sanity when available.skill-optimizer for residual risk and missing validation.Use when the user identifies a concrete prior failure.
Behavior:
Use when the task is long-running or has a clear completion contract.
Behavior:
$cas to create or inspect the parent goal.skill-optimizer.$cas to continue, pause, block, clear, or complete only after parent-side evidence review.When spawning the subagent, use this shape:
Spawn the custom agent `skill-optimizer` and wait for its result.
Delegation:
- target_skill: <path or skill name>
- mode: <audit|propose|tune|shadow-diagnose|patch|validate|regression>
- current_goal: <CAS parent goal text/id or "none">
- evidence: <current-turn notes | $shadow report | $tune brief | validation output | worktree facts>
- allowed_files: <explicit list/glob>
- forbidden_files: <explicit list/glob>
- validation_commands: <commands or "discover minimally">
- apply_policy: <no_edit|propose_patch|edit_allowed>
- output_required: Target, Mode, Evidence source, Files inspected, Changes made, Evidence/validation, Residual risks, Suggested parent CAS status, Suggested next parent action.
Rules:
- Do not manage the parent goal lifecycle.
- Do not broaden scope beyond the target skill and allowed files.
- Prefer surgical changes.
- If editing, run available validation or explain why validation was not possible.
Before treating the optimization as done, verify:
$cas, $shadow, $tune, $refine, and $ms boundaries are not blurred.references/ when they would bloat SKILL.md.$cas goal state is updated only after evidence supports the update.Return:
$opt result:
- Target:
- Mode:
- Parent goal status:
- Evidence source:
- What changed or what should change:
- Validation:
- Remaining risk:
- Next recommended action:
testing
Use before local patching when bugs, regressions, malformed state, crashes, parser failures, migrations, cache drift, protocol problems, compatibility requests, tolerant readers, fallbacks, coercions, retries, catch-and-continue logic, or local workarounds may broaden accepted invalid state.
testing
Use for bug reports, PR/issue prose, reviewer comments, user diagnoses, generated summaries, memories, retrieved context, public tracker context, claimed root causes, proposed fixes, fake-minimal repro risk, or any investigation where natural-language context could anchor the implementation scope.
development
Use when non-trivial work needs Challenge Escalation, latent-intelligence activation, frame-market selection, doctrine operators, dominant-move selection, ablation/surface-tax judgment, reification, review comment law, negative capability, route receipts, or proof-bearing refusal to mutate.
development
Apply Algebra-Driven Design. Use for ADD, denotational design, combinator models, law-driven architecture, domain algebra, property tests, codebase modeling, event sourcing, workflow design, or agentic skill design. If the canonical bundle is unavailable, use this wrapper as the minimal ADD kernel and report the missing bundle path.