kramme-cc-workflow/skills/kramme:code:optimize/SKILL.md
(experimental) Run metric-driven optimization experiments. Use when search relevance, clustering quality, prompt quality, build latency, ranking behavior, bundle size, or another measurable outcome needs repeatable variants instead of sequential guess-and-check. Requires a measurement command or judge rubric, persists baselines and experiment logs under `.context/code-optimize/`, and can use serial or worktree-isolated experiments. Not for ordinary one-shot performance fixes, implementation without a harness, or speculative optimization with no metric.
npx skillsauth add abildtoft/kramme-cc-workflow kramme:code:optimizeInstall 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.
Run metric-driven optimization loops for problems where several plausible variants should be tested against the same repeatable harness. This skill defines a spec, records a baseline, runs experiments, writes every result to disk, keeps winners, rejects losses, and preserves enough state to resume after context compaction.
Parse $ARGUMENTS.
.yaml or .yml means read and validate that spec.--auto may choose conservative defaults and continue through non-destructive steps, but it must not push, open PRs, delete experiment logs, approve first-run measurement commands, approve new dependencies, ignore dirty in-scope files, or run with uncapped judge cost.If no input is present, ask what outcome should be optimized and whether the user already has a measurement command.
Read the schema from references/optimize-spec-schema.yaml before validating or drafting a spec.
references/example-hard-spec.yaml when the target is an objective scalar metric.references/example-judge-spec.yaml when real quality requires semantic judgment.references/usage-guide.md when the user is deciding between hard metrics and judge mode.Boundary with kramme:code:performance: repeatable harness-driven experiments belong here; one-shot review-and-fix performance passes without a variant harness belong to kramme:code:performance.
Stop and ask for the missing requirement before experiments run when any condition is true:
measurement.command is empty.metric.primary.type is judge and metric.judge.rubric or metric.judge.scoring.primary is missing.scope.mutable or scope.immutable is empty.max_total_cost_usd: null and the user has not explicitly approved uncapped spend.Use .context/code-optimize/<spec-name>/ for local scratch state. These files must be gitignored (verified during Set Up Spec) and are the source of truth for the optimization run:
| File | Purpose |
| --- | --- |
| spec.yaml | Approved optimization spec, written at setup |
| experiment-log.yaml | Append-first history of baseline, hypotheses, experiment results, outcomes, and current best |
| strategy-digest.md | Compact learning summary used to generate later hypotheses |
| experiments/<iteration>/result.yaml | Crash-recovery marker for a measured experiment |
Use references/experiment-log-schema.yaml when writing or validating experiment-log.yaml.
hard when better is a scalar number: latency, bundle size, build time, memory, test pass rate, throughput.judge when a proxy metric can be gamed or human usefulness matters: search relevance, cluster coherence, summary quality, prompt quality, recommendation relevance.name must be lowercase kebab-case and safe for branch/worktree names.metric.primary.direction must be maximize or minimize.>=, <=, >, <, ==, !=.execution.mode: serial, execution.max_concurrent: 1, stopping.max_iterations: 4, stopping.max_hours: 1..context/code-optimize/<spec-name>/spec.yaml exists and matches the incoming spec, continue with that spec.spec.yaml exists but experiment-log.yaml does not, treat the directory as partial setup; verify the spec and continue from measurement validation without deleting files.experiment-log.yaml exists, use the Resume workflow before any new writes.git check-ignore .context/code-optimize/ (or equivalent). If it is not ignored, warn the user and offer to add a .context/code-optimize/ entry to .gitignore — apply it only with explicit user approval.spec.yaml to .context/code-optimize/<spec-name>/spec.yaml, then read it back and confirm the expected name, metric, measurement command, and scope are present before continuing.Resolve SKILL_DIR to this skill's directory.
Before the first measurement run, present the measurement execution boundary:
measurement.command,measurement.working_directory,measurement.timeout_seconds,Require explicit user approval before running it. --auto must not bypass this approval; it may only continue after approval has been recorded in the conversation or existing log.
Run the measurement helper from the user's repo root:
"$SKILL_DIR/scripts/measure.sh" "<measurement.command>" "<timeout_seconds>" "<measurement.working_directory>"
Parse stdout as JSON. Confirm it includes:
metric.primary.type: hard.If measurement.stability.mode: repeat, run the helper repeat_count times, aggregate with the configured method, and record variance. Treat improvements smaller than noise_threshold as noise.
Run the parallelism probe before parallel experiments:
"$SKILL_DIR/scripts/parallel-probe.sh" "$PWD" "<measurement.command>" "<measurement.working_directory>" <parallel.shared_files...>
Use its output as advisory. Shared databases, hardcoded ports, lock files, and exclusive accelerators usually mean serial mode or per-experiment parameterization.
If parallel.shared_files includes sensitive files such as .env, credentials, databases, or private fixtures, present the list and require explicit approval before creating worktrees. Shared file paths must be relative repo paths; parent traversal and absolute paths are unsupported.
references/judge-prompt-template.md after all degenerate gates pass.experiment-log.yaml with:
spec,run_id,started_at,baseline,experiments: [],best seeded from the baseline,hypothesis_backlog: [].--auto is present and all costs are capped, all paths are clean, and the first run is serial.hypothesis_backlog to experiment-log.yaml, then read the file back and verify the backlog before dispatching work.execution.max_concurrent,"$SKILL_DIR/scripts/experiment-worktree.sh" create <spec-name> <iteration> <base-branch>.parallel.shared_files to the worktree helper. The helper does not copy .env* files implicitly.references/experiment-prompt-template.md with the hypothesis, current best, baseline, allowed mutable scope, immutable scope, constraints, approved dependencies, and last 10 experiment summaries.experiments/<iteration>/result.yaml immediately after measurement.experiment-log.yaml with outcome measured, then read the log back and verify the entry before processing the next experiment.degenerate.error; timeouts produce timeout.measurement.stability.noise_threshold; for judge metrics, require metric.judge.minimum_improvement.best in experiment-log.yaml.max_runner_up_merges_per_batch:
runner_up_reverted.best section to disk, then verify the write.strategy-digest.md after every batch:
When .context/code-optimize/<spec-name>/experiment-log.yaml exists:
experiments/*/result.yaml for measured results not reflected in the log.spec value matches <spec-name>. If a new incoming spec was supplied and differs from the existing spec.yaml, stop and ask whether to resume the existing run, create a new spec name, or archive the old directory.best and the current backlog.Before declaring the optimization complete:
experiment-log.yaml state and verify it.kramme:verify:run and review with kramme:pr:code-review.tools
Requires Linear MCP. Implements one Linear issue end to end, selects applicable code-review, convention, and PR-refactor gates, runs them to bounded convergence, verifies, and optionally opens the PR and iterates on CI and review feedback until green. Use when the user wants a single Linear issue taken from implementation through a clean Pull Request. Not for implementation-only work, SIW-tracked issues, stacked PRs, existing PR updates, or post-merge rollout.
development
Reviews PR and local changes for convention drift and overcaution against documented rules and mined peer-file practice. Use for new patterns, dependencies, abstractions, or defensive complexity that departs from established practice; every finding cites evidence. Supports --inline. Not for general code quality (use kramme:pr:code-review) or spec review (use kramme:siw:spec-audit --team).
testing
Charts huge or foggy initiatives into a local `.context` decision map and resolves one typed frontier ticket per session until the work is ready for SIW or another execution workflow. Use when the route to a destination cannot fit in one agent session or parallel workspaces need coordinated planning state. Not for clear specs, ordinary issue decomposition, implementation, or Linear-native tracking.
development
Investigates a question against primary sources and saves one cited Markdown artifact. Use for reading legwork: official docs/API facts, source-code or spec checks, standards, and first-party service behavior before planning or implementation. Not for making product or architecture decisions, implementing code, broad web search, secondary blog summaries, or uncited answers.