structured-improvement
Skill0 starsChanged 6 months agoMITView on GitHub
Rigorous process for optimizing, fixing, or improving existing systems. Measure first, change least, prove everything. Focuses on profiling, targeted fixes, regression safety, and before/after evidence.
In this repository9 other files it gives its agents.
- agent-busSkill
- autonomous-iterationSkill
- documentation-captureSkill
- hue-signalsSkill
- llm-councilSkill
- macos-attention-soundSkill
- messageSkill
- outbound-injectionsSkill
- transcribe-scribeSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 18 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 37
Use TaskCreate for every discrete piece of work — never track work only in your head or in a doc
- Very specific: line 41
After completing a task, check TaskList for the next one — don't rely on memory
- Very specific: line 48
Check TaskList to see where you are
- Distinctive: line 54
Keep working until all tasks are completed: Never pause between phases to ask "want me to continue?" or "should I proceed?" — the task list …
- Distinctive: line 91
Before you can profile, you need to be able to observe.
- Distinctive: line 106
Run the instrumented system and produce a factual breakdown of where time/resources actually go.
- Distinctive: line 118
Use Codex to read the codebase and identify whether instrumentation points are in the right places.
- Distinctive: line 126
Before changing any code, lock down the current behavior with tests.
- Distinctive: line 211
ONE bottleneck per iteration: Never bundle two fixes. You won't be able to attribute the improvement.
- Distinctive: line 212
ALWAYS measure after each change: Not after "a few changes" — after each one.
- Distinctive: line 215
Revert before analyzing regressions: If a change breaks something, revert it immediately, THEN figure out why.
- Distinctive: line 217
Multi-model review per change: Use Codex to review the diff against the codebase ("what could this break?") and GPT-5.2 Pro to review the …
- Distinctive: line 219
Artifact per iteration: Before/after measurement + keep/revert decision + rationale
- Distinctive: line 225
After all changes are implemented, comprehensive verification against the original success criteria.
- Distinctive: line 244
Document what changed, why, and what the measured impact was.
- Distinctive: line 292
No baseline, no code: Never implement an improvement without profiling first.
- Distinctive: line 293
One variable at a time: Every change gets its own before/after measurement.
- Distinctive: line 294
Trust the profiler, not intuition: If your intuition says "inserts are slow" but the profiler says "deletions are 63% of time," the …
- Distinctive: line 295
Treat variance as signal: Run 3+ measurements per scenario.
- Distinctive: line 296
Regression is the primary risk: Every change must be tested against the full existing test suite plus the Phase 3 safety net.
- Distinctive: line 297
Revert before analyzing: If a change introduces a regression, revert immediately, THEN figure out why.
- Very specific: line 301
Document every decision: Keep/revert/defer decisions must include evidence (measurement data).
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Structured Improvement
Improve existing systems through measurement-driven loops: profile the current behavior, isolate bottlenecks, apply minimal targeted changes, and prove each improvement with before/after evidence.
Use when: Performance optimization, bug pattern fixes, refactoring existing code, improving reliability or resource usage. Any time you're making an existing system better rather than building something new.
Don't use when: Building new features, new libraries, or new systems from scratch. Use structured-development for greenfield work.
Core Principle
Measure first. Change least. Prove everything.
In greenfield work, planning is cheap and code is expensive. In improvement work, the existing system IS the plan — reading and measuring it is cheap, but changing it wrong causes regressions. The most expensive mistake is a wholesale redesign that misses the actual bottleneck.
Activation Protocol
When this skill is invoked, immediately create a task list covering ALL phases before starting any work. This is non-optional — the task list is how you track progress, survive context compaction, and ensure nothing gets silently dropped.
On invocation:
- Understand the improvement goal — read the user's request, ask clarifying questions if needed
- Create phase-level tasks — one task per phase (0-8). Each task description should list the expected sub-steps. Mark any already-completed phases as
completed. - For each pending phase, the first sub-task is always: "Create sub-tasks for Phase N" — this is a tracked
TaskCreateentry, not implicit. When this task runs, it reads the phase description + outcomes from previous phases, then creates the concrete sub-tasks. Every phase's sub-tasks must include a documentation task — update the improvement brief, profiling report, or relevant docs with that phase's outcomes. If it's not a tracked task, it won't happen. - Create sub-tasks for the first actionable phase immediately — since you're about to start it, break it into discrete
TaskCreateentries now. For future phases, only the "Create sub-tasks" placeholder task exists until that phase becomes active.
Task creation rules:
- Use
TaskCreatefor every discrete piece of work — never track work only in your head or in a doc - Phase-level tasks are parents; sub-tasks within each phase are the actual work items
- Each sub-task should have a clear completion criterion (not "do X and also Y" — split those)
- Mark tasks
in_progressbefore starting,completedwhen done - After completing a task, check
TaskListfor the next one — don't rely on memory - Multi-model reviews, measurement runs, regression tests, doc updates, and checkpoints are their own tasks (Standing Rule 8)
- Set dependencies based on data flow, not phase numbers. Phase 0 and Phase 1 can overlap. Phase 2 needs Phase 1's data. Phase 3 can run in parallel with Phase 4. Don't assume strictly sequential.
Surviving context compaction:
The task list persists across compaction. When context is compacted:
- Check
TaskListto see where you are - Re-read the improvement brief and profiling report (the task description should reference them)
- Pick up from the next incomplete task
Execution
Keep working until all tasks are completed. Never pause between phases to ask "want me to continue?" or "should I proceed?" — the task list is the plan, work through it autonomously.
When to alert the user:
- Profiling reveals a fundamentally different bottleneck than expected
- A spike fails to move the metric (hypothesis invalidated)
- Regression detected that can't be easily resolved
- Scope is expanding beyond targeted improvement into rewrite territory
When NOT to alert the user:
- Routine measurement results
- Phase transitions
- Technical decisions within the targeted change (batch size, algorithm choice)
- Any question you can answer yourself with measurement or research
Phases
Phase 0: Improvement Brief
Frame the improvement goal. What's wrong, how bad is it, and what does "better" look like — in numbers, per scenario.
- Symptom — what the user observes (slow sync, high memory, failures)
- Impact — quantified if possible (takes 128s, uses 2GB RAM, fails 3x/week)
- Hypothesis — initial guess about what's wrong. Explicitly mark as unverified. Write "we suspect X" not "the problem is X"
- Scope boundary — what we're improving vs. what we're NOT touching. Improvement work has gravitational pull toward "while we're in here, let's also..."
- Scenario matrix — enumerate distinct usage scenarios (incremental daily sync vs first-time catch-up vs recovery after failure). Each may need different acceptable thresholds
- Success criteria — what "better" means in numbers, per scenario. Not "faster" — "under 30s for incremental sync, under 120s for catch-up"
Difference from structured-dev Phase 0: The existing system IS the context. There's no "what are we building" — there's "what's wrong and how will we know it's fixed."
Artifact: Improvement brief with scenario matrix and numeric success criteria
Phase 1: Observability
Before you can profile, you need to be able to observe. Audit the existing system's instrumentation and add what's missing.
- Audit existing observability — what logging, metrics, or profiling already exists?
- Identify measurement points — where in the pipeline do you need timing data? At what granularity?
- Add instrumentation — timers, counters, trace points. Non-invasive where possible
- Build reproducible benchmark harness — same inputs, same environment, documented run procedure. This harness will be used throughout the entire process
Why this is a separate phase: If you can't observe it, bottleneck attribution is guesswork. In one data-sync improvement, the actual timing breakdown (deletions dominated the wall-clock time) only became clear AFTER adding instrumentation post-implementation. If this phase had come first, that would have been known before writing any code.
Artifact: Instrumentation map + reproducible benchmark harness
Phase 2: Profiling & Diagnosis
Run the instrumented system and produce a factual breakdown of where time/resources actually go. This is the single most important artifact in the entire process.
- Run profiled baselines — for each scenario in the Phase 0 matrix, capture timing/resource data
- Produce timing waterfall — wall-clock time for each step, with percentages and absolute values
- Rank bottlenecks — ordered list of where time/resources are actually spent
- Characterize variance — run 3+ measurements per scenario, report mean and stddev. If variance is 20%, a 15% improvement is noise
- Validate hypothesis — does the Phase 0 hypothesis hold up? If not, what's the actual bottleneck?
- Per-scenario breakdown — different scenarios may have completely different bottleneck profiles. Don't average them
Multi-model review: Send profiling data to multiple models in parallel:
"Here's a timing breakdown of an existing system. Are these measurements sound? What could be measured wrong? What's missing? What would you investigate further?"
Use Codex to read the codebase and identify whether instrumentation points are in the right places. GPT-5.2 Pro for statistical reasoning about measurement validity.
Artifact: Profiling report with ranked bottleneck list, per-scenario breakdown, and variance data
Phase 3: Safety Net
Before changing any code, lock down the current behavior with tests. If you can't test it, you can't safely change it.
- Audit test coverage — does the target area have tests? What behaviors are covered?
- Write pinning tests — high-level integration/characterization tests that pass on the current system. These capture existing behavior as a baseline, even if that behavior has bugs. They're your "golden master"
- Verify safety net — all pinning tests must be green before any changes begin
- Identify regression boundaries — document what must NOT change. Existing API contracts, data formats, observable behavior that other systems depend on
Why this phase matters: In greenfield work, there's nothing to regress. In improvement work, regression is the primary risk. Every change you make could break something that already works. The safety net catches this.
Artifact: Pinning test suite + regression boundary document
Phase 4: Targeted Spec
Based on profiling data, write specific improvement targets for the actual bottlenecks. Not a full PRD — a targeted improvement spec.
For each bottleneck above the significance threshold:
- Current measured value — from Phase 2 profiling
- Target value — allocated from Phase 0 success criteria
- Proposed approach — hypothesis for the fix (e.g., "replace individual DELETEs with batch DELETE WHERE IN")
- Predicted impact — expected improvement, with reasoning
- Regression risk — what could this change break?
- Rollback plan — how to revert if it doesn't work
- Measurement plan — how you'll measure the before/after for this specific change
Also specify:
- Change ordering — which bottleneck to attack first (biggest impact, lowest risk)
- Change minimality — explicitly state the minimum viable change. Resist redesign impulses
- Blast radius — how many files/components does each change touch? If more than ~3 files, question whether you're doing targeted improvement or a stealth rewrite
Multi-model review: Send the targeted spec plus the profiling report to multiple models in parallel:
"Here's profiling data showing where time is spent, and here's my plan for which bottlenecks to target. Am I targeting the right things? Are targets realistic? What interaction effects could occur between these changes?"
The review checks for: wrong bottleneck targeting, interaction effects, regression risk, insufficient targets (optimizing the 5% while ignoring the 63%).
Artifact: Targeted improvement spec with per-bottleneck approach, predicted impact, and regression risk
Phase 5: Benchmark Experiment
Validate the optimization hypothesis before investing in a clean implementation. Use the benchmark harness to prove the approach works — in isolation, not by hacking the main codebase.
- Design the experiment — what's the minimum you need to test? An isolated script, a throwaway branch, a standalone benchmark that simulates the proposed change
- Run the experiment — use the same benchmark harness and data from Phase 1. Compare to Phase 2 baseline
- Decision gate:
- Metric moved significantly: Hypothesis confirmed. Proceed to clean implementation in Phase 6
- Metric didn't move: Hypothesis wrong. Discard the experiment. Go back to Phase 2 and re-examine the profiling data. Do not invest in a clean implementation of something that doesn't help
- Metric moved but introduced side effects: Note the interaction. Factor into the clean implementation design
Approaches (from least to most invasive):
- Isolated benchmark script — simulate the proposed change outside the main codebase entirely (e.g., a Python script that tests DuckDB batch delete performance against a copy of the data)
- Throwaway branch — implement on a branch that will never be merged. Keeps the main codebase clean
- Feature-flagged change — if the system supports it, gate the change behind a flag for easy rollback
Why this exists: This is the cheapest place to learn your hypothesis is wrong. A few hours of benchmarking is better than days of clean implementation that doesn't help.
Artifact: Experiment measurement result (pass/fail on metric movement) + approach notes for clean implementation
Phase 6: Implementation Loop
The core improvement cycle. One bottleneck at a time, measured after each change.
For each targeted bottleneck, in priority order from Phase 4:
1. Implement the clean fix (minimal, targeted, production-quality)
2. Write/update tests for the changed behavior
3. Run ALL tests: safety net (Phase 3) + existing suite + new tests
4. Measure the specific bottleneck (compare to baseline)
5. Measure the FULL pipeline (catch interaction effects)
6. Record results: before/after for this change, cumulative improvement
7. Multi-model review of the change
8. Decision:
- Keep: improvement confirmed, no regressions → next bottleneck
- Iterate: improvement insufficient → refine the approach
- Revert: regression detected → revert FIRST, analyze SECOND
9. Document: update improvement brief with actual results
10. Checkpoint: am I still improving, or am I rewriting?Critical rules for this phase:
- ONE bottleneck per iteration. Never bundle two fixes. You won't be able to attribute the improvement.
- ALWAYS measure after each change. Not after "a few changes" — after each one.
- Same harness as baseline. Same inputs, same environment, same procedure.
- Measure the FULL pipeline, not just the targeted bottleneck. Changes interact.
- Revert before analyzing regressions. If a change breaks something, revert it immediately, THEN figure out why. Don't "fix forward" past a regression.
Multi-model review per change: Use Codex to review the diff against the codebase ("what could this break?") and GPT-5.2 Pro to review the measurement data ("is this improvement real or within noise?").
Artifact per iteration: Before/after measurement + keep/revert decision + rationale
Phase 7: Verification & Regression Audit
After all changes are implemented, comprehensive verification against the original success criteria.
- Cumulative measurement — full pipeline timing with ALL improvements applied, compared to Phase 2 baseline. Per scenario from Phase 0 matrix
- Success criteria check — does each scenario meet its Phase 0 target?
- Full regression scan — complete test suite, edge case testing, data integrity verification
- Improvement attribution — which change contributed how much (from Phase 6 per-change measurements)
- Unintended effects — anything that changed that wasn't targeted (better or worse)
If success criteria not met: Go back to Phase 2 (re-profile). The bottleneck landscape may have shifted after your improvements. The NEXT bottleneck may be different from what you expected.
Multi-model review: Send the full verification report to Codex + GPT-5.2 Pro + Gemini in parallel:
"Here's what we planned to improve, here's the profiling data, and here's what happened. Did we meet targets? Are there regressions we're not seeing? Is the improvement attribution sound?"
Artifact: Verification report with cumulative before/after, per-scenario results, and regression audit
Phase 8: Retrospective
Document what changed, why, and what the measured impact was.
- Summary — one-paragraph description of what was improved and by how much
- Before/after comparison — side-by-side measurements, per scenario
- Changes made — each change, its rationale, and its individual measured impact
- Hypothesis accuracy — which initial hypotheses were right, which were wrong, and what the actual bottlenecks turned out to be
- Process lessons — what we'd do differently next time
- Remaining opportunities — bottlenecks we chose not to address and why
- Monitoring recommendations — how to detect if the improvement degrades over time
Artifact: Retrospective doc
Multi-Model Review Protocol
Same structure as structured-development, but the review focus shifts. In structured-dev, models review correctness ("is this design right?"). In structured-improvement, models review soundness ("is this measurement real? is this change safe? are we optimizing the right thing?").
Model capabilities and constraints
Same as structured-development — see that skill for the full model capability table. Key differences in how models are used:
| Model | Improvement-specific strength |
| Codex | Blast radius analysis (reads actual codebase), instrumentation point review |
| GPT-5.2 Pro | Measurement validity, statistical reasoning, interaction effect analysis |
| Gemini 3 | Cross-validation of findings, web-grounded research on optimization techniques |
| Claude Opus 4.6 | Orchestration, profiling experiments, implementation |
Phase-specific review focus
| Phase | What models check for |
| After profiling (Phase 2) | "Are measurements sound? What could be measured wrong? What's missing?" |
| After targeted spec (Phase 4) | "Are we targeting the right bottlenecks? Are targets realistic? Interaction effects?" |
| After each implementation (Phase 6) | "Is this improvement real or noise? What could this diff break in the wider codebase?" |
| After verification (Phase 7) | "Did we meet targets? Hidden regressions? Is attribution sound?" |
Evidence requirements
When sending review queries, always require evidence-based analysis. Include: "Provide evidence-based answers only. If you're analyzing measurements, cite the specific numbers. If you're assessing regression risk, reference specific code paths. If you're unsure, say so explicitly."
Standing Rules
These apply across all phases:
- No baseline, no code. Never implement an improvement without profiling first. The Phase 0 hypothesis is not evidence.
- One variable at a time. Every change gets its own before/after measurement. Bundling changes makes attribution impossible and regression detection unreliable.
- Trust the profiler, not intuition. If your intuition says "inserts are slow" but the profiler says "deletions are 63% of time," the profiler wins.
- Treat variance as signal. Run 3+ measurements per scenario. Report mean and stddev. A 10% improvement is noise if variance is 15%. Don't celebrate improvements that are within measurement error.
- Regression is the primary risk. Every change must be tested against the full existing test suite plus the Phase 3 safety net. A performance win that breaks correctness is a net loss.
- Revert before analyzing. If a change introduces a regression, revert immediately, THEN figure out why. Don't "fix forward" — that compounds regression risk.
- Prefer local fixes over architectural rewrites. The smallest change that achieves the target is the best change. Escalate scope only when evidence shows local fixes cannot hit the target.
- Every step is its own tracked task. Same as structured-development. Implementation, measurement, regression test, review, documentation — each is a separate
TaskCreateentry. AI does not reliably complete multi-part tasks. - Checkpoint: still improving or rewriting? Scope creep in improvement work looks like "while we're in here, let's also restructure this module." If the change set grows beyond the targeted bottlenecks, stop and reassess. If you're touching more than ~3 files per bottleneck, you may have left improvement territory.
- Document every decision. Keep/revert/defer decisions must include evidence (measurement data). "It felt faster" is not evidence.
- Stop optimizing deliberately. End when objectives are met or returns are marginal. There's always another bottleneck — that doesn't mean it's worth chasing.
- Same harness for before/after. Same inputs, same environment, same procedure. Changing the measurement setup between before and after invalidates the comparison.
When to Use Which Skill
| Signal | Structured-Improvement | Structured-Development |
| Working system exists, goal is "make it better" | Yes | No |
| Performance optimization | Yes | No |
| Bug pattern fix (systematic, not one-off) | Yes | No |
| Refactoring (same behavior, better structure) | Yes | No |
| Building a new feature/system from scratch | No | Yes |
| Complete rewrite/replacement | No | Yes |
| Adding a major new feature to existing system | No | Yes (with integration awareness) |
The boundary: structured-improvement is for when the system already does the thing, but does it badly. Structured-development is for when the system doesn't do the thing yet.
Origin
Designed from a data-sync optimization that went the wrong way at first:
- Applied a greenfield development process to an improvement task — wrong tool
- The plan named row-by-row inserts as the bottleneck without profiling
- Post-implementation profiling revealed deletions dominated the wall-clock time (never in the plan)
- Merge/dedup and commit costs were also unaddressed
- Acceptance criteria were ambiguous (didn't distinguish incremental vs catch-up scenarios)
- Core lesson: profiling before implementation would have prevented a wholesale redesign when targeted fixes were sufficient
Synthesized from parallel multi-model review (Codex, Claude Opus, Gemini) — key contributions:
- Codex: Observability as separate phase, variance handling, scenario matrix, "stop optimizing deliberately"
- Opus: Scope creep checkpoints, regression boundary documentation, baseline capture rigor
- Gemini: Safety net / pinning tests, benchmark experiment with kill gate, "trust the profiler not intuition"
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.

