Lift
Intent
Deliver aggressive, measurement-driven performance improvements (latency/throughput/memory/GC/tail) with correctness preserved and regressions guarded.
Zig CLI Iteration Repos
When iterating on the Zig-backed bench_stats/perf_report helper CLI path, use these two repos:
skills-zig (/Users/tk/workspace/tk/skills-zig): source for bench_stats and perf_report, build/test wiring, and release tags.
homebrew-tap (/Users/tk/workspace/tk/homebrew-tap): Homebrew formula updates/checksum bumps for released lift binaries.
Double Diamond fit
Lift lives in Define -> Deliver:
- Define: write a performance contract and pick a proof workload.
- Deliver: measure baseline, profile, run tight experiments, then ship with a guard.
Hard Rules
- Measure before and after every optimization (numbers + environment + command).
- Optimize the bottleneck, not the loudest hunch (profile/trace/counters required).
- Avoid micro-optimizations until algorithmic wins are exhausted.
- Keep correctness and safety invariants intact.
- Require a correctness signal before and after; never accept a perf win with failing correctness.
- Do not change semantics without explicit user approval.
- If you cannot run a proof workload, label the output
UNMEASURED and provide exact benchmark/profiling commands; treat all optimization ideas as hypotheses.
- Stop and ask before raising resource/cost ceilings (CPU cores, memory footprint, I/O bytes, external calls), unless explicitly requested.
- Stop when ROI is negative or risk exceeds benefit.
- For Lift-owned CLIs, use Zig binaries only (
bench_stats, perf_report) and prove compatibility via marker checks before use.
- After any Zig CLI contract change, update docs and release/tap propagation in the same pass so install guidance matches runtime behavior.
- When running
$lift on $lift with $ms, require a runnable proof bundle before done: Zig marker checks plus one sample invocation per CLI.
Default policy (non-interactive)
Goal: stay autonomous without inventing SLOs.
Mode selection (measured vs unmeasured)
If you can run a proof workload, operate in measured mode. Otherwise operate in unmeasured mode.
- Measured: run baseline + variant on the same workload; include numbers, bottleneck evidence, and a correctness signal.
- Unmeasured: start with
UNMEASURED: <why>; do not claim wins; provide the exact commands you would run to produce baseline/after + profiling evidence.
Contract derivation
If the user did not provide a numeric target:
- Define the contract as: "Improve on vs baseline; report delta; do not regress ."
- Do not invent SLO numbers; treat the goal as "maximize improvement within constraints".
Metric defaults (pick one):
- Request-like: latency p95 (also report p50/p99).
- Batch/offline: throughput (also report CPU% and memory).
- Memory issues: peak RSS + alloc rate / GC pause (also report latency).
Workload selection (proof signal)
Pick the first runnable, representative workload you can find:
- User-provided repro/command.
- Existing repo benchmark/harness (README, scripts, Makefile/justfile/taskfile).
- A minimal harness around the hot path (microbench) plus a correctness signal.
Stop and ask only if you cannot find or create any runnable proof workload without product ambiguity.
Experiment hygiene
- Change one variable at a time; keep diffs small and reversible.
- Reject wins smaller than the noise floor; re-run when variance is high.
- Track second-order regressions (memory, tail latency, CPU) even if the primary metric improves.
Workflow (Opinionated)
- Preflight
- Capture environment (hardware/OS/runtime flags).
- Pick a correctness signal and a performance workload; run each once to verify they work.
- Performance contract
- Metric + percentile + workload + environment + constraints.
- Baseline
- Warm up; collect enough samples for stable percentiles (keep raw samples when possible).
- Locate the bottleneck
- Profile/trace; classify bound (CPU/memory/I/O/lock/tail).
- Choose the highest-leverage lever
- Follow the optimization ladder: delete work -> algorithm -> data/layout -> concurrency -> I/O -> micro-arch -> runtime/compiler.
- Run tight experiments (loop)
- Hypothesis -> patch -> measure -> accept/reject -> record.
- Ship with guards
- Add/extend a benchmark, budget, or alert; document trade-offs.
- Report
- Present baseline vs variant and the evidence trail.
- CLI proof (Zig only)
- Lock Zig behavior and capture proof (
<tool> --help marker check plus one sample run).
- Keep install/run guidance in sync with the released
lift binary behavior before shipping.
Decision Gates
- If the baseline is noisy or unstable, fix measurement first.
- If the complexity class dominates, change the algorithm first.
- If tail latency dominates, treat variance reduction as the primary goal.
- If I/O dominates, reduce bytes, syscalls, or round trips before CPU tuning.
- If the only remaining wins require higher resource/cost ceilings, surface the trade-off and ask.
- Stop when ROI is negative or risk exceeds benefit.
Deliverable format (chat)
If unmeasured, prefix the response with UNMEASURED: <reason> and fill sections with a concrete measurement plan (no claimed deltas).
Output exactly these sections (short, numbers-first):
Performance contract
- Metric + percentile:
- Workload command:
- Dataset:
- Environment:
- Constraints:
Baseline
- Samples + warmup:
- Results (min/p50/p95/p99/max):
- Notes on variance/noise (or estimated noise floor):
Bottleneck evidence
- Tool + key finding:
- Hot paths / contention points:
- Bound classification:
Experiments
- <1-3 entries> Hypothesis -> change -> measurement delta -> decision
Result
- Variant results (min/p50/p95/p99/max):
- Delta vs baseline:
- Confidence (noise/variance):
- Trade-offs / regressions checked:
Regression guard
- Benchmark/budget added:
- Threshold (if any):
Validation
- Correctness command(s) -> pass/fail
- Performance command(s) -> numbers
Residual risks / next steps
lift_compliance: mode=<measured|unmeasured>; workload=<yes|no>; baseline=<yes|no>; after=<yes|no>; correctness=<yes|no>; bottleneck_evidence=<yes|no>
Core References (Load on Demand)
- Read
references/playbook.md for the master flow and optimization ladder.
- Read
references/measurement.md for benchmarking and statistical rigor.
- Read
references/profiling-tools.md for a profiler/tool matrix and evidence artifacts.
- Read
references/algorithms-and-data-structures.md for algorithmic levers.
- Read
references/systems-and-architecture.md for CPU, memory, and OS tactics.
- Read
references/latency-throughput-tail.md for queueing and tail behavior.
- Read
references/optimization-tactics.md for a tactical catalog by layer.
- Read
references/checklists.md for fast triage and validation checklists.
- Read
references/anti-patterns.md to avoid common traps.
Scripts
- Prefer this brew-aware launcher pattern for Lift CLIs (Zig-only, fail-closed):
run_lift_tool() {
local subcommand="${1:-}"
if [ -z "$subcommand" ]; then
echo "usage: run_lift_tool <bench-stats|perf-report> [args...]" >&2
return 2
fi
shift || true
local bin=""
local marker=""
case "$subcommand" in
bench-stats)
bin="bench_stats"
marker="bench_stats.zig"
;;
perf-report)
bin="perf_report"
marker="perf_report.zig"
;;
*)
echo "unknown lift subcommand: $subcommand" >&2
return 2
;;
esac
install_lift_direct() {
local repo="${SKILLS_ZIG_REPO:-$HOME/workspace/tk/skills-zig}"
if ! command -v zig >/dev/null 2>&1; then
echo "zig not found. Install Zig from https://ziglang.org/download/ and retry." >&2
return 1
fi
if [ ! -d "$repo" ]; then
echo "skills-zig repo not found at $repo." >&2
echo "clone it with: git clone https://github.com/tkersey/skills-zig \"$repo\"" >&2
return 1
fi
if ! (cd "$repo" && zig build -Doptimize=ReleaseSafe); then
echo "direct Zig build failed in $repo." >&2
return 1
fi
if [ ! -x "$repo/zig-out/bin/$bin" ]; then
echo "direct Zig build did not produce $repo/zig-out/bin/$bin." >&2
return 1
fi
mkdir -p "$HOME/.local/bin"
install -m 0755 "$repo/zig-out/bin/$bin" "$HOME/.local/bin/$bin"
}
local os="$(uname -s)"
if command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"; then
"$bin" "$@"
return
fi
if [ "$os" = "Darwin" ]; then
if ! command -v brew >/dev/null 2>&1; then
echo "homebrew is required on macOS: https://brew.sh/" >&2
return 1
fi
if ! brew install tkersey/tap/lift; then
echo "brew install tkersey/tap/lift failed." >&2
return 1
fi
elif ! (command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"); then
if ! install_lift_direct; then
return 1
fi
fi
if command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"; then
"$bin" "$@"
return
fi
echo "missing compatible $bin binary after install attempt." >&2
if [ "$os" = "Darwin" ]; then
echo "expected install path: brew install tkersey/tap/lift" >&2
else
echo "expected direct path: SKILLS_ZIG_REPO=<skills-zig-path> zig build -Doptimize=ReleaseSafe" >&2
fi
return 1
}
run_lift_tool bench-stats --input samples.txt --unit ms
run_lift_tool perf-report --title "Perf pass" --owner "team" --system "service" --output /tmp/perf-report.md
Assets
- Use
assets/perf-report-template.md as a ready-to-edit report.
- Use
assets/experiment-log-template.md to track experiments and results.
Output Expectations
- Deliver a baseline, bottleneck evidence, hypothesis, experiment plan, and measured result.
- Provide a minimal diff that preserves correctness and includes a regression guard.
- Explain trade-offs in plain language and record the measured delta.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: lift3description: Comprehensive, measurement-driven performance optimization for latency, throughput, memory/GC, and tail behavior. Use when the user asks to optimize/speed up, reduce latency (p95/p99), increase throughput/QPS, lower CPU/memory/allocations/GC pauses, profile hot paths, or run a benchmarked perf pass (including JSONL/query-heavy code). Requires before/after measurement on a runnable workload (or an explicit `UNMEASURED` plan) plus a correctness gate. Zig-only CLI iteration where `bench_stats`/`perf_report` are proven before shipping. Use when this capability is needed.4---56# Lift78## Intent910Deliver aggressive, measurement-driven performance improvements (latency/throughput/memory/GC/tail) with correctness preserved and regressions guarded.1112## Zig CLI Iteration Repos1314When iterating on the Zig-backed `bench_stats`/`perf_report` helper CLI path, use these two repos:1516- `skills-zig` (`/Users/tk/workspace/tk/skills-zig`): source for `bench_stats` and `perf_report`, build/test wiring, and release tags.17- `homebrew-tap` (`/Users/tk/workspace/tk/homebrew-tap`): Homebrew formula updates/checksum bumps for released `lift` binaries.1819## Double Diamond fit2021Lift lives in Define -> Deliver:22- Define: write a performance contract and pick a proof workload.23- Deliver: measure baseline, profile, run tight experiments, then ship with a guard.2425## Hard Rules2627- Measure before and after every optimization (numbers + environment + command).28- Optimize the bottleneck, not the loudest hunch (profile/trace/counters required).29- Avoid micro-optimizations until algorithmic wins are exhausted.30- Keep correctness and safety invariants intact.31- Require a correctness signal before and after; never accept a perf win with failing correctness.32- Do not change semantics without explicit user approval.33- If you cannot run a proof workload, label the output `UNMEASURED` and provide exact benchmark/profiling commands; treat all optimization ideas as hypotheses.34- Stop and ask before raising resource/cost ceilings (CPU cores, memory footprint, I/O bytes, external calls), unless explicitly requested.35- Stop when ROI is negative or risk exceeds benefit.36- For Lift-owned CLIs, use Zig binaries only (`bench_stats`, `perf_report`) and prove compatibility via marker checks before use.37- After any Zig CLI contract change, update docs and release/tap propagation in the same pass so install guidance matches runtime behavior.38- When running `$lift` on `$lift` with `$ms`, require a runnable proof bundle before done: Zig marker checks plus one sample invocation per CLI.3940## Default policy (non-interactive)4142Goal: stay autonomous without inventing SLOs.4344### Mode selection (measured vs unmeasured)4546If you can run a proof workload, operate in measured mode. Otherwise operate in unmeasured mode.4748- Measured: run baseline + variant on the same workload; include numbers, bottleneck evidence, and a correctness signal.49- Unmeasured: start with `UNMEASURED: <why>`; do not claim wins; provide the exact commands you would run to produce baseline/after + profiling evidence.5051### Contract derivation5253If the user did not provide a numeric target:54- Define the contract as: "Improve <metric> on <workload> vs baseline; report delta; do not regress <constraints>."55- Do not invent SLO numbers; treat the goal as "maximize improvement within constraints".5657Metric defaults (pick one):58- Request-like: latency p95 (also report p50/p99).59- Batch/offline: throughput (also report CPU% and memory).60- Memory issues: peak RSS + alloc rate / GC pause (also report latency).6162### Workload selection (proof signal)6364Pick the first runnable, representative workload you can find:651. User-provided repro/command.662. Existing repo benchmark/harness (README, scripts, Makefile/justfile/taskfile).673. A minimal harness around the hot path (microbench) plus a correctness signal.6869Stop and ask only if you cannot find or create any runnable proof workload without product ambiguity.7071### Experiment hygiene7273- Change one variable at a time; keep diffs small and reversible.74- Reject wins smaller than the noise floor; re-run when variance is high.75- Track second-order regressions (memory, tail latency, CPU) even if the primary metric improves.7677## Workflow (Opinionated)78790. Preflight80 - Capture environment (hardware/OS/runtime flags).81 - Pick a correctness signal and a performance workload; run each once to verify they work.821. Performance contract83 - Metric + percentile + workload + environment + constraints.842. Baseline85 - Warm up; collect enough samples for stable percentiles (keep raw samples when possible).863. Locate the bottleneck87 - Profile/trace; classify bound (CPU/memory/I/O/lock/tail).884. Choose the highest-leverage lever89 - Follow the optimization ladder: delete work -> algorithm -> data/layout -> concurrency -> I/O -> micro-arch -> runtime/compiler.905. Run tight experiments (loop)91 - Hypothesis -> patch -> measure -> accept/reject -> record.926. Ship with guards93 - Add/extend a benchmark, budget, or alert; document trade-offs.947. Report95 - Present baseline vs variant and the evidence trail.968. CLI proof (Zig only)97 - Lock Zig behavior and capture proof (`<tool> --help` marker check plus one sample run).98 - Keep install/run guidance in sync with the released `lift` binary behavior before shipping.99100## Decision Gates101102- If the baseline is noisy or unstable, fix measurement first.103- If the complexity class dominates, change the algorithm first.104- If tail latency dominates, treat variance reduction as the primary goal.105- If I/O dominates, reduce bytes, syscalls, or round trips before CPU tuning.106- If the only remaining wins require higher resource/cost ceilings, surface the trade-off and ask.107- Stop when ROI is negative or risk exceeds benefit.108109## Deliverable format (chat)110111If unmeasured, prefix the response with `UNMEASURED: <reason>` and fill sections with a concrete measurement plan (no claimed deltas).112113Output exactly these sections (short, numbers-first):114115**Performance contract**116- Metric + percentile:117- Workload command:118- Dataset:119- Environment:120- Constraints:121122**Baseline**123- Samples + warmup:124- Results (min/p50/p95/p99/max):125- Notes on variance/noise (or estimated noise floor):126127**Bottleneck evidence**128- Tool + key finding:129- Hot paths / contention points:130- Bound classification:131132**Experiments**133- <1-3 entries> Hypothesis -> change -> measurement delta -> decision134135**Result**136- Variant results (min/p50/p95/p99/max):137- Delta vs baseline:138- Confidence (noise/variance):139- Trade-offs / regressions checked:140141**Regression guard**142- Benchmark/budget added:143- Threshold (if any):144145**Validation**146- Correctness command(s) -> pass/fail147- Performance command(s) -> numbers148149**Residual risks / next steps**150- <bullets>151152`lift_compliance: mode=<measured|unmeasured>; workload=<yes|no>; baseline=<yes|no>; after=<yes|no>; correctness=<yes|no>; bottleneck_evidence=<yes|no>`153154## Core References (Load on Demand)155156- Read `references/playbook.md` for the master flow and optimization ladder.157- Read `references/measurement.md` for benchmarking and statistical rigor.158- Read `references/profiling-tools.md` for a profiler/tool matrix and evidence artifacts.159- Read `references/algorithms-and-data-structures.md` for algorithmic levers.160- Read `references/systems-and-architecture.md` for CPU, memory, and OS tactics.161- Read `references/latency-throughput-tail.md` for queueing and tail behavior.162- Read `references/optimization-tactics.md` for a tactical catalog by layer.163- Read `references/checklists.md` for fast triage and validation checklists.164- Read `references/anti-patterns.md` to avoid common traps.165166## Scripts167168- Prefer this brew-aware launcher pattern for Lift CLIs (Zig-only, fail-closed):169170```bash171run_lift_tool() {172 local subcommand="${1:-}"173 if [ -z "$subcommand" ]; then174 echo "usage: run_lift_tool <bench-stats|perf-report> [args...]" >&2175 return 2176 fi177 shift || true178179 local bin=""180 local marker=""181 case "$subcommand" in182 bench-stats)183 bin="bench_stats"184 marker="bench_stats.zig"185 ;;186 perf-report)187 bin="perf_report"188 marker="perf_report.zig"189 ;;190 *)191 echo "unknown lift subcommand: $subcommand" >&2192 return 2193 ;;194 esac195196 install_lift_direct() {197 local repo="${SKILLS_ZIG_REPO:-$HOME/workspace/tk/skills-zig}"198 if ! command -v zig >/dev/null 2>&1; then199 echo "zig not found. Install Zig from https://ziglang.org/download/ and retry." >&2200 return 1201 fi202 if [ ! -d "$repo" ]; then203 echo "skills-zig repo not found at $repo." >&2204 echo "clone it with: git clone https://github.com/tkersey/skills-zig \"$repo\"" >&2205 return 1206 fi207 if ! (cd "$repo" && zig build -Doptimize=ReleaseSafe); then208 echo "direct Zig build failed in $repo." >&2209 return 1210 fi211 if [ ! -x "$repo/zig-out/bin/$bin" ]; then212 echo "direct Zig build did not produce $repo/zig-out/bin/$bin." >&2213 return 1214 fi215 mkdir -p "$HOME/.local/bin"216 install -m 0755 "$repo/zig-out/bin/$bin" "$HOME/.local/bin/$bin"217 }218219 local os="$(uname -s)"220 if command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"; then221 "$bin" "$@"222 return223 fi224225 if [ "$os" = "Darwin" ]; then226 if ! command -v brew >/dev/null 2>&1; then227 echo "homebrew is required on macOS: https://brew.sh/" >&2228 return 1229 fi230 if ! brew install tkersey/tap/lift; then231 echo "brew install tkersey/tap/lift failed." >&2232 return 1233 fi234 elif ! (command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"); then235 if ! install_lift_direct; then236 return 1237 fi238 fi239240 if command -v "$bin" >/dev/null 2>&1 && "$bin" --help 2>&1 | grep -q "$marker"; then241 "$bin" "$@"242 return243 fi244 echo "missing compatible $bin binary after install attempt." >&2245 if [ "$os" = "Darwin" ]; then246 echo "expected install path: brew install tkersey/tap/lift" >&2247 else248 echo "expected direct path: SKILLS_ZIG_REPO=<skills-zig-path> zig build -Doptimize=ReleaseSafe" >&2249 fi250 return 1251}252253run_lift_tool bench-stats --input samples.txt --unit ms254run_lift_tool perf-report --title "Perf pass" --owner "team" --system "service" --output /tmp/perf-report.md255```256257- Direct Zig CLI commands:258 - `bench_stats --input samples.txt --unit ms`259 - `perf_report --title "Perf pass" --owner "team" --system "service" --output /tmp/perf-report.md`260261- Zig proof snippet:262 - `command -v bench_stats && bench_stats --help 2>&1 | grep -q bench_stats.zig`263 - `command -v perf_report && perf_report --help 2>&1 | grep -q perf_report.zig`264265- Sample invocation proof snippet:266 - `bench_stats --input samples.txt --unit ms`267 - `perf_report --title "Perf pass" --owner "team" --system "service" --output /tmp/perf-report.md`268269## Assets270271- Use `assets/perf-report-template.md` as a ready-to-edit report.272- Use `assets/experiment-log-template.md` to track experiments and results.273274## Output Expectations275276- Deliver a baseline, bottleneck evidence, hypothesis, experiment plan, and measured result.277- Provide a minimal diff that preserves correctness and includes a regression guard.278- Explain trade-offs in plain language and record the measured delta.279280---281> Converted and distributed by [TomeVault](https://tomevault.io/claim/tkersey) — claim your Tome and manage your conversions.282<!-- tomevault:4.0:skill_md:2026-04-11 -->