slicewise
The everyday discipline for building one slice at a time in an existing codebase. You write the
code yourself, but every commit unit is objectively verified — a full test gate plus two independent
reviewers reconciled against each other — and the human, not the agent, decides what lands.
한국어 안내는 README.ko.md를 참고하세요.
Principles (non-negotiable)
- No auto-commit. You never run
git commit. You hand the user exact, file-disjoint git
blocks and they run them, on a fresh branch for the current issue. (Only commit yourself if the
user explicitly says "commit it" / "do it".)
- Always dual review. Every commit unit is reviewed by two independent reviewers in parallel,
then reconciled. No risk-based gating — the small unit that "looks trivial" is where the subtle bug
hides. If only one reviewer is available, run it and warn that this invariant is relaxed.
- Tests are the ground truth. A build/compile floor for every unit; the full suite green before
anything lands. Risky changes get real integration tests, not mocks or fakes.
- No scope creep. Only the current issue. Anything outside the plan — extra features, new
dependencies, edits to unrelated files — you ask first.
Checklist (make each a todo)
- Read first, report drift.
- Plan file-disjoint commit units.
- Implement → test gate (per unit).
- Dual review → reconcile (per unit, always).
- Re-verify → commit handoff.
- Doc sync + drift sweep.
- PR / merge unblocking (only if you hit it).
- (cross-cutting) Log reusable troubleshooting the moment you hit it.
Configuration
Read .slicewise.yml (or .json) at the repo root if present; otherwise auto-detect the
toolchain from the ecosystem. See docs/configuration.md for the schema and the detect table. The
keys you care about: build, test, integration, lint, docs (globs to read in Phase 1),
reviewers (the roster for Phase 4), troubleshooting_log, commit_convention. When a key is
absent, detect it (package.json→npm, Cargo.toml→cargo, go.mod→go test, pom.xml/build.gradle→mvn/gradle,
pyproject.toml→pytest, Makefile→make) and state what you detected so the user can correct you.
Phase 1 — Read first, report drift (before any code)
- Read the configured
docs globs (default: docs/**, **/*.md, plus any OpenAPI/schema/ADR files),
the related code, and any design notes for this slice. Understand the contract before touching it.
- Drift detection is a first-class deliverable. If two docs disagree, or a doc contradicts the
code (a spec that no longer matches the schema, a data model that drifted from the migration), you
report it and get a decision before writing code. Silently "fixing" it the wrong way is the
classic trap.
- State scope in one line: what you will build, and what is explicitly out of scope.
Phase 2 — Plan file-disjoint commit units
- Split the work into small units whose file sets do not overlap (e.g. infra/port · domain logic ·
docs). If one file is touched by two units, merge them into one unit.
- For genuinely hard logic (auth/social login, pairing, IoT, RAG, aggregation, external integrations),
lay down the skeleton with
// TODO(impl) markers and fill it in deliberately — don't fake it.
Phase 3 — Implement → test gate (per unit)
- Write it yourself, matching the surrounding style. Cross-context references go by ID; external
systems go through a port/adapter, not a direct call.
- Run the build/compile floor (
build command). It must pass — that's the floor, not the goal.
- For risky changes, add real integration tests, not mocks: raw SQL / complex queries, JSONB or
document mapping, concurrency and locking, migrations, money, auth/authorization, anything with a
data-loss or ownership-boundary failure mode. Assert hard — exercise boundary values, ownership
checks, time/ordering — so a false green can't sneak through.
- Before the unit is final, run the full
test suite and confirm it is green (failures = 0).
Phase 4 — Dual review → reconcile (per unit, always)
Dispatch the reviewer roster in parallel, in one message. All reviewers are read-only (they
report; they never edit). The zero-config default roster is the bundled code-reviewer agent run
twice with different lenses:
- Lens A — correctness, security, concurrency / data-safety.
- Lens B — simplicity / DRY, project conventions, test adequacy.
For cross-model diversity, set reviewers: ["codex", "code-reviewer"] in config to use one Codex
reviewer (via the codex plugin, if installed) plus one Claude reviewer. If a configured reviewer
isn't available, degrade to single and warn that the always-dual-review invariant is relaxed.
Shared prompt template (same for every reviewer, only the lens differs):
- Target: the
git diff of the working tree + the list of changed/new file paths + a couple of
reference files showing the pattern to match.
- Design context: state the decisions that are already settled, so reviewers check consistency,
bugs, and security within that design instead of re-litigating the architecture.
- Output contract: prioritized findings — 🔴 must-fix / 🟡 should-fix / 🟢 nit — each with
file:line and a concrete fix. Explicit instruction: "If it's sound, say it's sound. Do not
fabricate issues."
- Scrutiny points: data loss, JSONB/serialization mapping, IDOR / authorization, concurrency
TOCTOU, migration safety, test adequacy, doc↔code consistency.
Reconcile (this step is the whole point). Compare the two reports; don't just concatenate them.
See docs/reconcile-rubric.md for the full decision table. In short:
- 🔴 → verify it's real, then apply, then prove the fix with a new test. If the two reviewers
disagree, resolve by evidence, not by vote.
- Over-engineering / speculative asks → reject with a stated reason (name the rejection as
explicitly as the adoption). "Deterministic key, so a per-segment HEAD check is unnecessary — rejected."
- Every adopted fix is reflected in code and proven by a test that would fail without it.
Phase 5 — Re-verify → commit handoff
Phase 6 — Doc sync + drift sweep
- If behavior or a contract changed, update the docs it touched (endpoint schemas, error cases,
status, ER diagrams, counts/summaries).
- Sweep the mirrors: when you change one field/column,
grep for its old name across every doc
and generated artifact (overview docs, exported schema JSON, SVG diagrams) so no straggler survives.
Mark generated artifacts (SVGs, etc.) for regeneration. Historical changelog lines are history —
leave them.
Phase 7 — PR / merge unblocking (only if you hit it)
- Classify the blocker:
gh pr view <n> --json mergeable,mergeStateStatus,reviewDecision →
CONFLICTING (conflicts) / UNSTABLE or BLOCKED (checks) / review.
- For conflicts: merge
origin/<base> in, resolve only the conflicts (union / consistency),
confirm zero markers, and get the whole merge tree green before handing off the push.
- For count/summary conflicts, recompute from the underlying groups and reconcile to the true number.
Cross-cutting — Troubleshooting log
When you hit a real troubleshooting trap (build, test, runtime, or a design pitfall), append it to the
configured troubleshooting_log (default TROUBLESHOOTING.md). Create it if missing; append to the
bottom if it exists — never a fresh file each time. Format each entry as: a one-line title (date +
feature/branch), then Cause / Resulting problem / Fix / Alternatives considered. Record only
reusable traps, not one-off typos — this is an accumulating asset so the next person doesn't hit the
same wall.
Tooling notes
- Reviewers see uncommitted work via
git diff (assume a clean baseline before the unit).
- Codex unavailable → single Claude reviewer + a stated note that the full-review invariant is broken.
build/test/lint and gh run via Bash. Prefer the repo's own scripts over ad-hoc commands.
- If a decision won't show up in a later code scan (a design fork, a rejection rationale, a schema
switch), write it down where the project keeps such notes so it isn't lost.
1---2name: slicewise3description: A disciplined loop for implementing, fixing, refactoring, or unblocking a single feature or slice in an existing codebase. Reads the relevant docs/specs first and reports drift before coding, splits work into small file-disjoint commit units, and for each unit runs a build/test gate then dispatches two independent reviewers in parallel and reconciles their findings before handing off a commit you run yourself (it never auto-commits). Use when the user says things like "implement this feature", "add this API", "fix this bug", "refactor this", "finish this slice", or "this PR/merge is stuck". Not for one-line typo fixes (answer directly), and not for the initial mass-scaffold of an entire API layer (use a fan-out authoring harness instead).4---56# slicewise78The everyday discipline for building **one slice at a time** in an existing codebase. You write the9code yourself, but every commit unit is objectively verified — a full test gate plus two independent10reviewers reconciled against each other — and the human, not the agent, decides what lands.1112한국어 안내는 [README.ko.md](https://github.com/pjw81226/slicewise/blob/main/README.ko.md)를 참고하세요.1314## Principles (non-negotiable)15161. **No auto-commit.** You never run `git commit`. You hand the user exact, file-disjoint `git`17 blocks and they run them, on a **fresh branch** for the current issue. (Only commit yourself if the18 user explicitly says "commit it" / "do it".)192. **Always dual review.** Every commit unit is reviewed by **two independent reviewers in parallel**,20 then reconciled. No risk-based gating — the small unit that "looks trivial" is where the subtle bug21 hides. If only one reviewer is available, run it and **warn** that this invariant is relaxed.223. **Tests are the ground truth.** A build/compile floor for every unit; the full suite green before23 anything lands. Risky changes get **real integration tests, not mocks or fakes**.244. **No scope creep.** Only the current issue. Anything outside the plan — extra features, new25 dependencies, edits to unrelated files — you **ask first**.2627## Checklist (make each a todo)28291. Read first, report drift.302. Plan file-disjoint commit units.313. Implement → test gate (per unit).324. Dual review → reconcile (per unit, always).335. Re-verify → commit handoff.346. Doc sync + drift sweep.357. PR / merge unblocking (only if you hit it).36- (cross-cutting) Log reusable troubleshooting the moment you hit it.3738## Configuration3940Read `.slicewise.yml` (or `.json`) at the repo root if present; otherwise **auto-detect** the41toolchain from the ecosystem. See `docs/configuration.md` for the schema and the detect table. The42keys you care about: `build`, `test`, `integration`, `lint`, `docs` (globs to read in Phase 1),43`reviewers` (the roster for Phase 4), `troubleshooting_log`, `commit_convention`. When a key is44absent, detect it (package.json→npm, Cargo.toml→cargo, go.mod→go test, pom.xml/build.gradle→mvn/gradle,45pyproject.toml→pytest, Makefile→make) and **state what you detected** so the user can correct you.4647## Phase 1 — Read first, report drift (before any code)4849- Read the configured `docs` globs (default: `docs/**`, `**/*.md`, plus any OpenAPI/schema/ADR files),50 the related code, and any design notes for this slice. Understand the contract before touching it.51- **Drift detection is a first-class deliverable.** If two docs disagree, or a doc contradicts the52 code (a spec that no longer matches the schema, a data model that drifted from the migration), you53 **report it and get a decision before writing code.** Silently "fixing" it the wrong way is the54 classic trap.55- State scope in one line: what you will build, and what is explicitly out of scope.5657## Phase 2 — Plan file-disjoint commit units5859- Split the work into small units whose file sets **do not overlap** (e.g. infra/port · domain logic ·60 docs). If one file is touched by two units, merge them into one unit.61- For genuinely hard logic (auth/social login, pairing, IoT, RAG, aggregation, external integrations),62 lay down the skeleton with `// TODO(impl)` markers and fill it in deliberately — don't fake it.6364## Phase 3 — Implement → test gate (per unit)6566- Write it yourself, matching the surrounding style. Cross-context references go by ID; external67 systems go through a port/adapter, not a direct call.68- Run the **build/compile floor** (`build` command). It must pass — that's the floor, not the goal.69- For **risky changes**, add real integration tests, not mocks: raw SQL / complex queries, JSONB or70 document mapping, concurrency and locking, migrations, money, auth/authorization, anything with a71 data-loss or ownership-boundary failure mode. Assert hard — exercise boundary values, ownership72 checks, time/ordering — so a false green can't sneak through.73- Before the unit is final, run the **full `test` suite** and confirm it is green (failures = 0).7475## Phase 4 — Dual review → reconcile (per unit, always)7677**Dispatch the reviewer roster in parallel, in one message.** All reviewers are **read-only** (they78report; they never edit). The zero-config default roster is the bundled `code-reviewer` agent run79**twice with different lenses**:80- **Lens A** — correctness, security, concurrency / data-safety.81- **Lens B** — simplicity / DRY, project conventions, test adequacy.8283For cross-model diversity, set `reviewers: ["codex", "code-reviewer"]` in config to use one Codex84reviewer (via the `codex` plugin, if installed) plus one Claude reviewer. If a configured reviewer85isn't available, degrade to single and **warn** that the always-dual-review invariant is relaxed.8687Shared prompt template (same for every reviewer, only the lens differs):88- **Target:** the `git diff` of the working tree + the list of changed/new file paths + a couple of89 reference files showing the pattern to match.90- **Design context:** state the decisions that are already settled, so reviewers check *consistency,91 bugs, and security within that design* instead of re-litigating the architecture.92- **Output contract:** prioritized findings — 🔴 must-fix / 🟡 should-fix / 🟢 nit — each with93 `file:line` and a concrete fix. Explicit instruction: *"If it's sound, say it's sound. Do not94 fabricate issues."*95- **Scrutiny points:** data loss, JSONB/serialization mapping, IDOR / authorization, concurrency96 TOCTOU, migration safety, test adequacy, doc↔code consistency.9798**Reconcile (this step is the whole point).** Compare the two reports; don't just concatenate them.99See `docs/reconcile-rubric.md` for the full decision table. In short:100- 🔴 → **verify it's real, then apply, then prove the fix with a new test.** If the two reviewers101 disagree, resolve by evidence, not by vote.102- Over-engineering / speculative asks → **reject with a stated reason** (name the rejection as103 explicitly as the adoption). "Deterministic key, so a per-segment HEAD check is unnecessary — rejected."104- Every adopted fix is reflected in code **and** proven by a test that would fail without it.105106## Phase 5 — Re-verify → commit handoff107108- After applying reconciled fixes, run the `test` suite again — green.109- **Do not commit.** Present numbered, **file-disjoint** blocks:110 ```111 git add <exact paths for this unit>112 git commit -m "<conventional subject>" -m "<body>"113 ```114 Add a trailer (sign-off, issue ref, co-author) only if the project already uses one. The user runs115 the blocks. If they say "do it", then you run them.116117## Phase 6 — Doc sync + drift sweep118119- If behavior or a contract changed, update the docs it touched (endpoint schemas, error cases,120 status, ER diagrams, counts/summaries).121- **Sweep the mirrors:** when you change one field/column, `grep` for its old name across every doc122 and generated artifact (overview docs, exported schema JSON, SVG diagrams) so no straggler survives.123 Mark generated artifacts (SVGs, etc.) for regeneration. Historical changelog lines are history —124 leave them.125126## Phase 7 — PR / merge unblocking (only if you hit it)127128- Classify the blocker: `gh pr view <n> --json mergeable,mergeStateStatus,reviewDecision` →129 CONFLICTING (conflicts) / UNSTABLE or BLOCKED (checks) / review.130- For conflicts: merge `origin/<base>` in, resolve **only** the conflicts (union / consistency),131 confirm zero markers, and get the **whole merge tree green** before handing off the push.132- For count/summary conflicts, recompute from the underlying groups and reconcile to the true number.133134## Cross-cutting — Troubleshooting log135136When you hit a real troubleshooting trap (build, test, runtime, or a design pitfall), append it to the137configured `troubleshooting_log` (default `TROUBLESHOOTING.md`). **Create it if missing; append to the138bottom if it exists — never a fresh file each time.** Format each entry as: a one-line title (date +139feature/branch), then **Cause / Resulting problem / Fix / Alternatives considered**. Record only140reusable traps, not one-off typos — this is an accumulating asset so the next person doesn't hit the141same wall.142143## Tooling notes144145- Reviewers see uncommitted work via `git diff` (assume a clean baseline before the unit).146- Codex unavailable → single Claude reviewer + a stated note that the full-review invariant is broken.147- `build`/`test`/`lint` and `gh` run via Bash. Prefer the repo's own scripts over ad-hoc commands.148- If a decision won't show up in a later code scan (a design fork, a rejection rationale, a schema149 switch), write it down where the project keeps such notes so it isn't lost.