From aa3a797c5d305135ef2fc53adc1635c30e3bef7c Mon Sep 17 00:00:00 2001 From: Lukasz Boryn Date: Mon, 15 Jun 2026 14:29:25 +0200 Subject: [PATCH] feat(skills): coin nostos lessons into octobot, add Socratic sieve/winnow spine refactor(bdd): rename tdd-bdd skill to bdd (dir, triggers, 24 refs, symlink) feat(skills): add sieve (Real/Good/Minimal gate) and winnow (debloat audit) feat(skills): add background-work and review-angles from review-round lessons feat(bdd): fold rules 7/13/17 into interface-design + new SKILL sections docs(refute): extract shared elenchus doctrine, cite from review-angles/winnow/bdd docs(CLAUDE): reframe Simplicity First as the three sieves docs(README): list new skills, add Socratic-spine roadmap --- CLAUDE.md | 27 ++++-- README.md | 35 +++++++- skills/engineering/background-work/SKILL.md | 72 ++++++++++++++++ skills/engineering/{tdd-bdd => bdd}/SKILL.md | 28 +++++- .../{tdd-bdd => bdd}/anti-patterns.md | 2 +- .../{tdd-bdd => bdd}/deep-modules-r.md | 0 .../{tdd-bdd => bdd}/docstrings-py.md | 0 .../{tdd-bdd => bdd}/interface-design-py.md | 17 ++++ .../{tdd-bdd => bdd}/interface-design-r.md | 0 .../{tdd-bdd => bdd}/mocking-py.md | 0 .../engineering/{tdd-bdd => bdd}/mocking-r.md | 0 .../{tdd-bdd => bdd}/refactoring-r.md | 2 +- .../engineering/{tdd-bdd => bdd}/tests-py.md | 4 +- .../engineering/{tdd-bdd => bdd}/tests-r.md | 4 +- skills/engineering/dev-python/SKILL.md | 12 +-- skills/engineering/dev-r/SKILL.md | 8 +- skills/engineering/dev-r/analysis-loop.md | 4 +- skills/engineering/dev-r/package-loop.md | 6 +- skills/engineering/diagnose/SKILL.md | 10 +-- .../engineering/diagnose/feedback-loops-py.md | 6 +- .../engineering/diagnose/feedback-loops-r.md | 4 +- skills/engineering/grill-with-docs/SKILL.md | 2 +- .../engineering/grill-with-docs/examples-r.md | 2 +- skills/engineering/r-style/SKILL.md | 4 +- skills/engineering/r-style/box.md | 2 +- skills/engineering/r-style/dtplyr.md | 2 +- skills/engineering/review-angles/SKILL.md | 74 ++++++++++++++++ skills/engineering/review-angles/refute.md | 34 ++++++++ skills/engineering/sieve/SKILL.md | 85 +++++++++++++++++++ skills/engineering/winnow/SKILL.md | 82 ++++++++++++++++++ skills/productivity/jj-atomic/SKILL.md | 8 +- .../productivity/jj-atomic/anti-patterns.md | 11 +++ skills/productivity/jj-atomic/examples.md | 2 +- skills/scaffold/build-r-analysis/SKILL.md | 4 +- 34 files changed, 498 insertions(+), 55 deletions(-) create mode 100644 skills/engineering/background-work/SKILL.md rename skills/engineering/{tdd-bdd => bdd}/SKILL.md (72%) rename skills/engineering/{tdd-bdd => bdd}/anti-patterns.md (98%) rename skills/engineering/{tdd-bdd => bdd}/deep-modules-r.md (100%) rename skills/engineering/{tdd-bdd => bdd}/docstrings-py.md (100%) rename skills/engineering/{tdd-bdd => bdd}/interface-design-py.md (83%) rename skills/engineering/{tdd-bdd => bdd}/interface-design-r.md (100%) rename skills/engineering/{tdd-bdd => bdd}/mocking-py.md (100%) rename skills/engineering/{tdd-bdd => bdd}/mocking-r.md (100%) rename skills/engineering/{tdd-bdd => bdd}/refactoring-r.md (98%) rename skills/engineering/{tdd-bdd => bdd}/tests-py.md (98%) rename skills/engineering/{tdd-bdd => bdd}/tests-r.md (99%) create mode 100644 skills/engineering/review-angles/SKILL.md create mode 100644 skills/engineering/review-angles/refute.md create mode 100644 skills/engineering/sieve/SKILL.md create mode 100644 skills/engineering/winnow/SKILL.md diff --git a/CLAUDE.md b/CLAUDE.md index bda1958..3726beb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,17 +17,28 @@ Before implementing: - If a simpler approach exists, say so. Push back when warranted. - If something is unclear, stop. Name what's confusing. Ask. -## 2. Simplicity First +## 2. Simplicity First — the three sieves -**Minimum code that solves the problem. Nothing speculative.** +**Admit nothing by default. Every line must earn its place — to enter, or to +stay.** Pass each through three sieves: -- No features beyond what was asked. -- No abstractions for single-use code. -- No "flexibility" or "configurability" that wasn't requested. -- No error handling for impossible scenarios. -- If you write 200 lines and it could be 50, rewrite it. +- **Real** — Is the need true, or speculative? No feature beyond what was + asked; no abstraction for single-use code; no "flexibility" nobody + requested; no error handling for impossible scenarios. +- **Good** — Does it leave the code better for the next reader — not merely + shorter? Betterment must be nameable, not cosmetic. +- **Minimal** — Is this the leanest form? stdlib before custom code; a native + feature before a dependency; one line before fifty. -Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify. +The burden is on **keeping**, not cutting: "it's clearer this way" must +*justify* survival, never merely *excuse* it. If you write 200 lines and it +could be 50, rewrite it. + +Run the sieves at the **seal boundary** (the commit), not per keystroke — the +[`sieve`](skills/engineering/sieve/SKILL.md) skill is the full gate, and +[`winnow`](skills/engineering/winnow/SKILL.md) the after-the-fact debloat +pass. Exceptions that always pass Good: input validation, error handling that +prevents data loss, security, accessibility, explicitly requested behaviour. ## 3. Surgical Changes diff --git a/README.md b/README.md index 7bc5d06..ebdfbb8 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,16 @@ skill list. message; docs / docstrings / READMEs ship in the same change. ### engineering -- **tdd-bdd** — strict red-green-refactor loop with BDD Given/When/Then +- **sieve** — Socratic Real / Good / Minimal gate; burden on *keeping*, not + cutting. Fires at the seal boundary (build, prune, analysis). Pairs with + `winnow`. +- **winnow** — blunt after-the-fact debloat audit; `delete/stdlib/native/ + yagni/shrink` tags, `net: -N lines`. Only ever removes. Pairs with `sieve`. +- **background-work** — rules for daemon threads, trigger loops, shared + locks, readiness surfaces — the failures a green unit suite misses. +- **review-angles** — recall-biased correctness checklist for the post-green + review pass (stale refs, TOCTOU, ordering state, durability, invalidation). +- **bdd** — strict red-green-refactor loop with BDD Given/When/Then scenarios as the unit of work. - **diagnose** — six-phase bug hunt: feedback loop → reproduce → hypothesise → instrument → fix with regression test → cleanup. @@ -83,7 +92,7 @@ afternoon. a short Q-by-Q transcript on a vague task that resolves into a one-paragraph statement, mirroring `grill-with-docs/examples-r.md`. Makes the plan-only vs docs-anchored distinction obvious at a glance. -- **Python siblings for `tdd-bdd` / `diagnose`.** R has `tests-r.md`, +- **Python siblings for `bdd` / `diagnose`.** R has `tests-r.md`, `mocking-r.md`, `feedback-loops-r.md`, etc. Python equivalents (`tests-py.md`, `mocking-py.md`, `feedback-loops-py.md`) are acknowledged as missing in [`dev-python/SKILL.md`](skills/engineering/dev-python/SKILL.md). @@ -91,3 +100,25 @@ afternoon. `DESCRIPTION` for packages and `_targets.R` + `index.qmd` for analyses) is noted as out of scope in [`write-readme-py/SKILL.md`](skills/engineering/write-readme-py/SKILL.md). + +### Socratic spine (toward a harness) + +The library is being organized around a Socratic lifecycle — +**Question** (grill-me, grill-with-docs, plan-project) → **Gate** (sieve) → +**Build** (bdd) → **Refute** (review-angles, winnow, refute.md) → +**Seal** (jj-atomic). Done so far: the three-sieve spine in `CLAUDE.md §2` +and the shared `refute.md` elenchus doctrine. Remaining, **in order — don't +build the harness before the leaves are proven by real use**: + +- **Generalize `dev-python` / `dev-r` into one Socratic harness.** Both are + already proto-harnesses (implement → lint → test → commit). Extract one + language-agnostic loop — *grill → plan → per-slice(bdd red/green → sieve at + seal → jj-atomic) → review-angles + winnow → handoff* — with `dev-python` / + `dev-r` as the language-flavored leaves. This is the harness target. +- **Shared `## Intensity` convention.** `caveman` and `sieve` both have + lite/full/ultra; standardize a one-line intensity block so the harness can + run the whole spine at one setting (ultra = aggressive end-to-end). +- **Recategorize skills by lifecycle phase** (`question/gate/build/refute/ + seal/`) — *only if* the harness reads categories to sequence. Claude Code + doesn't scan category dirs, so until the harness consumes them this is + motion, not progress. Defer until the harness exists. diff --git a/skills/engineering/background-work/SKILL.md b/skills/engineering/background-work/SKILL.md new file mode 100644 index 0000000..3a5dc4a --- /dev/null +++ b/skills/engineering/background-work/SKILL.md @@ -0,0 +1,72 @@ +--- +name: background-work +description: Hard-won rules for writing a service with a background thread, a change-trigger loop, or a shared resource behind a lock — the failure modes unit tests never exercise (silent thread death, swallowed signals, locks held across network calls, busy-loop triggers, answering before the data exists). Use when the user says "background-work", "daemon thread", "background loop", "trigger loop", "change detector", "watcher", "shared lock", or is about to write any long-lived loop / lock / readiness surface. +--- + +# background-work + +## When to use +- About to write a **daemon thread**, a **change-trigger loop**, a + **watcher**, or anything that runs forever in the background. +- A **lock** will guard a resource several callers touch. +- A service answers requests whose data is built **asynchronously**. +- Read this *before* writing the thread — these are the bugs a green, + scenario-driven unit suite does not catch (see rule 13 in + [`../bdd/SKILL.md`](../bdd/SKILL.md)). + +## Core principle +**A background thread that dies takes its silence with it.** The process +keeps serving, health keeps answering, and the loop's job silently never +happens again. Everything below defends against that one failure shape. + +## Before you spawn the thread +- **Parse configuration first (rule 3).** A malformed env var must crash the + *container at startup*, where it is visible — not inside a daemon thread + minutes later, after health already said ok. +- **Arm the trigger before the work it observes (rule 8).** Priming a change + detector *after* a long initial pass absorbs everything that changed + during the pass into the baseline — never processed. Fingerprint first, + then index; the first check after startup catches the window. + +## Inside the loop +- **Nothing may raise (rule 1).** Wrap every pass; log; retry. Treat "first + iteration fails because a dependency is still booting" as the *expected* + startup path, not an edge case. +- **A retry must not consume the signal that scheduled it (rule 2).** Keep a + `pending` flag that *only a successful pass* clears — otherwise a transient + error eats the trigger fire and the change is never processed. + +## Locks +- **Never hold a lock across a network (or LLM) round-trip (rule 4).** Scope + the lock to the shared resource itself — per statement, rows materialised + before release — so a minutes-long call cannot block a millisecond lookup. + State the isolation trade-off in the lock owner's docstring. +- **Put the lock where the resource is, not where the callers are (rule 5).** + `with lock:` copy-pasted into every caller is an invariant enforced by + author discipline; the next caller forgets it and no test notices. A + guarded wrapper around the resource makes unlocked access + *unrepresentable*. + +## Cost and surface +- **An always-firing trigger is a busy loop with extra steps (rule 12).** + "Fire every interval, let the differ decide" is harmless until the differ + is a full content-hash pass holding the shared lock. Check the + steady-state cost on a *quiet* system — that's the number that matters. +- **Readiness is part of the API, not just the health endpoint (rule 9).** + If the service answers before its data exists, "not found" becomes a + confident lie. Gate the answering surface on the same status health + reports, and keep that vocabulary in one module. + +## Guardrails +- **Never** let a background pass raise to the top of the loop. +- **Never** clear the pending flag on a failed pass. +- **Never** hold a lock across I/O you don't control. +- **Never** answer a query the underlying data can't yet satisfy — gate it. + +## See also +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — rule 13: green is necessary, + not sufficient; budget a recall-biased review after the thread is written. +- [`../review-angles/SKILL.md`](../review-angles/SKILL.md) — EAFP, stale + references, readiness — the correctness angles these loops trip over. +- [`../diagnose/SKILL.md`](../diagnose/SKILL.md) — when a background loop is + silently not doing its job, start here. diff --git a/skills/engineering/tdd-bdd/SKILL.md b/skills/engineering/bdd/SKILL.md similarity index 72% rename from skills/engineering/tdd-bdd/SKILL.md rename to skills/engineering/bdd/SKILL.md index d3fb92c..02b1103 100644 --- a/skills/engineering/tdd-bdd/SKILL.md +++ b/skills/engineering/bdd/SKILL.md @@ -1,12 +1,12 @@ --- -name: tdd-bdd -description: Drive implementation with a strict red-green-refactor loop where every test is first stated as a BDD-flavored Given/When/Then scenario before being translated into the project's native test framework. Use when the user says "tdd", "bdd", "/tdd-bdd", "use TDD", "use BDD", "behaviour-driven development", "behavior-driven development", "red-green-refactor", "write tests first", or asks to add a feature/fix a bug and a test suite exists (or should exist) in the repo. +name: bdd +description: Drive implementation with a strict red-green-refactor loop where every test is first stated as a BDD-flavored Given/When/Then scenario before being translated into the project's native test framework. Use when the user says "tdd", "bdd", "/bdd", "use TDD", "use BDD", "behaviour-driven development", "behavior-driven development", "red-green-refactor", "write tests first", or asks to add a feature/fix a bug and a test suite exists (or should exist) in the repo. --- -# tdd-bdd +# bdd ## When to use -- User says "tdd", "/tdd-bdd", "test first", "write a failing test first". +- User says "tdd", "/bdd", "test first", "write a failing test first". - A bug fix or new behavior is requested and the repo has a test runner (or one can be added in < 5 min). - Behavior is observable from outside the unit (input → output, state @@ -80,6 +80,26 @@ Testthat ed. 3+, `box::use`, `describe`/`it`. - No production code exists that is not exercised by a test added in this loop. +## Fixtures must match the graph the producer really emits + +Hand-built unit fixtures encode the shape you *imagine*, and stay green +while the real producer emits a different one. A query tool was written +assuming `calls` edges reach callee definitions; the real mappers stop a +cross-file call at a same-named reference node, so the tool was blind across +files — and the hand-made fixtures hid it the whole way (rule 17). Before +building on a stored shape, **probe what the writer actually produces** (or +generate the fixture *with* the real producer), and **live-verify on a +realistic multi-file input** before calling a phase done. + +## Green is necessary, not sufficient + +A passing scenario suite does not exercise thread death, lock contention, +caller ordering, hostile filesystem layouts, or stale stored data (rule 13). +A green suite is a *claim*, not a proof. After the loop is green, **budget a +recall-biased review pass** — [`../review-angles/SKILL.md`](../review-angles/SKILL.md) +— and refute the green ([`../review-angles/refute.md`](../review-angles/refute.md)) +before calling it done. Fix findings red-test-first, like any other feature. + ## Anti-patterns See [anti-patterns.md](anti-patterns.md) — horizontal slicing, passing on diff --git a/skills/engineering/tdd-bdd/anti-patterns.md b/skills/engineering/bdd/anti-patterns.md similarity index 98% rename from skills/engineering/tdd-bdd/anti-patterns.md rename to skills/engineering/bdd/anti-patterns.md index d40178c..d3a8d0c 100644 --- a/skills/engineering/tdd-bdd/anti-patterns.md +++ b/skills/engineering/bdd/anti-patterns.md @@ -1,4 +1,4 @@ -# tdd-bdd anti-patterns +# bdd anti-patterns ## Horizontal slicing diff --git a/skills/engineering/tdd-bdd/deep-modules-r.md b/skills/engineering/bdd/deep-modules-r.md similarity index 100% rename from skills/engineering/tdd-bdd/deep-modules-r.md rename to skills/engineering/bdd/deep-modules-r.md diff --git a/skills/engineering/tdd-bdd/docstrings-py.md b/skills/engineering/bdd/docstrings-py.md similarity index 100% rename from skills/engineering/tdd-bdd/docstrings-py.md rename to skills/engineering/bdd/docstrings-py.md diff --git a/skills/engineering/tdd-bdd/interface-design-py.md b/skills/engineering/bdd/interface-design-py.md similarity index 83% rename from skills/engineering/tdd-bdd/interface-design-py.md rename to skills/engineering/bdd/interface-design-py.md index e61f04e..667efd6 100644 --- a/skills/engineering/tdd-bdd/interface-design-py.md +++ b/skills/engineering/bdd/interface-design-py.md @@ -71,6 +71,23 @@ must cover. Shrink it: - Fold orthogonal args into one structured input (a small frozen dataclass) rather than six positional parameters. +## 4. Don't pair parameters that can silently disagree + +Two parameters that encode the same fact let a caller make them contradict +with no error ever. A function taking both a `conn` and the `db_path` it +"belongs to" can be handed a connection to database A and a path beside +database B — and nothing catches it. + +```python +# BAD — two sources of truth for one fact; they can disagree silently +def reindex(conn: Connection, db_path: Path) -> None: ... +``` + +Split the entry points so each caller supplies exactly **one** source of +truth — derive the other, or take only the one the body actually uses. The +test that would have caught the mismatch is one you never have to write, +because the mismatch is now unrepresentable. + ## Choosing the type of "thing" | Need | Use | diff --git a/skills/engineering/tdd-bdd/interface-design-r.md b/skills/engineering/bdd/interface-design-r.md similarity index 100% rename from skills/engineering/tdd-bdd/interface-design-r.md rename to skills/engineering/bdd/interface-design-r.md diff --git a/skills/engineering/tdd-bdd/mocking-py.md b/skills/engineering/bdd/mocking-py.md similarity index 100% rename from skills/engineering/tdd-bdd/mocking-py.md rename to skills/engineering/bdd/mocking-py.md diff --git a/skills/engineering/tdd-bdd/mocking-r.md b/skills/engineering/bdd/mocking-r.md similarity index 100% rename from skills/engineering/tdd-bdd/mocking-r.md rename to skills/engineering/bdd/mocking-r.md diff --git a/skills/engineering/tdd-bdd/refactoring-r.md b/skills/engineering/bdd/refactoring-r.md similarity index 98% rename from skills/engineering/tdd-bdd/refactoring-r.md rename to skills/engineering/bdd/refactoring-r.md index 229715d..62c2e03 100644 --- a/skills/engineering/tdd-bdd/refactoring-r.md +++ b/skills/engineering/bdd/refactoring-r.md @@ -1,6 +1,6 @@ # Refactor candidates (R) -After every tdd-bdd cycle goes green, scan for these. Refactor only with a +After every bdd cycle goes green, scan for these. Refactor only with a green test bar. ## Duplication → extract a function diff --git a/skills/engineering/tdd-bdd/tests-py.md b/skills/engineering/bdd/tests-py.md similarity index 98% rename from skills/engineering/tdd-bdd/tests-py.md rename to skills/engineering/bdd/tests-py.md index a878455..7bf031c 100644 --- a/skills/engineering/tdd-bdd/tests-py.md +++ b/skills/engineering/bdd/tests-py.md @@ -1,8 +1,8 @@ -# Python tests for tdd-bdd +# Python tests for bdd Paired good/bad examples for Python (pytest only). One principle per section: bad first, good second, then a one-paragraph reason. Use these as -the concrete reference when applying the core tdd-bdd loop in a Python +the concrete reference when applying the core bdd loop in a Python repo. **Framework rule — pytest, nothing else.** Fixtures via `@pytest.fixture` diff --git a/skills/engineering/tdd-bdd/tests-r.md b/skills/engineering/bdd/tests-r.md similarity index 99% rename from skills/engineering/tdd-bdd/tests-r.md rename to skills/engineering/bdd/tests-r.md index 64751a6..20dbe84 100644 --- a/skills/engineering/tdd-bdd/tests-r.md +++ b/skills/engineering/bdd/tests-r.md @@ -1,9 +1,9 @@ -# R tests for tdd-bdd +# R tests for bdd Paired good/bad examples for R (testthat ed. 3+, `box::use`, `describe`/`it`). One principle per section: bad first, good second, then a one-paragraph reason. Use these as the concrete reference when applying the -core tdd-bdd loop in an R repo. +core bdd loop in an R repo. --- diff --git a/skills/engineering/dev-python/SKILL.md b/skills/engineering/dev-python/SKILL.md index c1f47f5..b06a670 100644 --- a/skills/engineering/dev-python/SKILL.md +++ b/skills/engineering/dev-python/SKILL.md @@ -1,6 +1,6 @@ --- name: dev-python -description: Orchestrate the full Python development workflow in a uv + Docker + justfile project — implement, lint, typecheck, test (TDD-BDD), commit. Use ONLY when the user explicitly asks for the workflow ("run the python workflow", "full dev loop", "/dev-python"). Do NOT auto-invoke for individual tasks like fixing a bug, adding a function, or writing tests — those use the relevant focused skill (`/tdd-bdd`, `/diagnose`, `/jj-atomic`) directly. +description: Orchestrate the full Python development workflow in a uv + Docker + justfile project — implement, lint, typecheck, test (TDD-BDD), commit. Use ONLY when the user explicitly asks for the workflow ("run the python workflow", "full dev loop", "/dev-python"). Do NOT auto-invoke for individual tasks like fixing a bug, adding a function, or writing tests — those use the relevant focused skill (`/bdd`, `/diagnose`, `/jj-atomic`) directly. --- # dev-python @@ -13,8 +13,8 @@ Each phase must pass before the next. Do not advance silently. - A fresh feature or fix needs the complete loop, not a single skill. ## When NOT to use -- Single-task work: a bug fix → `/diagnose` + `/tdd-bdd` directly. -- Writing tests for an already-implemented behaviour → `/tdd-bdd` only. +- Single-task work: a bug fix → `/diagnose` + `/bdd` directly. +- Writing tests for an already-implemented behaviour → `/bdd` only. - Committing a single change → `/jj-atomic` only. ## Phases @@ -50,9 +50,9 @@ Fix type errors. Don't suppress with `# type: ignore` unless genuinely unavoidable — explain inline why. ### 4. Test (TDD-BDD) -Hand to [`/tdd-bdd`](../tdd-bdd/SKILL.md), which loops red→green→refactor +Hand to [`/bdd`](../bdd/SKILL.md), which loops red→green→refactor **one scenario at a time** — never write all the tests upfront (that's the -horizontal-slicing anti-pattern called out in tdd-bdd itself). When every +horizontal-slicing anti-pattern called out in bdd itself). When every scenario from step 0 is green: ```bash just test @@ -79,7 +79,7 @@ Hand to [`/jj-atomic`](../../productivity/jj-atomic/SKILL.md). The fix | `just fix-and-check` | lint-fix + fmt + typecheck + test | ## See also -- [`../tdd-bdd/SKILL.md`](../tdd-bdd/SKILL.md) — Given/When/Then loop; +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — Given/When/Then loop; Python siblings `tests-py.md`, `mocking-py.md`, `interface-design-py.md`, `docstrings-py.md`. - [`../diagnose/SKILL.md`](../diagnose/SKILL.md) — six-phase bug hunt. diff --git a/skills/engineering/dev-r/SKILL.md b/skills/engineering/dev-r/SKILL.md index 44758f8..516c54a 100644 --- a/skills/engineering/dev-r/SKILL.md +++ b/skills/engineering/dev-r/SKILL.md @@ -1,6 +1,6 @@ --- name: dev-r -description: Orchestrate the full R development workflow. Auto-detects project type — `DESCRIPTION` present → R package; `_targets.R` present → R analysis — and runs the appropriate loop (implement → lint → style → test → commit). Applies /r-style throughout. Use ONLY when the user explicitly asks for the workflow ("run the R workflow", "full R dev loop", "/dev-r"). Do NOT auto-invoke for individual R tasks — those use `/tdd-bdd`, `/diagnose`, `/r-style`, or `/jj-atomic` directly. +description: Orchestrate the full R development workflow. Auto-detects project type — `DESCRIPTION` present → R package; `_targets.R` present → R analysis — and runs the appropriate loop (implement → lint → style → test → commit). Applies /r-style throughout. Use ONLY when the user explicitly asks for the workflow ("run the R workflow", "full R dev loop", "/dev-r"). Do NOT auto-invoke for individual R tasks — those use `/bdd`, `/diagnose`, `/r-style`, or `/jj-atomic` directly. --- # dev-r @@ -17,8 +17,8 @@ Workflow for R repos. Detects project type from filesystem markers: Apply [`/r-style`](../r-style/SKILL.md) at every implementation step. ## When NOT to use -- Single-task work: bug fix → `/diagnose` + `/tdd-bdd` directly. -- Writing tests → `/tdd-bdd` only. +- Single-task work: bug fix → `/diagnose` + `/bdd` directly. +- Writing tests → `/bdd` only. - Reviewing R style of one file → `/r-style` only. - Committing → `/jj-atomic` only. @@ -42,7 +42,7 @@ or [`/grill-with-docs`](../grill-with-docs/SKILL.md) (anchors to (lint → style → test → run pipeline → render → commit) ## See also -- [`../tdd-bdd/SKILL.md`](../tdd-bdd/SKILL.md) and its R siblings +- [`../bdd/SKILL.md`](../bdd/SKILL.md) and its R siblings (`tests-r.md`, `interface-design-r.md`, `mocking-r.md`, `deep-modules-r.md`, `refactoring-r.md`, `anti-patterns.md`). - [`../diagnose/SKILL.md`](../diagnose/SKILL.md) — six-phase bug hunt diff --git a/skills/engineering/dev-r/analysis-loop.md b/skills/engineering/dev-r/analysis-loop.md index beddde8..eb35f7f 100644 --- a/skills/engineering/dev-r/analysis-loop.md +++ b/skills/engineering/dev-r/analysis-loop.md @@ -18,9 +18,9 @@ just style-check # fix with: just style ## 3. Test (TDD-BDD) -Hand to [`/tdd-bdd`](../tdd-bdd/SKILL.md), which loops red→green→refactor +Hand to [`/bdd`](../bdd/SKILL.md), which loops red→green→refactor **one scenario at a time** — never write all the tests upfront (see -[`../tdd-bdd/anti-patterns.md`](../tdd-bdd/anti-patterns.md)). Target +[`../bdd/anti-patterns.md`](../bdd/anti-patterns.md)). Target `R/functions/`. Then: ```bash diff --git a/skills/engineering/dev-r/package-loop.md b/skills/engineering/dev-r/package-loop.md index b89af0f..7ea8821 100644 --- a/skills/engineering/dev-r/package-loop.md +++ b/skills/engineering/dev-r/package-loop.md @@ -28,10 +28,10 @@ just style ## 4. Test (TDD-BDD) -Hand to [`/tdd-bdd`](../tdd-bdd/SKILL.md), which loops red→green→refactor +Hand to [`/bdd`](../bdd/SKILL.md), which loops red→green→refactor **one scenario at a time** — never write all the tests upfront (see -[`../tdd-bdd/anti-patterns.md`](../tdd-bdd/anti-patterns.md)). Test -prologue follows [`../tdd-bdd/tests-r.md`](../tdd-bdd/tests-r.md). Run: +[`../bdd/anti-patterns.md`](../bdd/anti-patterns.md)). Test +prologue follows [`../bdd/tests-r.md`](../bdd/tests-r.md). Run: ```bash just test # devtools::test() diff --git a/skills/engineering/diagnose/SKILL.md b/skills/engineering/diagnose/SKILL.md index e51265f..860191b 100644 --- a/skills/engineering/diagnose/SKILL.md +++ b/skills/engineering/diagnose/SKILL.md @@ -51,10 +51,10 @@ Prefer interactive inspection over logging — cleanup is `grep`-able. ### 5. Fix + regression test -Hand off to [tdd-bdd](../tdd-bdd/SKILL.md): +Hand off to [bdd](../bdd/SKILL.md): - State the bug as one Given/When/Then scenario. - Translate into a failing testthat test at the **public** interface - (see `../tdd-bdd/mocking-r.md` — do not reach past it). + (see `../bdd/mocking-r.md` — do not reach past it). - Watch it fail with the original error. - Apply the fix. Watch it pass. Re-run the original user-facing scenario. @@ -65,7 +65,7 @@ Hand off to [tdd-bdd](../tdd-bdd/SKILL.md): - Commit message names the confirmed hypothesis ("H1: `data.table` reference semantics in `assemble_expr`") so future readers see the *why*. - Note architectural follow-ups as - [refactoring-r.md](../tdd-bdd/refactoring-r.md) candidates; file them, + [refactoring-r.md](../bdd/refactoring-r.md) candidates; file them, don't auto-fix in the same commit. ## Guardrails @@ -76,8 +76,8 @@ Hand off to [tdd-bdd](../tdd-bdd/SKILL.md): - **Never** ship instrumentation. Cleanup is a phase, not an afterthought. ## See also -- [../tdd-bdd/SKILL.md](../tdd-bdd/SKILL.md) — phase 5 is a tdd-bdd cycle. -- [../tdd-bdd/refactoring-r.md](../tdd-bdd/refactoring-r.md) — file +- [../bdd/SKILL.md](../bdd/SKILL.md) — phase 5 is a bdd cycle. +- [../bdd/refactoring-r.md](../bdd/refactoring-r.md) — file architectural follow-ups here. - [../grill-with-docs/SKILL.md](../grill-with-docs/SKILL.md) — phase 3 hypothesis names should use canonical terms from `CONTEXT.md`. diff --git a/skills/engineering/diagnose/feedback-loops-py.md b/skills/engineering/diagnose/feedback-loops-py.md index 0caa0e6..3004e94 100644 --- a/skills/engineering/diagnose/feedback-loops-py.md +++ b/skills/engineering/diagnose/feedback-loops-py.md @@ -35,7 +35,7 @@ drive it from one pytest test — also where the fix will live. out "broke because pandas 2.2 changed a default". - **Isolate the filesystem**: `tmp_path`, never the repo tree. - **Kill ambient network** so a hung NCBI call can't masquerade as a bug - (see [../tdd-bdd/mocking-py.md](../tdd-bdd/mocking-py.md) autouse fixture). + (see [../bdd/mocking-py.md](../bdd/mocking-py.md) autouse fixture). If the same loop gives two different answers in a row, **fix the loop before phase 2**. @@ -72,7 +72,7 @@ Test passes. H1 confirmed. **Phase 5 — regression test** = the idempotence test. Move the copy from the diagnostic patch into the real fix at the contract boundary (return a fresh frame, don't mutate the argument — see -[../tdd-bdd/interface-design-py.md](../tdd-bdd/interface-design-py.md)). +[../bdd/interface-design-py.md](../bdd/interface-design-py.md)). **Phase 6 — cleanup.** `grep -rn "### DIAGNOSE-" .` → zero hits. Commit: *"fix(assemble_expr): return a fresh frame — H1: pandas view aliasing @@ -108,4 +108,4 @@ time). **Phase 6 — cleanup.** Nothing to revert. Commit: *"test(textmining): seed RNG to stabilise tie-break — H1 confirmed"*. File a follow-up: production `score_terms()` should break ties on a stable key (`term_id`), not input -order → [../tdd-bdd/refactoring-r.md](../tdd-bdd/refactoring-r.md) candidate. +order → [../bdd/refactoring-r.md](../bdd/refactoring-r.md) candidate. diff --git a/skills/engineering/diagnose/feedback-loops-r.md b/skills/engineering/diagnose/feedback-loops-r.md index db0d29d..5c268c3 100644 --- a/skills/engineering/diagnose/feedback-loops-r.md +++ b/skills/engineering/diagnose/feedback-loops-r.md @@ -99,7 +99,7 @@ Test passes. H1 confirmed. **Phase 5 — regression test** = the idempotence test above (already written). Now move the `copy()` from the diagnostic patch into the real fix at the boundary the contract requires (likely the constructor of the -`modb_result` object — see `../tdd-bdd/interface-design-r.md`). +`modb_result` object — see `../bdd/interface-design-r.md`). **Phase 6 — cleanup.** `grep -r "### DIAGNOSE-" .` shows zero hits. Commit message: @@ -143,4 +143,4 @@ Nothing to revert. Commit: *"test(textmining): seed RNG to stabilise top-term tie-break — H1 confirmed"*. File an architectural follow-up: "production `score_terms()` should break ties on a stable key (`term_id`) rather than relying on input order" → goes to -`../tdd-bdd/refactoring-r.md` candidate list. +`../bdd/refactoring-r.md` candidate list. diff --git a/skills/engineering/grill-with-docs/SKILL.md b/skills/engineering/grill-with-docs/SKILL.md index f4496c6..0292110 100644 --- a/skills/engineering/grill-with-docs/SKILL.md +++ b/skills/engineering/grill-with-docs/SKILL.md @@ -78,7 +78,7 @@ write to any new file in the repo before proceeding. confirming the first such write. ## See also -- [../tdd-bdd/SKILL.md](../tdd-bdd/SKILL.md) — once vocabulary is pinned, +- [../bdd/SKILL.md](../bdd/SKILL.md) — once vocabulary is pinned, the Given/When/Then scenarios should use the canonical terms. - [../diagnose/SKILL.md](../diagnose/SKILL.md) — hypothesis names in diagnose post-mortems should match `CONTEXT.md` terminology. diff --git a/skills/engineering/grill-with-docs/examples-r.md b/skills/engineering/grill-with-docs/examples-r.md index e2a0a03..bd9e007 100644 --- a/skills/engineering/grill-with-docs/examples-r.md +++ b/skills/engineering/grill-with-docs/examples-r.md @@ -48,7 +48,7 @@ User: *"MODB tissue column."* > downstream `purrr::compact` drops it), or an error? Forces the user to commit to the contract before any test is written. -Hands cleanly to `/tdd-bdd` once locked. +Hands cleanly to `/bdd` once locked. ## Cross-reference contradiction the agent surfaces diff --git a/skills/engineering/r-style/SKILL.md b/skills/engineering/r-style/SKILL.md index 2114cde..02dc083 100644 --- a/skills/engineering/r-style/SKILL.md +++ b/skills/engineering/r-style/SKILL.md @@ -50,9 +50,9 @@ file under review. saving. See [dtplyr.md](dtplyr.md#when-not-to-use). ## See also -- [../tdd-bdd/deep-modules-r.md](../tdd-bdd/deep-modules-r.md) — +- [../bdd/deep-modules-r.md](../bdd/deep-modules-r.md) — `box::export()` is the public-surface control mechanism. -- [../tdd-bdd/interface-design-r.md](../tdd-bdd/interface-design-r.md) — +- [../bdd/interface-design-r.md](../bdd/interface-design-r.md) — pure functions + DI compose with these style rules. - [../diagnose/feedback-loops-r.md](../diagnose/feedback-loops-r.md) — worked example #1 (in-place mutation) is the canonical `dtplyr` / diff --git a/skills/engineering/r-style/box.md b/skills/engineering/r-style/box.md index 68d6216..539b526 100644 --- a/skills/engineering/r-style/box.md +++ b/skills/engineering/r-style/box.md @@ -62,7 +62,7 @@ fetch_pages <- function(req) { ... } ``` Keep `box::export()` deliberately small — see -[../tdd-bdd/deep-modules-r.md](../tdd-bdd/deep-modules-r.md). Every name +[../bdd/deep-modules-r.md](../bdd/deep-modules-r.md). Every name you export is a contract you owe future callers and tests. ## `.Rmd` setup chunks — no exception diff --git a/skills/engineering/r-style/dtplyr.md b/skills/engineering/r-style/dtplyr.md index c9b6ddd..8cf93b9 100644 --- a/skills/engineering/r-style/dtplyr.md +++ b/skills/engineering/r-style/dtplyr.md @@ -148,5 +148,5 @@ Read that before you reach for `:=`. ## See also - [box.md](box.md) — preferred way to bring `data.table` / `dtplyr` names into scope (`dt = data.table[...]`). -- [../tdd-bdd/interface-design-r.md](../tdd-bdd/interface-design-r.md) — +- [../bdd/interface-design-r.md](../bdd/interface-design-r.md) — "return, don't mutate" applies even harder to `data.table`. diff --git a/skills/engineering/review-angles/SKILL.md b/skills/engineering/review-angles/SKILL.md new file mode 100644 index 0000000..242dbb9 --- /dev/null +++ b/skills/engineering/review-angles/SKILL.md @@ -0,0 +1,74 @@ +--- +name: review-angles +description: A recall-biased correctness checklist for the review pass that runs after the tests are green — the robustness angles unit scenarios never exercise (stale stored references, check-then-read races, unfamiliar filesystem layouts, ordering-sensitive state, durability load paths, derived-edge invalidation). Use when the user says "review-angles", "recall review", "correctness review", "robustness review", "what could break", runs a post-green review pass, or finishes a phase and wants the finder angles before calling it done. +--- + +# review-angles + +## When to use +- A feature is **green** and you want the review pass that finds what tests + don't — run after `/bdd`, before calling a phase done. +- A `/diagnose` post-mortem, or `/code-review`, wants concrete finder angles. +- **Why this exists (rule 13):** TDD green is *necessary, not sufficient*. + Findings live in code with 100% passing, scenario-driven tests, because + unit scenarios don't exercise thread death, lock contention, caller + ordering, hostile filesystem layouts, or stale stored data. Run each angle + as a separate finder; verify adversarially; fix red-test-first. + +## The angles + +Each is a question to interrogate the change with. One real finding per +angle is worth more than a green suite. + +1. **Ordering-sensitive state — derive, don't relay (rule 6).** A return flag + ("rebuilt") reported only by the call that rebuilds is lost the moment a + second caller runs first. When consistency matters, cross-check the + *artifacts themselves* (sidecar claims a build + graph has zero nodes → + sidecar is stale) so no calling order can desync them. + +2. **EAFP over check-then-read — TOCTOU (rule 10).** `is_file()` then + `read_bytes()` is a crash window against git gc, branch deletes, log + rotation. Read and catch the exception; the check just reopens the race. + Applies *everywhere another process writes* the same path. + +3. **"Is it a directory" is not "is it absent" (rule 11).** `.git` can be a + *file* (worktrees, submodules: a `gitdir:` pointer). Treating an + unfamiliar layout as "feature not present" silently selects the degraded + path. Resolve the pointer, *then* fall back — and keep the fallback cheap + (stat fingerprints, not content hashes). + +4. **Write-time validation is a point-in-time fact, not an invariant + (rule 15).** Validating a reference when written says nothing about the + world when it is read — anything deletable out from under stored data + eventually will be. Every reader of a long-lived reference must own the + stale case explicitly: skip, mark, or resolve — never index unguarded. + +5. **A file's load path is half its durability contract (rule 16).** Atomic + saves aren't enough. Load must default keys absent from *older* files, + raise loudly on corruption (a silent empty-default is worse than a crash — + the next save persists the loss), and save must create its directory. Test + load against files your current save never writes; the disk remembers + every version you shipped. + +6. **A stored derived edge is signing up to invalidate it (rule 19).** Moving + a cross-entity fact from a read-time join to a stored edge looks like + cleanup, but a `DETACH DELETE` of a changed entity severs edges pointing + *into* it from neighbours that didn't change — staling them silently. + Before caching a cross-entity fact *in* the entity, ask what invalidates + it and whether the thing that changes can reach back to refresh it. If it + can't, keep the derivation cheap and the source durable. + +## How to run it +- One finder per angle, in parallel where you can — recall over precision. +- **Refute each candidate before emitting it** — the elenchus protocol in + [refute.md](refute.md): default to refuted, attack from independent angles, + accept only what survives. +- Fix each survivor red-test-first, like any other feature. + +## See also +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — the green pass these angles + sit *after*; fixes land as new red-first scenarios here. +- [`../background-work/SKILL.md`](../background-work/SKILL.md) — the threading + / lock / readiness angles, split out because they share a setup. +- [`../winnow/SKILL.md`](../winnow/SKILL.md) — the *structural* axis (what to + delete) review-angles deliberately leaves alone; opposite concern. diff --git a/skills/engineering/review-angles/refute.md b/skills/engineering/review-angles/refute.md new file mode 100644 index 0000000..8fa60f0 --- /dev/null +++ b/skills/engineering/review-angles/refute.md @@ -0,0 +1,34 @@ +# Refute before you accept (elenchus) + +The Socratic move: a claim earns acceptance only by *surviving an attempt to +break it*, not by sounding right. Applies to a review finding, a bug +hypothesis, a "this is redundant" call, a passing test — anything you are +about to act on. + +## Protocol +1. **State the claim sharply.** "X is a bug", "this wrapper is dead", "the + suite proves the feature works." A vague claim can't be refuted. +2. **Default to refuted.** The burden is on the claim to survive, not on you + to disprove it. When uncertain, it fails. +3. **Attack from independent angles.** Spawn N skeptics, each trying to + *break* the claim, not confirm it. Diversity beats repetition — give each + a distinct lens (correctness, security, does-it-reproduce, + what-changes-if-it's-wrong) rather than N identical passes. +4. **Survival = a majority fail to refute.** A claim that withstands several + honest attacks from different directions is accepted. One that any angle + breaks is dropped or downgraded. + +## Why default-to-refuted +The opposite default — accept unless disproven — is how plausible-but-wrong +findings survive a review, and how cosmetic changes pass as improvements. +The burden of proof is the whole game: the same inversion the [`sieve`](../sieve/SKILL.md) +uses for keeping vs cutting, pointed at *believing* vs acting. + +## Used by +- [`SKILL.md`](SKILL.md) — refute each review-angle candidate before emitting. +- [`../winnow/SKILL.md`](../winnow/SKILL.md) — refute "it's redundant" before + cutting; the type-checker is one skeptic. +- [`../bdd/SKILL.md`](../bdd/SKILL.md) — rule 13: a green suite is a claim, + not a proof; the post-green pass refutes it. +- [`../sieve/SKILL.md`](../sieve/SKILL.md) — Good-with-receipts refutes the + merely-cosmetic change. diff --git a/skills/engineering/sieve/SKILL.md b/skills/engineering/sieve/SKILL.md new file mode 100644 index 0000000..820355c --- /dev/null +++ b/skills/engineering/sieve/SKILL.md @@ -0,0 +1,85 @@ +--- +name: sieve +description: A Socratic gate that decides whether a change earns its place before you seal it — every line must pass three sieves (Real, Good, Minimal) to enter or to stay. The burden is on keeping, not cutting. Use when the user says "sieve", "/sieve", "should we build this", "is this worth it", "justify keeping this", "Real Good Minimal", "do we need this", before adding a feature/file/dependency, or before pruning one — any decision about whether code deserves to exist. +--- + +# sieve + +## When to use +- User says "sieve", "/sieve", "should we build this at all", "is this + worth it", "justify keeping this", "do we actually need this". +- About to **add** — a feature, file, dependency, abstraction, parameter. +- About to **prune** — and a deletion is being defended ("but it's clearer"). +- A backlog item says "do X properly" — is the current way wrong, or just + cheaper-to-improve? (rule 20) + +## Core principle +**The burden is on keeping, not cutting.** A line does not get to exist by +default and survive review by inertia. To enter — or to stay — it must pass +all three sieves. Fail one, it goes. This is the inversion that keeps the +gate from becoming a rubber stamp: "Good" must *justify* survival, it cannot +merely *excuse* it. + +## The three sieves + +Each surviving line must pass **all three**: + +1. **Real** — *Is the need true?* Does the requirement actually exist, or is + it imagined / speculative / "might need it later"? A speculative + abstraction, a config nobody configures, a flag with one value — fails + Real. Before taking on a "do it properly" change, prove the current way + is actually *wrong*, not merely improvable — that sets the bar the change + must clear (rule 20). + +2. **Good** — *Does it leave the code better than you found it — clearer to + the next reader, sounder in shape — not merely shorter?* This sieve faces + **forward** (adds value), it does not crouch (guard against loss). But + betterment must be **real, not cosmetic**: a change that only makes the + code shorter, or only *looks* tidier, has not passed Good. Name the + concrete thing it improves; if you can't name it, it hasn't. + +3. **Minimal** — *Is this the leanest form that works?* stdlib before custom + code; a native feature before a dependency; an installed dependency + before a new one; one line before fifty. Only then, minimal hand-written + code. + +## Sieve at the boundary, never in the sandbox + +The gate fires **where scratch becomes artifact** — a commit, a pipeline +target, a published report. Inside the sandbox (a REPL, a spike branch, a +`scratch.*` file) generation runs free; pruning exploration early throws +away its option value. Run the sieve at the **seal** step (your `jj +describe`), not per keystroke — otherwise it fights iteration. + +## Modes + +| Context | What the gate guards | +|---|---| +| **Build** | gates *adding*; Good leans forward — it is the sieve that lets *necessary robustness in* (validation, error handling), curing the under-build failure mode of pure YAGNI. | +| **Prune** | gates *keeping*; default-delete, Good must earn each survivor (see [`../winnow/SKILL.md`](../winnow/SKILL.md) for the mechanical cut). | +| **Analysis** | gates the *artifact* (`_targets.R`, the report), never the scratch. Minimal is sharp **and dangerous** here: no type-checker catches a cut that changes a conclusion. Good carries **epistemic** weight — *does removing this change what the analysis concludes?* A kept step names the inference it supports. | + +## Intensity +- **Lite** — collapse to one sieve (*Real?*) for a one-liner; don't tax a + trivial edit with the full ceremony. +- **Full** (default) — all three sieves, balanced. +- **Ultra** — **suspend Good.** Only Real + Minimal run, default-delete, no + "but clarity" reprieve. The aggressive debloat pass when you want it. + +## Guardrails +- **Never** let "Good" pass a change you can't name a concrete improvement + for — that is the cowardice loophole, and it is how debloating dies. +- **Never** sieve the sandbox. Exploration is not bloat. +- **Never** apply Minimal to analysis without the epistemic check — a clean + report is not a true one (the analysis form of "green is not correct"). +- Exceptions that pass Good automatically: input validation, error handling + that prevents data loss, security, accessibility, and explicitly + requested behaviour. Don't simplify these away. + +## See also +- [`../winnow/SKILL.md`](../winnow/SKILL.md) — the mechanical after-the-fact + audit. The sieve judges entry; winnow clears the field. +- [`../../productivity/jj-atomic/SKILL.md`](../../productivity/jj-atomic/SKILL.md) + — the seal where the sieve fires. +- [`../../productivity/grill-with-docs/SKILL.md`](../../productivity/grill-with-docs/SKILL.md) + — Socratic siblings; grill the requirement, then sieve the code. diff --git a/skills/engineering/winnow/SKILL.md b/skills/engineering/winnow/SKILL.md new file mode 100644 index 0000000..a600340 --- /dev/null +++ b/skills/engineering/winnow/SKILL.md @@ -0,0 +1,82 @@ +--- +name: winnow +description: A blunt after-the-fact debloat audit that scans existing code for what can be deleted — reinvented stdlib, needless dependencies, speculative abstractions, dead flexibility — and reports a line-count delta. One-directional: it only ever removes. Use when the user says "winnow", "/winnow", "debloat", "what can we delete", "is this over-engineered", "simplify review", "find what to cut", "over-engineering review", or wants a mechanical pass over a diff or file for removable complexity. +--- + +# winnow + +## When to use +- User says "winnow", "/winnow", "debloat", "what can we delete", "is this + over-engineered", "find what to cut", "simplify review". +- A diff or file is written and working; you want a separate pass that hunts + *only* for removable mass. +- **Not** a judgment gate — that is [`../sieve/SKILL.md`](../sieve/SKILL.md). + Winnow runs *after* the fact and argues *only* for deletion. It blows the + chaff off the grain; it never adds. + +## Core principle +**Only removes, and proves it with a number.** Every finding names something +to cut and its replacement; the audit ends with a line-count delta. A pass +that can't show a negative number found nothing — it's just talk. The +scoreboard is what makes minimalism rationalization-proof. + +## Tags + +One finding per line: + +``` +:: . . +``` + +| tag | finds | +|---|---| +| `delete` | dead code, unused flexibility — no replacement needed | +| `stdlib` | hand-rolled logic the standard library already provides | +| `native` | code/dependency duplicating a platform-native feature | +| `yagni` | abstraction with one implementation, single-caller layer | +| `shrink` | logic reducible to fewer lines with a cleaner pattern | + +Close with: `net: - lines possible.` + +## Over-engineering signals +- A 27-line validator class where a guard clause suffices. +- A framework dependency solving one trivial problem. +- An ABC / Protocol / interface with exactly one concrete implementation. +- A configuration layer nobody configures. +- A retry wrapper around an idempotent local operation. +- A manual loop where a built-in (`map`, `sum`, comprehension) applies. + +## The brake — prove redundant before you cut (rule 18) + +A "redundant" idiom may be **load-bearing**. Every `delete`/`shrink` is the +claim *"this is redundant"* — refute it before you act +([`../review-angles/refute.md`](../review-angles/refute.md)); the type-checker +is one skeptic. A real review flagged a +repeated `tuple(r) for r in conn.execute(...)` wrapper and a +`cast(int | None, line)` as noise. Both were genuine no-ops at *runtime* — +but deleting the wrapper **broke the type-checker**: the raw cursor row +isn't positionally subscriptable, and the wrapper was normalising it. + +So, before emitting any `delete`/`shrink`: +- **Run the type-checker, not just the tests.** Tests stay green when you + remove a type-only crutch; the checker is the one that bites. +- When an idiom turns out load-bearing, **centralise it** (one helper that + normalises once) — don't scatter it back, and don't just revert. The cut + becomes a *consolidation*, still net-negative, still honest. +- A finding whose only payoff is "fewer lines" but which a reader needs for + clarity, or the checker needs for soundness, fails the audit — it was + never chaff. + +## Scope +Winnow ignores **correctness bugs, security, and performance** — those are +[`../review-angles/SKILL.md`](../review-angles/SKILL.md) and `/code-review`. +This pass is *only* structural complexity. Staying single-axis is what keeps +it sharp. + +## See also +- [`../sieve/SKILL.md`](../sieve/SKILL.md) — the judgment gate. Sieve decides + what earns its place; winnow mechanically clears what doesn't. +- [`../bdd/refactoring-r.md`](../bdd/refactoring-r.md) — file the + architectural follow-ups a winnow surfaces; don't auto-cut them mid-pass. +- [`../review-angles/SKILL.md`](../review-angles/SKILL.md) — the correctness + axis winnow deliberately does not touch. diff --git a/skills/productivity/jj-atomic/SKILL.md b/skills/productivity/jj-atomic/SKILL.md index a873ea1..fb48348 100644 --- a/skills/productivity/jj-atomic/SKILL.md +++ b/skills/productivity/jj-atomic/SKILL.md @@ -78,6 +78,12 @@ sealed; without `jj new`, every subsequent edit accumulates into a change with an outdated message. Open a fresh empty `@` immediately so the next concern starts in a clean working copy. +**Run every `jj` mutation in the foreground.** `squash`, `describe`, +`split`, `new` rewrite the working copy; backgrounding one (a detached +`ruff format && jj squash …`) races the working-copy snapshot and the +op aborts. Background only long read-only work (builds, test runs). See +[anti-patterns.md](anti-patterns.md) *"Backgrounding a `jj` mutation"*. + ## Anti-patterns See [anti-patterns.md](anti-patterns.md) — `jj describe` before @@ -91,7 +97,7 @@ working-copy is split into two atomic commits with proper messages. ## See also - [`../../engineering/r-style/SKILL.md`](../../engineering/r-style/SKILL.md) — style refactors are their own atomic change. -- [`../../engineering/tdd-bdd/SKILL.md`](../../engineering/tdd-bdd/SKILL.md) +- [`../../engineering/bdd/SKILL.md`](../../engineering/bdd/SKILL.md) — the regression test for a bug fix lands in the *same* atomic change as the fix. - [`../../engineering/diagnose/SKILL.md`](../../engineering/diagnose/SKILL.md) diff --git a/skills/productivity/jj-atomic/anti-patterns.md b/skills/productivity/jj-atomic/anti-patterns.md index c2c7cf4..28ab139 100644 --- a/skills/productivity/jj-atomic/anti-patterns.md +++ b/skills/productivity/jj-atomic/anti-patterns.md @@ -34,3 +34,14 @@ ship. See SKILL.md §5 *"Docs travel with the code"*. Edits land in the just-described change; its message rots into a lie. Always open a fresh `@` immediately after `jj describe`. See SKILL.md *"Workflow"* step 5. + +## Backgrounding a `jj` mutation + +Running `jj squash` / `describe` / `split` / `new` as a *background* +command (e.g. a chained `ruff format && jj squash …` fired detached) +fails — observed three times in one session, exit 144, the format step +succeeding and the `jj` step dying. A mutating `jj` op snapshots and +rewrites the working copy; backgrounding it races the harness's own +working-copy snapshot and the op aborts. Run every `jj` mutation in the +**foreground**, one at a time. Background is for long read-only work +(builds, test runs), never for sealing a commit. diff --git a/skills/productivity/jj-atomic/examples.md b/skills/productivity/jj-atomic/examples.md index 9c52aa4..e84d809 100644 --- a/skills/productivity/jj-atomic/examples.md +++ b/skills/productivity/jj-atomic/examples.md @@ -50,7 +50,7 @@ Why this works: change will…". - Body bullets are each one concern, each `type(scope): imperative`. - The test ships with the fix (see - [`../../engineering/tdd-bdd/SKILL.md`](../../engineering/tdd-bdd/SKILL.md)). + [`../../engineering/bdd/SKILL.md`](../../engineering/bdd/SKILL.md)). - The docstring update ships with the fix (see [SKILL.md §5](SKILL.md)). diff --git a/skills/scaffold/build-r-analysis/SKILL.md b/skills/scaffold/build-r-analysis/SKILL.md index ee8a1b8..0371880 100644 --- a/skills/scaffold/build-r-analysis/SKILL.md +++ b/skills/scaffold/build-r-analysis/SKILL.md @@ -60,6 +60,6 @@ description: Scaffold a new R analysis project with renv for dependency manageme — workflow auto-detects `_targets.R` → R-analysis loop. - [`../../engineering/r-style/SKILL.md`](../../engineering/r-style/SKILL.md) — every function in `R/functions/` and `R/pipeline/` follows these. -- [`../../engineering/tdd-bdd/SKILL.md`](../../engineering/tdd-bdd/SKILL.md) +- [`../../engineering/bdd/SKILL.md`](../../engineering/bdd/SKILL.md) — `tests/testthat/` opens with the standard `box::use(testthat[...])` - prologue (see `tdd-bdd/tests-r.md`). + prologue (see `bdd/tests-r.md`).