Pushes code toward a user's stretch target - a large speedup, much less code, every edge case found, or a rethought design. Use when the user invokes stretch with a target such as "make it 100x faster" or "删掉一半代码,功能不变". Do NOT use to check an already-measured speedup (use benchmark-checklist) or for an ordinary code review (use code-review).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Stretch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/wilbeibi-stretch)
---
name: stretch
description: Pushes code toward a user's stretch target - a large speedup, much less code, every edge case found, or a rethought design. Use when the user invokes stretch with a target such as "make it 100x faster" or "删掉一半代码,功能不变". Do NOT use to check an already-measured speedup (use benchmark-checklist) or for an ordinary code review (use code-review).
disable-model-invocation: true
---
# stretch
Aim for the user's number, prove every gain with a check that existed before the edit, and report the gap.
The target authorizes structural change inside its scope. It never authorizes breaking an invariant, gaming the measurement, or lowering the number.
## 1. Contract (REQUIRED before any edit)
Write this block at the start and repeat it in the report:
```text
Target: <the user's goal, verbatim>
Scope: <paths, user-facing flows, or modules>
Invariants: <what must not change: outputs, public API, file formats, error behavior>
Oracle: <the mode's check for the target, plus commands for every invariant>
Budget: <the user's time or iteration limit, or one you state>
```
- Derive invariants from the request, the tests, and public interfaces. "功能不变" covers error and edge behavior, not only the happy path.
- If an invariant is ambiguous and the user is present, ask. If the user is absent, take the stricter reading and record it.
- If the target fits no mode below and no check can decide it, stop and ask. "Polish it to a top-engineer standard" is such a target: have the user restate it as a mode or name a checkable standard.
- After the baseline, the oracle only gains checks. Never delete or weaken a test or check to make a change pass.
Done when the baseline is recorded: the oracle's numbers on unchanged code for Faster and Smaller, the current test result for Edge cases, and the current design's costs with locations or measurements for Rethink.
## 2. Work the mode
**Faster** ("100x", "10 倍")
- Oracle: benchmark the user-facing paths on realistic input, plus an output check independent of the timing.
- Profile, rank costs by share of end-to-end time, and remove the largest structural cost first: repeated work, full redraws or reloads, the wrong complexity class, needless IO or copies. Rerun the oracle after each change. Keep a change only if invariants pass and the number moves.
- Never cache on benchmark inputs, skip work the timer does not observe, or lower output quality an invariant protects.
- Load benchmark-checklist (route-skill `get benchmark-checklist`) and run its checks on the final claim. If it cannot load, say so in the report.
**Smaller** ("delete half the code")
- Oracle: the test suite and the public API surface. Metric: non-blank, non-comment lines outside tests, counted with the same tool before and after: `scc` or `cloc`, else `wc -l` over `git ls-files` with comments noted as included.
- Delete dead code, duplication, pass-through layers, and options nobody sets. Error handling and edge branches are behavior.
- Before deleting a branch no test covers, add a characterization test (load test-writing to decide whether it stays), or keep the branch.
- Never pack lines, compress logic into clever expressions, or move code into config or generated files to hit the count.
**Edge cases** ("find all boundary conditions and logic holes")
- Oracle: a failing test or runnable repro per finding.
- Read-only: no edits to production code or committed tests unless the user asked for fixes. Put repros and probes in `/tmp/<task>`.
- For each entry point, enumerate input and state classes: empty, one, maximum, malformed, duplicate, concurrent, partial failure, retry, restart. For state, lifecycle, or concurrency code, also load design-principles (route-skill `get design-principles`) and run its checks.
- Report each finding with its repro command and output. List unreproduced suspicions separately as unverified.
- "All" cannot be proven: report the classes checked and the classes skipped.
**Rethink** ("assume unlimited time, re-examine the design")
- Oracle: evidence per claim, as code locations or measurements.
- Read-only, with experiments in `/tmp/<task>`. Produce ranked proposals, including keeping the current design.
- Each proposal names what it removes or gains, its evidence (code locations, measurements), migration cost, riskiest assumption, and the cheapest experiment that would test it.
- Hand open decisions to grill-me.
## 3. Stop
Stop when the target is met, the budget is spent, or the remaining cost is a proven ceiling. A ceiling needs evidence and a bound: a path that is 30% unavoidable IO caps overall speedup near 3.3x. Difficulty alone is not a ceiling.
A gain that needs an invariant to break goes in the report as a proposal with its estimated gain. Do not apply it.
## Output
Lead with achieved versus target, then:
- Per path or area: before, after, ratio, and the oracle command. Give a microbenchmark's share of the end-to-end path.
- Invariants: the oracle result.
- Ceiling: what blocks further progress, with evidence.
- Proposals that would need an invariant to break.
Label each claim measured or inference.