@whamp/pi-pstack 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -0
- package/agents/comment-sicko.md +34 -0
- package/agents/poteto-agent.md +13 -0
- package/extensions/pstack/ask-user-question.ts +137 -0
- package/extensions/pstack/config.ts +55 -0
- package/extensions/pstack/index.ts +330 -0
- package/extensions/pstack/pstack-config-status.ts +72 -0
- package/extensions/pstack/pstack-role-config-store.ts +287 -0
- package/extensions/pstack/pstack-role-config.ts +496 -0
- package/extensions/pstack/pstack-role-prompt.ts +33 -0
- package/extensions/pstack/pstack-roles.ts +252 -0
- package/extensions/pstack/pstack-setup-plan.ts +223 -0
- package/extensions/pstack/skill-strip.ts +62 -0
- package/package.json +60 -0
- package/skills/architect/SKILL.md +83 -0
- package/skills/architect/references/design-red-flags.md +33 -0
- package/skills/architect/references/rationale-template.md +35 -0
- package/skills/architect/references/runner-prompt.md +20 -0
- package/skills/arena/SKILL.md +71 -0
- package/skills/automate-me/SKILL.md +104 -0
- package/skills/blast-radius/SKILL.md +50 -0
- package/skills/bro/SKILL.md +7 -0
- package/skills/create-verification-skill/SKILL.md +44 -0
- package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/skills/deslop/SKILL.md +23 -0
- package/skills/figure-it-out/SKILL.md +53 -0
- package/skills/how/SKILL.md +52 -0
- package/skills/how/references/explainer-prompt.md +55 -0
- package/skills/how/references/explorer-prompt.md +52 -0
- package/skills/interrogate/SKILL.md +111 -0
- package/skills/interrogate/references/code-quality-review.md +47 -0
- package/skills/interrogate/references/lead-judgment.md +58 -0
- package/skills/interrogate/references/reviewer-prompt.md +72 -0
- package/skills/interrogate/references/rubric.md +77 -0
- package/skills/maintain-verification-skill/SKILL.md +39 -0
- package/skills/no-comments/SKILL.md +24 -0
- package/skills/poteto-mode/SKILL.md +147 -0
- package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-full.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-stack.md +16 -0
- package/skills/poteto-mode/playbooks/babysit.md +27 -0
- package/skills/poteto-mode/playbooks/bug-fix.md +17 -0
- package/skills/poteto-mode/playbooks/eval.md +25 -0
- package/skills/poteto-mode/playbooks/feature.md +21 -0
- package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
- package/skills/poteto-mode/playbooks/investigation.md +14 -0
- package/skills/poteto-mode/playbooks/multi-phase-plan.md +156 -0
- package/skills/poteto-mode/playbooks/opening-a-pr.md +33 -0
- package/skills/poteto-mode/playbooks/orchestrate.md +199 -0
- package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
- package/skills/poteto-mode/playbooks/perf-issue.md +24 -0
- package/skills/poteto-mode/playbooks/prototype.md +14 -0
- package/skills/poteto-mode/playbooks/refactoring.md +16 -0
- package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/skills/poteto-mode/playbooks/session-pickup.md +11 -0
- package/skills/poteto-mode/playbooks/shipping.md +17 -0
- package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
- package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
- package/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -0
- package/skills/poteto-mode/references/bugbot-triage.md +142 -0
- package/skills/poteto-mode/scripts/bootstrap.ts +62 -0
- package/skills/poteto-mode/scripts/bun.lock +67 -0
- package/skills/poteto-mode/scripts/check-plan.mjs +186 -0
- package/skills/poteto-mode/scripts/check-plan.test.mjs +25 -0
- package/skills/poteto-mode/scripts/orch/orch.test.ts +634 -0
- package/skills/poteto-mode/scripts/orch/orch.ts +578 -0
- package/skills/poteto-mode/scripts/orch/store.ts +1607 -0
- package/skills/poteto-mode/scripts/package.json +16 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
- package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +118 -0
- package/skills/poteto-mode/scripts/watch-pr/github.test.ts +306 -0
- package/skills/poteto-mode/scripts/watch-pr/github.ts +699 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +420 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.ts +832 -0
- package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
- package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
- package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
- package/skills/poteto-mode/scripts/watch-pr/types.ts +401 -0
- package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
- package/skills/poteto-mode/scripts/worktree-audit.sh +85 -0
- package/skills/principle-attack-the-premise/SKILL.md +23 -0
- package/skills/principle-boundary-discipline/SKILL.md +34 -0
- package/skills/principle-build-the-lever/SKILL.md +23 -0
- package/skills/principle-encode-lessons-in-structure/SKILL.md +31 -0
- package/skills/principle-exhaust-the-design-space/SKILL.md +21 -0
- package/skills/principle-experience-first/SKILL.md +19 -0
- package/skills/principle-fix-root-causes/SKILL.md +23 -0
- package/skills/principle-foundational-thinking/SKILL.md +21 -0
- package/skills/principle-guard-the-context-window/SKILL.md +17 -0
- package/skills/principle-laziness-protocol/SKILL.md +18 -0
- package/skills/principle-make-operations-idempotent/SKILL.md +24 -0
- package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +22 -0
- package/skills/principle-minimize-reader-load/SKILL.md +23 -0
- package/skills/principle-model-the-domain/SKILL.md +26 -0
- package/skills/principle-never-block-on-the-human/SKILL.md +22 -0
- package/skills/principle-outcome-oriented-execution/SKILL.md +22 -0
- package/skills/principle-prove-it-works/SKILL.md +33 -0
- package/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
- package/skills/principle-separate-before-serializing-shared-state/SKILL.md +16 -0
- package/skills/principle-sequence-verifiable-units/SKILL.md +22 -0
- package/skills/principle-subtract-before-you-add/SKILL.md +21 -0
- package/skills/principle-test-behavior-not-implementation/SKILL.md +25 -0
- package/skills/principle-type-system-discipline/SKILL.md +31 -0
- package/skills/recall/SKILL.md +35 -0
- package/skills/reflect/SKILL.md +73 -0
- package/skills/reflect/references/divergent-reviewer.md +43 -0
- package/skills/reflect/references/judgment-reviewer.md +42 -0
- package/skills/reflect/references/synthesizer.md +56 -0
- package/skills/reflect/references/tooling-reviewer.md +55 -0
- package/skills/setup-pstack/SKILL.md +38 -0
- package/skills/setup-pstack/references/MODEL-ROLES.md +35 -0
- package/skills/show-me-your-work/SKILL.md +82 -0
- package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/skills/show-me-your-work/scripts/log.sh +40 -0
- package/skills/swarm/SKILL.md +46 -0
- package/skills/tdd/SKILL.md +44 -0
- package/skills/teach/SKILL.md +21 -0
- package/skills/technical-writing/SKILL.md +127 -0
- package/skills/typescript-best-practices/SKILL.md +29 -0
- package/skills/typescript-best-practices/references/patterns.md +313 -0
- package/skills/unslop/SKILL.md +67 -0
- package/skills/why/SKILL.md +154 -0
- package/skills/why/references/epistemics.md +144 -0
- package/skills/why/references/investigator-prompt.md +103 -0
- package/skills/why/references/source-playbook.md +17 -0
- package/skills/why/references/sources/code-archaeology.md +88 -0
- package/skills/why/references/sources/databricks.md +70 -0
- package/skills/why/references/sources/datadog.md +99 -0
- package/skills/why/references/sources/incident-postmortem.md +15 -0
- package/skills/why/references/sources/linear.md +48 -0
- package/skills/why/references/sources/notion.md +55 -0
- package/skills/why/references/sources/sentry.md +100 -0
- package/skills/why/references/sources/slack.md +54 -0
- package/skills/why/references/synthesizer-prompt.md +135 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Read-only worktree prune audit. Classifies every git worktree by size, merge
|
|
3
|
+
# state, uncommitted work, remote/PR state, and the most recent chat that
|
|
4
|
+
# operated in it. Emits a table sorted by size with a suggested bucket. Never
|
|
5
|
+
# deletes anything; deletion stays a human-gated step in the playbook.
|
|
6
|
+
#
|
|
7
|
+
# Usage: worktree-audit.sh [repo-path] (defaults to the current repo)
|
|
8
|
+
set -u
|
|
9
|
+
|
|
10
|
+
repo="${1:-$(git rev-parse --show-toplevel 2>/dev/null)}"
|
|
11
|
+
[ -z "$repo" ] && { echo "not in a git repo; pass a repo path" >&2; exit 1; }
|
|
12
|
+
cd "$repo" || exit 1
|
|
13
|
+
|
|
14
|
+
# Main worktree is the first entry; everything else is a candidate.
|
|
15
|
+
main_wt=$(git worktree list --porcelain | awk '/^worktree /{print $2; exit}')
|
|
16
|
+
|
|
17
|
+
# origin/main drives the merge check. Best-effort; stale is fine for a first pass.
|
|
18
|
+
git fetch origin main --quiet 2>/dev/null || echo "warn: could not fetch origin/main; merged column may be stale" >&2
|
|
19
|
+
|
|
20
|
+
# PR state by branch, fetched once. Empty if gh is unavailable.
|
|
21
|
+
prs=$(mktemp)
|
|
22
|
+
gh pr list --author "@me" --state all --limit 1000 \
|
|
23
|
+
--json number,state,headRefName 2>/dev/null > "$prs" || echo "[]" > "$prs"
|
|
24
|
+
|
|
25
|
+
# Transcripts dir: ~/.pi/agent/sessions (JSONL, one file per session).
|
|
26
|
+
transcripts="$HOME/.pi/agent/sessions"
|
|
27
|
+
now=$(date +%s)
|
|
28
|
+
|
|
29
|
+
printf "SIZE\tAGE\tMERGED\tDIRTY\tREMOTE\tPR\tLAST_CHAT\tBUCKET\tWORKTREE\n"
|
|
30
|
+
|
|
31
|
+
git worktree list --porcelain | awk '/^worktree /{print $2}' | while read -r wt; do
|
|
32
|
+
[ "$wt" = "$main_wt" ] && continue
|
|
33
|
+
|
|
34
|
+
size=$(du -sh "$wt" 2>/dev/null | awk '{print $1}')
|
|
35
|
+
head=$(git -C "$wt" rev-parse HEAD 2>/dev/null)
|
|
36
|
+
head_ts=$(git -C "$wt" log -1 --format='%ct' HEAD 2>/dev/null || echo 0)
|
|
37
|
+
age=$([ "$head_ts" -gt 0 ] 2>/dev/null && echo "$(( (now - head_ts) / 86400 ))d" || echo "?")
|
|
38
|
+
|
|
39
|
+
# Squash-merged branches are not ancestors of main, so PR state is the
|
|
40
|
+
# real signal; merge-base only catches fast-forward/rebase merges.
|
|
41
|
+
git merge-base --is-ancestor "$head" origin/main 2>/dev/null && merged=YES || merged=no
|
|
42
|
+
|
|
43
|
+
# Distinguish real WIP (tracked edits) from disposable untracked scratch.
|
|
44
|
+
porcelain=$(git -C "$wt" status --porcelain 2>/dev/null)
|
|
45
|
+
if [ -z "$porcelain" ]; then dirty=clean
|
|
46
|
+
elif printf '%s\n' "$porcelain" | grep -qv '^??'; then
|
|
47
|
+
dirty="wip:$(printf '%s\n' "$porcelain" | grep -cv '^??')"
|
|
48
|
+
else dirty="scratch:$(printf '%s\n' "$porcelain" | grep -c '^??')"; fi
|
|
49
|
+
|
|
50
|
+
branch=$(git -C "$wt" symbolic-ref --quiet --short HEAD 2>/dev/null || echo "")
|
|
51
|
+
if [ -z "$branch" ]; then remote=detached
|
|
52
|
+
elif git -C "$wt" show-ref --verify --quiet "refs/remotes/origin/$branch"; then
|
|
53
|
+
[ "$(git -C "$wt" rev-parse "origin/$branch" 2>/dev/null)" = "$head" ] \
|
|
54
|
+
&& remote=pushed \
|
|
55
|
+
|| remote="ahead$(git -C "$wt" rev-list --count "origin/$branch..HEAD" 2>/dev/null)"
|
|
56
|
+
else remote=no-remote; fi
|
|
57
|
+
|
|
58
|
+
pr=$([ -n "$branch" ] && jq -r --arg b "$branch" \
|
|
59
|
+
'.[] | select(.headRefName==$b) | "#\(.number)/\(.state)"' "$prs" 2>/dev/null | head -1)
|
|
60
|
+
[ -z "$pr" ] && pr="-"
|
|
61
|
+
|
|
62
|
+
# Most recent chat whose transcript operated in this worktree. Match path
|
|
63
|
+
# followed by "/" or a quote so glint-482 does not match glint-482-r37.
|
|
64
|
+
last="-"; last_ts=0
|
|
65
|
+
if [ -d "$transcripts" ]; then
|
|
66
|
+
f=$(rg -l -e "${wt}/" -e "${wt}\"" "$transcripts" 2>/dev/null \
|
|
67
|
+
| xargs stat -f '%m %N' 2>/dev/null | sort -rn | head -1)
|
|
68
|
+
if [ -n "$f" ]; then last_ts=$(echo "$f" | awk '{print $1}')
|
|
69
|
+
last=$(date -r "$last_ts" '+%Y-%m-%d' 2>/dev/null); fi
|
|
70
|
+
fi
|
|
71
|
+
recent=$([ "$last_ts" -gt 0 ] 2>/dev/null && [ $(( (now - last_ts) / 86400 )) -le 4 ] && echo yes || echo no)
|
|
72
|
+
|
|
73
|
+
case "$dirty" in wip:*) bucket=hold-wip ;; *)
|
|
74
|
+
case "$pr" in *OPEN*) bucket=hold-open-pr ;; *)
|
|
75
|
+
if [ "$recent" = yes ]; then bucket=verify-recent-chat
|
|
76
|
+
elif [ "$merged" = YES ] || [ "$pr" != "-" ]; then bucket=safe
|
|
77
|
+
else bucket=review; fi ;;
|
|
78
|
+
esac ;;
|
|
79
|
+
esac
|
|
80
|
+
|
|
81
|
+
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" \
|
|
82
|
+
"$size" "$age" "$merged" "$dirty" "$remote" "$pr" "$last" "$bucket" "$wt"
|
|
83
|
+
done | sort -t$'\t' -k1,1 -rh
|
|
84
|
+
|
|
85
|
+
rm -f "$prs"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-attack-the-premise
|
|
3
|
+
description: "Apply when two or more fixes that share one premise have failed the same gate. Take a census of which actors hold the imbalance before the next fix, then question the premise instead of writing another fix that assumes it."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Attack the Premise
|
|
8
|
+
|
|
9
|
+
When two or more fixes that share one premise have failed the same gate, suspect the premise, not the fixes.
|
|
10
|
+
|
|
11
|
+
**Why:** Each failure under a shared premise is evidence about the premise.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
- **Write the premise down.** The premise is the one sentence that every failed fix assumed.
|
|
15
|
+
- **Take a census before the next fix.** Count the imbalance per actor. The census shows which actors hold the imbalance, not how large it is. Write the census as a rerunnable script per [Build the Lever](../principle-build-the-lever/SKILL.md).
|
|
16
|
+
- **Read the skew.** If the same few actors hold most of the imbalance on every run, something assigns them that role. Find what assigns the role. That assignment is the next "why" per [Fix Root Causes](../principle-fix-root-causes/SKILL.md).
|
|
17
|
+
- **Remove the asymmetry instead of compensating for it**, per the [Laziness Protocol](../principle-laziness-protocol/SKILL.md). Rotate the role between actors, randomize the assignment, or move the role, so that no actor holds it on every run. A return path, a shared pool, a batched hand-off, or a periodic rebalance leaves the assignment in place and adds work on every run.
|
|
18
|
+
|
|
19
|
+
**Stop:**
|
|
20
|
+
- Do not start the next fix before the premise is written down and the census exists.
|
|
21
|
+
- If the census is even across actors, the premise is not the cause. Look for the cause elsewhere and keep the census as evidence.
|
|
22
|
+
|
|
23
|
+
This principle is distinct from [Redesign from First Principles](../principle-redesign-from-first-principles/SKILL.md), which rebuilds a design around a new requirement. It questions a fact the current design assumes.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-boundary-discipline
|
|
3
|
+
description: "Apply when wiring validation, error handling, or framework adapters. Concentrate guards at system boundaries (CLI, config, network, external APIs); trust internal types and keep business logic in pure functions."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Boundary Discipline
|
|
8
|
+
|
|
9
|
+
Place validation, type narrowing, and error handling at system boundaries. Trust internal code unconditionally. Business logic lives in pure functions. The shell is thin and mechanical.
|
|
10
|
+
|
|
11
|
+
**Why:** Scattered validation is noisy, redundant, and gives a false sense of safety. Keep logic out of framework wiring so it can be tested without the framework.
|
|
12
|
+
|
|
13
|
+
**The pattern:**
|
|
14
|
+
- **At boundaries** (CLI args, config files, external APIs, network protocols): validate, return errors, handle defensively.
|
|
15
|
+
- **Inside the system:** typed data, error propagation, no re-validation. Trust the types.
|
|
16
|
+
- **Across the boundary.** Expose domain concepts, not the boundary's private representation. Keep general-purpose mechanism inside and special-purpose policy at the edge.
|
|
17
|
+
|
|
18
|
+
**Applications:**
|
|
19
|
+
|
|
20
|
+
Validation and error handling:
|
|
21
|
+
- Validate config at parse time (the boundary), not inside business logic
|
|
22
|
+
- Parse raw data into domain types at the boundary
|
|
23
|
+
- Do not re-export transport, storage, framework, or wire types through the public surface
|
|
24
|
+
- No redundant nil checks deep in call chains if the boundary already validated
|
|
25
|
+
|
|
26
|
+
Code organization:
|
|
27
|
+
- Business logic in pure functions with no framework dependencies
|
|
28
|
+
- Parse functions: pure transforms from raw bytes to typed state
|
|
29
|
+
- Prompt construction: structured state in, string out
|
|
30
|
+
- Scoring and assessment: pure transforms from state to results
|
|
31
|
+
|
|
32
|
+
**The tests:**
|
|
33
|
+
- "Is this data crossing a system boundary right now?" If not, validation is redundant.
|
|
34
|
+
- "Can this be a pure function that the shell just calls?" If yes, extract it.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-build-the-lever
|
|
3
|
+
description: "Apply to any non-trivial work, not just bulk work: edits, migrations, analyses, checks. Build the tool that does it or proves it (codemod, script, generator, or a skill your subagents follow) instead of working by hand. The tool is the artifact a reviewer can rerun."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
# Build the Lever
|
|
7
|
+
|
|
8
|
+
When the work isn't trivial, build the tool that does it instead of doing it by hand.
|
|
9
|
+
|
|
10
|
+
**Why:** Two payoffs. Throughput: a codemod, generator, or script does the work the same way every time and reruns for free. Confidence: the tool is one artifact a reviewer can read and rerun to check the work. Hand-done changes can only be re-verified by redoing them. A deterministic script turns "trust me" into "run this".
|
|
11
|
+
|
|
12
|
+
**Pattern:** Default to building the lever. Skip it only when the task is trivial, a couple of obvious edits you can see at a glance.
|
|
13
|
+
|
|
14
|
+
- Do the first unit by hand to learn the recipe, then build the tool. Prove it by rerunning it on that unit and diffing against your hand-done version. Make the lever safe to rerun.
|
|
15
|
+
- Codemod or script for edits, generator for repetitive files, a dump-to-sqlite query for analysis, a rerunnable check for verification.
|
|
16
|
+
- A deterministic lever beats fan-out. If the tool can process every unit in one pass, run it yourself. Don't fan out delegates to hand-apply what a script can do.
|
|
17
|
+
- When you fan work out to subagents, write the lever as a skill they all read: the recipe, the verification contract, and the do-not-touch fences in one artifact. Keep it outside the delegates' write scope so they can't quietly edit the contract.
|
|
18
|
+
- Applying this principle produces a file. If you cited it and there is no codemod, script, generator, or delegate skill in the diff, you didn't apply it.
|
|
19
|
+
- Commit the lever when the work outlives the session.
|
|
20
|
+
|
|
21
|
+
**Balance:** The bar is triviality, not repetition. A one-off still earns a lever when the lever is what makes the work checkable. Per the [Laziness Protocol](../principle-laziness-protocol/SKILL.md), build the smallest script that does or proves the job, never a framework.
|
|
22
|
+
|
|
23
|
+
Distinct from [Encode Lessons in Structure](../principle-encode-lessons-in-structure/SKILL.md), which makes a recurring instruction a durable guardrail. This is throughput and reviewability on the work in front of you. For scripting the verification itself, see [Prove It Works](../principle-prove-it-works/SKILL.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-encode-lessons-in-structure
|
|
3
|
+
description: "Apply when you catch yourself writing the same instruction a second time, or notice a recurring correction. Encode the rule as a lint, metadata flag, runtime check, or script instead of more text."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Encode Lessons in Structure
|
|
8
|
+
|
|
9
|
+
Encode recurring fixes in mechanisms (tools, code, metadata, automation) instead of textual instructions. Every error, human correction, and unexpected outcome is a learning signal. Capture it, route it, and close the loop.
|
|
10
|
+
|
|
11
|
+
**Why:** Textual instructions are easy to miss. They require the reader to notice, remember, and comply. Structural mechanisms (lint rules, metadata flags, runtime checks, automation scripts) enforce the rule without cooperation.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
When you catch yourself writing the same instruction a second time:
|
|
15
|
+
1. Ask: can this be a lint rule, a metadata flag, a runtime check, or a script?
|
|
16
|
+
2. If yes, encode it. Delete the instruction
|
|
17
|
+
3. If no (requires judgment), make the instruction more prominent and add an example of the failure mode
|
|
18
|
+
|
|
19
|
+
**Pick the strongest mechanism.** When more than one mechanism would work, choose the strongest the situation allows (an unrepresentable state that cannot compile, then a lint or banned API that fails CI, then a canonical helper, then a runtime check), because agents copy whatever the surrounding code already does and a weaker guard becomes the next template.
|
|
20
|
+
|
|
21
|
+
**Corollary:** If the fix is structural, only use the structural fix. The instruction is the symptom.
|
|
22
|
+
|
|
23
|
+
**Feedback loop:**
|
|
24
|
+
- **Capture every correction.** When the human intervenes or tests fail, decide if it's a one-off or a pattern.
|
|
25
|
+
- **Route to the right layer.** One-off -> brain note. Recurring fix -> skill or lint rule. Systemic issue -> principle.
|
|
26
|
+
- **Close the loop.** Don't just record. Apply now or create a concrete todo.
|
|
27
|
+
|
|
28
|
+
**Anti-patterns:**
|
|
29
|
+
- Acknowledging without recording ("I'll keep that in mind" does not persist)
|
|
30
|
+
- Recording without routing (a brain note about a lint rule that should exist is wasted unless the lint rule gets implemented)
|
|
31
|
+
- Fixing without generalizing (fixing one instance while leaving the recurring pattern intact)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-exhaust-the-design-space
|
|
3
|
+
description: "Apply when facing a novel UI interaction or architectural decision with no precedent in the codebase. Build 2-3 competing prototypes and compare side by side before committing."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Exhaust the Design Space
|
|
8
|
+
|
|
9
|
+
When a novel interaction or architectural decision has no established precedent, explore several concrete alternatives before implementation. Building the wrong thing costs more than exploring three options.
|
|
10
|
+
|
|
11
|
+
**The rule.** When the right answer is not obvious, build 2-3 competing prototypes or sketches. Compare them side by side. Only then commit. Design it twice is this rule by another name. A second flavor of the first shape does not count.
|
|
12
|
+
|
|
13
|
+
**When it applies:**
|
|
14
|
+
- Novel UI interactions (no prior art in the codebase)
|
|
15
|
+
- Architectural choices with multiple viable approaches
|
|
16
|
+
- Product design decisions where user experience depends on feel, not logic
|
|
17
|
+
|
|
18
|
+
**When it doesn't:**
|
|
19
|
+
- Mechanical implementation where the pattern is established
|
|
20
|
+
- Bug fixes or refactors with a clear target state
|
|
21
|
+
- Changes where constraints dictate a single viable approach
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-experience-first
|
|
3
|
+
description: "Apply when product, UX, or feature-scope tradeoffs come up. Choose user delight over implementation convenience; ship fewer polished features over more rough ones."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Experience First
|
|
8
|
+
|
|
9
|
+
When implementation convenience conflicts with user delight, choose delight.
|
|
10
|
+
|
|
11
|
+
- Every feature, control, and option must be justified
|
|
12
|
+
- Ship less, ship better (polished experience with three features beats rough one with ten)
|
|
13
|
+
- Prototype before committing (design decisions are cheaper in throwaway HTML than production code)
|
|
14
|
+
- Get the details right (transitions, alignment, spacing, feedback, error states)
|
|
15
|
+
- Tighten the core loop (every feature should serve the central workflow or get out of the way)
|
|
16
|
+
|
|
17
|
+
The user is whoever consumes the work. For a UI that is the end user. For a library or an internal API it is the colleague who imports it. The engineer who maintains the code next is a user too. Weigh their experience the same way, and explain impact from their perspective.
|
|
18
|
+
|
|
19
|
+
Foundations should serve the experience. Foundational thinking governs the *sequence* of work. This principle governs the *target*.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-fix-root-causes
|
|
3
|
+
description: "Apply when debugging. Trace each symptom to its root cause and fix it there; reproduce first, ask why until you reach it, resist nil-check guards that silence crashes."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Fix Root Causes
|
|
8
|
+
|
|
9
|
+
When debugging, do not fix symptoms. Trace every problem to its root cause and fix it there.
|
|
10
|
+
|
|
11
|
+
**Why:** Symptom fixes accumulate. Each workaround makes the system harder to reason about, and the real bug remains. Root-cause fixes are slower upfront but reduce total debugging time.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
- Reproduce first
|
|
15
|
+
- Ask "why" until you hit the root cause
|
|
16
|
+
- Do not add guards (adding a nil check to silence a crash is a symptom fix)
|
|
17
|
+
- If a workaround needs a paragraph-long comment to justify it, the code is wrong (fix the code, not the comment)
|
|
18
|
+
- Check for the pattern, not just the instance (grep for the same pattern, fix all instances)
|
|
19
|
+
- When stuck, instrument. Don't guess (add logging, read the actual error)
|
|
20
|
+
|
|
21
|
+
**Restart bugs: suspect state before code**
|
|
22
|
+
|
|
23
|
+
When something "fails after restart," suspect stale persistent state first: config files, caches, lock files, serialized state. If clearing a state file restores behavior, prioritize state validation as the fix.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-foundational-thinking
|
|
3
|
+
description: "Apply before writing logic: choosing core types and data structures, sequencing scaffold-vs-feature work, asking what concurrent actors share. Get the data structures right so downstream code becomes obvious."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Foundational Thinking
|
|
8
|
+
|
|
9
|
+
**Structural decisions** protect option value. **Code-level decisions** protect simplicity.
|
|
10
|
+
|
|
11
|
+
**Data structures first.** Get the data shape right before writing logic. Define core types early, trace every access pattern, and choose structures that match the dominant paths.
|
|
12
|
+
|
|
13
|
+
At code level, DRY the structure, not every line. Types and data models should converge. Three similar statements still beat a premature abstraction. Prefer explicit over clever. Test behavior and edge cases, not line counts.
|
|
14
|
+
|
|
15
|
+
**Concurrency corollary.** Before sharing state between actors, ask "what happens if another actor modifies this concurrently?" If not "nothing", isolate.
|
|
16
|
+
|
|
17
|
+
**Scaffold first.** If something helps every later phase, do it first. Ask "does every subsequent phase benefit from this existing?" CI, linting, test infrastructure, and shared types are scaffold. Sequence for option value: setup before features, tests before fixes. Keep commits small and single-purpose.
|
|
18
|
+
|
|
19
|
+
Each increment should land a coherent abstraction or deepen one that exists. Do not spread a new capability across callers as special-case coordination.
|
|
20
|
+
|
|
21
|
+
Subtraction comes before scaffolding. Remove dead code first, then lay foundations.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-guard-the-context-window
|
|
3
|
+
description: "Apply when context is filling up: large outputs, long files, repeated reads, fan-out planning. Route bulk to subagents; keep summaries in the main thread, not raw payloads."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Guard the Context Window
|
|
8
|
+
|
|
9
|
+
The context window is finite and non-renewable within a session. Every token should be worth its cost.
|
|
10
|
+
|
|
11
|
+
**Why:** Context overflow degrades reasoning quality, creates compression artifacts, and halts progress.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
- **Isolate large payloads.** Route verbose outputs, screenshots, and large documents to subagents. The main context gets summaries, not raw data.
|
|
15
|
+
- **Don't read what you won't use.** Read selectively based on relevance. If a file isn't needed for the current task, skip it.
|
|
16
|
+
- **Keep frequently used content inline.** Templates and references used on every invocation belong in the skill file, not in separate files that cost a read each time.
|
|
17
|
+
- **Size phases and cap scope.** Limit files per phase, set turn budgets, account for mechanism costs.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-laziness-protocol
|
|
3
|
+
description: "Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Laziness Protocol
|
|
8
|
+
|
|
9
|
+
Aim for the most result with the least code and complexity.
|
|
10
|
+
|
|
11
|
+
- **Prefer deletion.** When asked to refactor or improve, look for removals before additions.
|
|
12
|
+
- **Maintain a flat call hierarchy.** Avoid deep call chains. A rich interface that hides substantial work is not a deep call chain. If answering a question requires tracing through more than 3 files or layers, flatten it.
|
|
13
|
+
- **Consolidate decisions.** Do not repeat the same choice in several places. Put it behind one source of truth and pass the result as a simple flag.
|
|
14
|
+
- **Minimize the diff.** Make the smallest change that solves the problem. Fewer lines beat "elegant" boilerplate.
|
|
15
|
+
- **Question the threading.** If a task asks you to pass a new signal through types, schemas, pipelines, or similar layers, stop and look for a more direct path.
|
|
16
|
+
- **Sweat the small leaks.** Remove tiny pass-throughs, representation leaks, and duplicated choices before they spread. Small leaks compound into permanent coordination costs.
|
|
17
|
+
|
|
18
|
+
**The test:** If a human developer would find the code exhausting to maintain, it is a bad solution.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-make-operations-idempotent
|
|
3
|
+
description: "Apply when designing commands, lifecycle steps, or processing loops that run amid crashes, restarts, and retries. Converge to the same end state regardless of partial prior runs."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Make Operations Idempotent
|
|
8
|
+
|
|
9
|
+
Design operations so they converge to the correct state regardless of how many times they run or where they start from. Every state-mutating operation should answer: "What happens if this runs twice? What happens if the previous run crashed halfway?"
|
|
10
|
+
|
|
11
|
+
**Why:** Commands, lifecycle operations, and processing loops run where crashes, restarts, and retries are normal. If partial state changes the next run's outcome, every restart becomes a debugging session.
|
|
12
|
+
|
|
13
|
+
**The pattern:**
|
|
14
|
+
- Convergent startup: scan for existing state, clean stale artifacts, adopt live sessions
|
|
15
|
+
- Content-based cleanup: compare by content equivalence, not creation order
|
|
16
|
+
- Self-healing locks: use PID-based stale lock detection
|
|
17
|
+
- Idempotent scheduling: failed work respawns cleanly, fresh input regenerated after each cycle
|
|
18
|
+
|
|
19
|
+
**The test:**
|
|
20
|
+
1. What happens if this runs twice in a row?
|
|
21
|
+
2. What happens if the previous run crashed at every possible point?
|
|
22
|
+
3. Does re-execution converge to the same end state?
|
|
23
|
+
|
|
24
|
+
If any answer is "it depends on what state was left behind," the operation needs a reconciliation step.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-migrate-callers-then-delete-legacy-apis
|
|
3
|
+
description: "Apply when introducing a new internal API while old callers still exist. Migrate callers and delete the old API in the same wave instead of preserving compatibility layers."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Migrate Callers Then Delete Legacy APIs
|
|
8
|
+
|
|
9
|
+
When we decide a new API is the right design, migrate callers and remove the old API in the same refactor wave instead of preserving compatibility layers.
|
|
10
|
+
|
|
11
|
+
**Rule:**
|
|
12
|
+
- Do not keep legacy API paths only because internal callers still exist
|
|
13
|
+
- Inventory callers, migrate them, and delete the old API immediately
|
|
14
|
+
- Treat temporary adapters as exceptional and time-boxed, not default architecture
|
|
15
|
+
- Update tests to assert the new contract, and delete tests that only protect pre-refactor implementation details
|
|
16
|
+
|
|
17
|
+
**When this applies:**
|
|
18
|
+
- No external users depend on backward compatibility
|
|
19
|
+
- The project can absorb coordinated breaking changes
|
|
20
|
+
- The new API is part of a simplification or refactor initiative
|
|
21
|
+
|
|
22
|
+
Keeping both old and new APIs creates dual-path complexity, slows cleanup, and makes the codebase feel append-only.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-minimize-reader-load
|
|
3
|
+
description: "Apply when reviewing or shaping code that's hard to trace. Count layers between question and answer, and hidden state in the reader's head; collapse one-caller wrappers and shrink mutable scope."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Minimize Reader Load
|
|
8
|
+
|
|
9
|
+
Maintainability is the work a reader must do to understand code. Track two axes:
|
|
10
|
+
1. **Layers to trace.** How many indirections sit between the question and the answer.
|
|
11
|
+
2. **State to hold.** How much hidden or mutable context the reader must keep in their head.
|
|
12
|
+
|
|
13
|
+
**Why:** Code is read far more than it is written. LOC, cyclomatic complexity, and "clean architecture" are proxies. Reader load is the thing that matters. The two axes are independent. A flat file with 50 globals can be as hard to reason about as a 6-layer adapter stack. Guard both. This is the human analog of [Guard the Context Window](../principle-guard-the-context-window/SKILL.md). Working memory is finite for readers too.
|
|
14
|
+
|
|
15
|
+
**The pattern:**
|
|
16
|
+
- **Collapse layers** that cost more than they save: wrappers with one caller, adapters with no second implementation, speculative indirection that was never needed. Inline them.
|
|
17
|
+
- **Make adjacent layers change the abstraction.** A layer that repeats the same methods and arguments adds reader load without compression. Collapse pass-through layers.
|
|
18
|
+
- **Demand interface compression.** A broad interface that hides little complexity makes readers learn both the surface and the implementation. Prefer boundaries that hide meaningful decisions.
|
|
19
|
+
- **Shrink state scope:** prefer pure functions (returns over mutations), locals over fields, fields over module state, and module state over globals. Derive instead of sync.
|
|
20
|
+
- **Name the invariant at the boundary,** not in every consumer, so the reader learns it once.
|
|
21
|
+
- Before adding a layer or a piece of state, ask: does this reduce reader load somewhere else by at least as much?
|
|
22
|
+
|
|
23
|
+
**The test:** Can a new reader answer "where does X come from?" and "what can change X?" in under 30 seconds? If not, cut layers or cut state.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-model-the-domain
|
|
3
|
+
description: "Apply when writing stateful logic, or when code branches a lot or repeats a shape assumption across files. Encode the domain in a structure instead of scattered conditionals."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Model the Domain
|
|
8
|
+
|
|
9
|
+
Encode the real domain in a data structure instead of scattering it across conditionals.
|
|
10
|
+
|
|
11
|
+
**Why:** Scattered booleans, repeated shape assumptions, and branching spread across files are accidental complexity. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.
|
|
12
|
+
|
|
13
|
+
**Reach for structures like these:**
|
|
14
|
+
|
|
15
|
+
- A state machine instead of scattered booleans, phases, or lifecycle checks.
|
|
16
|
+
- A typed object/model instead of loose parameters or repeated shape assumptions.
|
|
17
|
+
- A map, registry, lookup table, or discriminated union instead of branching spread across files.
|
|
18
|
+
- A reducer or command/event model instead of ad hoc state mutations.
|
|
19
|
+
- A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.
|
|
20
|
+
- A small module boundary that gathers repeated behavior, ownership, or invariants.
|
|
21
|
+
- A queue, cache, index, graph/tree, or normalized collection where the data access pattern calls for it.
|
|
22
|
+
- Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.
|
|
23
|
+
|
|
24
|
+
Do not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.
|
|
25
|
+
|
|
26
|
+
The sign that you skipped this is a new feature that grows an existing if/else chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-never-block-on-the-human
|
|
3
|
+
description: "Apply when tempted to ask 'should I do X?' on reversible work. Proceed, present the result, let the human course-correct after the fact; reserve confirmation for irreversible actions."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Never Block on the Human
|
|
8
|
+
|
|
9
|
+
The human supervises asynchronously. Agents must stay unblocked. Make reasonable decisions, proceed, and let the human course-correct after the fact.
|
|
10
|
+
|
|
11
|
+
**Why:** Every permission pause stalls the pipeline and makes the human the bottleneck. Since code changes are reversible and reviewable, a wrong decision usually costs less than blocking.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
- **Proceed, then present.** Do the work, show the result. Don't ask "should I do X?" Do X, explain why.
|
|
15
|
+
- **Reserve questions for genuine ambiguity.** Ask only when you cannot infer intent from context.
|
|
16
|
+
- **Make the system self-healing.** When you notice a problem, log it and fix it in the next round.
|
|
17
|
+
- **Supervision is async.** Design workflows for review-after-the-fact.
|
|
18
|
+
|
|
19
|
+
**Boundaries:**
|
|
20
|
+
- **Irreversible actions** (force-push, delete production data, send external messages) still require confirmation.
|
|
21
|
+
- **Reversible actions** (write code, edit notes, split tasks) should proceed without blocking.
|
|
22
|
+
- **Product direction** comes from the human. *Execution* should not block.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-outcome-oriented-execution
|
|
3
|
+
description: "Apply during planned rewrites and migrations with explicit phase boundaries. Converge on the target architecture; don't preserve smooth intermediate states with throwaway compatibility code."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Outcome-Oriented Execution
|
|
8
|
+
|
|
9
|
+
Optimize for the intended, verifiable end state rather than preserving smooth intermediate states.
|
|
10
|
+
|
|
11
|
+
**Why:** Keeping every intermediate step fully stable often creates temporary compatibility code that becomes long-lived debt. Converge on the target architecture and prove correctness at explicit verification boundaries.
|
|
12
|
+
|
|
13
|
+
**Core rule:**
|
|
14
|
+
- Prioritize end-state integrity over transitional stability
|
|
15
|
+
- Intermediate breakage is acceptable when it is planned, scoped, and reversible
|
|
16
|
+
- Always run final verification before declaring done
|
|
17
|
+
|
|
18
|
+
**Guardrails:**
|
|
19
|
+
- Use this for planned rewrites and migrations with explicit phase boundaries
|
|
20
|
+
- Declare where temporary breakage is acceptable
|
|
21
|
+
- Keep high-signal checks for actively touched areas while migrating
|
|
22
|
+
- Require full static and runtime verification at plan completion
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-prove-it-works
|
|
3
|
+
description: "Apply after completing a task, before declaring done. Verify against the real artifact (run the feature, read the actual value, inspect the diff), not a proxy, self-report, or 'it compiles.'"
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Prove It Works
|
|
8
|
+
|
|
9
|
+
Verify every task output by checking the real thing directly. Do not infer from proxies, self-reports, or "it compiles."
|
|
10
|
+
|
|
11
|
+
**Why:** Unverified work has unknown correctness. Indirect verification (file mtimes, output freshness, agent self-reports, cached screenshots) feels cheaper than direct observation. Acting on a wrong inference costs far more than checking the source.
|
|
12
|
+
|
|
13
|
+
**Pattern:** After completing any task, ask: "how do I prove this actually works?"
|
|
14
|
+
|
|
15
|
+
Check the real thing, not a proxy:
|
|
16
|
+
- Check process liveness directly, not indirectly through derived state
|
|
17
|
+
- Read the actual value, not a cached or derived representation
|
|
18
|
+
- When verification fails, suspect the observation method before suspecting the system
|
|
19
|
+
|
|
20
|
+
Code and features:
|
|
21
|
+
1. Build it (necessary but not sufficient)
|
|
22
|
+
2. Run it and exercise the actual feature path
|
|
23
|
+
3. Check the full chain: does data flow from input to output?
|
|
24
|
+
4. For integrations, test the full communication path end-to-end
|
|
25
|
+
|
|
26
|
+
Delegation: trust artifacts, not self-reports.
|
|
27
|
+
When verifying delegated work, inspect the actual output artifact (git diff, file contents, runtime behavior), not the delegate's summary.
|
|
28
|
+
|
|
29
|
+
## Script the check when you can
|
|
30
|
+
|
|
31
|
+
The strongest proof is a deterministic script that re-runs the same comparison, not a one-time eyeball. Write the script, run it, and keep its output as an artifact a reviewer can re-run instead of trusting your word.
|
|
32
|
+
|
|
33
|
+
Keep the artifact visible for the human. Commit it only for large or complex work where the trail has to be auditable later, like a big port or migration (the **show-me-your-work** skill).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-redesign-from-first-principles
|
|
3
|
+
description: "Apply when integrating a new requirement into an existing design. Redesign as if the requirement had been a foundational assumption from day one, instead of bolting it on."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Redesign From First Principles
|
|
8
|
+
|
|
9
|
+
When integrating a change, don't bolt it onto the existing design. Redesign as if the requirement had been there from the start.
|
|
10
|
+
|
|
11
|
+
- Read all affected files and understand the current design
|
|
12
|
+
- Ask: "if we were writing this from scratch with this new requirement, what would we build?"
|
|
13
|
+
- Propagate the change through every reference: types, docs, examples, rationale sections
|
|
14
|
+
- Think about the whole redesign, then deliver it incrementally
|
|
15
|
+
|
|
16
|
+
This is the method for preserving option value when integrating changes into an existing design.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-separate-before-serializing-shared-state
|
|
3
|
+
description: "Apply when concurrent actors might write to the same file, branch, key, or state object. Eliminate the sharing first; serialize structurally only when one shared writer is a real invariant."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Separate Before Serializing Shared State
|
|
8
|
+
|
|
9
|
+
When concurrent actors might share mutable state, first ask whether they need the same mutable object. If not, eliminate the sharing. When sharing is real, enforce serialization structurally: lockfiles, sequential phases, exclusive ownership. Instructions and conventions are not concurrency control.
|
|
10
|
+
|
|
11
|
+
**Why:** Concurrent writes to shared state create race conditions that are intermittent, hard to reproduce, and expensive to debug.
|
|
12
|
+
|
|
13
|
+
**Pattern:**
|
|
14
|
+
1. **Identify shared mutable state** (files both read and write, branches both push to, APIs both define and consume).
|
|
15
|
+
2. **Default: eliminate the shared write target.** Ask: do these actors need one canonical object, or are they publishing independent facts? Give each actor its own owned file, key, branch, or state directory, and merge only at the read/reporting boundary. Two workers writing their own `lastX` field into one `state.json` is still shared mutation. `indexer-state.json` + `metrics-state.json` is not.
|
|
16
|
+
3. **Only when one shared write target is a real invariant, serialize access structurally** (lockfiles, sequential phases, single-writer actor, or atomic compare-and-swap). Treat "we need a lock" as a design smell to check, not as the default answer.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-sequence-verifiable-units
|
|
3
|
+
description: "Apply to multi-step work (sweeps, migrations, runs of similar edits) and to how you stack commits and PRs. Break work into small units that each end in a verifiable state, check each before the next, and order delivery so the sequence proves itself to a reviewer."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sequence work into verifiable units
|
|
8
|
+
|
|
9
|
+
Order work as a sequence of small units, each ending in a state you can check, and don't advance until the current one is green.
|
|
10
|
+
|
|
11
|
+
**Why:** A break caught at the unit that caused it is cheap to localize. A break caught after a batch is buried, and you have already built further on a broken base. Sequencing those same units into a delivery a reviewer can replay turns "trust me" into "watch it go red, then green."
|
|
12
|
+
|
|
13
|
+
**Execution.** In a sweep, migration, or any run of similar edits, verify each change before starting the next. Each unit is a before/after bracket: known-good state, one change, run the check, then proceed. Rebase onto clean trunk first so every check measures against the real baseline. When a lever does the edits, the per-unit check is nearly free. Run it anyway.
|
|
14
|
+
|
|
15
|
+
**Delivery.** Stack commits and PRs in the order that proves the work. The canonical shape is the failing test first, then the fix on top. Other story orders are a subtraction before the reshape, a baseline capture before the treatment, the scaffold before the feature. Each commit lands on its own and the sequence reads as an argument.
|
|
16
|
+
|
|
17
|
+
**Pattern:**
|
|
18
|
+
- Pick the smallest unit that ends in a check: an edit plus its test, or a commit that stands alone.
|
|
19
|
+
- Verify before advancing. Red to green per unit, never deferred to a final batch.
|
|
20
|
+
- Order the units so the sequence builds confidence on its own, for you while executing and for a reviewer reading the stack.
|
|
21
|
+
|
|
22
|
+
The sequencing complement to the **prove-it-works** principle skill, which keeps each check real, and the **build-the-lever** principle skill, which makes the per-unit check cheap.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-subtract-before-you-add
|
|
3
|
+
description: "Apply when sequencing an addition, refactor, or rewrite. Remove dead code, redundant validators, and stub references first, then build on the simpler base."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Subtract Before You Add
|
|
8
|
+
|
|
9
|
+
When evolving a system, remove complexity first, then build.
|
|
10
|
+
|
|
11
|
+
**Why:** Adding to a complex system compounds complexity. Removing first leaves less code, reveals the essential structure, and usually makes the next design obvious. Default to subtraction.
|
|
12
|
+
|
|
13
|
+
Make simplification a continual investment. Leave the design slightly simpler and more capable behind the same or smaller surface than you found it.
|
|
14
|
+
|
|
15
|
+
**The pattern:**
|
|
16
|
+
- Sequence removal before construction
|
|
17
|
+
- Cut before you polish (get to the minimum before investing in quality)
|
|
18
|
+
- Design for observed usage, not speculative edge cases
|
|
19
|
+
- No speculative validators, parsers, or guards beyond what the spec demands
|
|
20
|
+
- Simplify prompts (remove redundant instructions, excessive templates)
|
|
21
|
+
- When a reference has no novel content, delete it rather than leaving a stub
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: principle-test-behavior-not-implementation
|
|
3
|
+
description: "Apply when you write, change, or keep a test. Call the code the way its users do and assert the result they observe against a literal expected value. If the test would still pass when every imported function returns undefined, rewrite the assertion or delete the test."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Test Behavior, Not Implementation
|
|
8
|
+
|
|
9
|
+
A test calls the code the way its users do and asserts the result they observe against a literal expected value. A test that asserts which calls the code made, or restates a constant the code contains, does neither.
|
|
10
|
+
|
|
11
|
+
The check: before you keep a test, ask whether it would still pass if every function it imports returned `undefined`. If yes, it observes no behavior and cannot fail for a defect. Rewrite the assertion or delete the test.
|
|
12
|
+
|
|
13
|
+
**Why:** A test that cannot fail for a defect costs CI time and review attention and catches nothing. A constant pin also fails when someone edits the constant or the prompt it restates, so it prevents that edit.
|
|
14
|
+
|
|
15
|
+
**Five shapes that still pass when every imported function returns `undefined`:**
|
|
16
|
+
|
|
17
|
+
- **Weak or no assertion.** No `expect`, or only `toBeDefined`, `toBeTruthy`, `not.toThrow`, `toBeInstanceOf`, `toBeGreaterThan(0)`.
|
|
18
|
+
- **Mock or absence only.** Only `toHaveBeenCalled`, `not.toHaveBeenCalled`, `toBeUndefined`, `toEqual([])`, `toHaveLength(0)`, `not.toBe(wrongValue)`.
|
|
19
|
+
- **Self-referential.** The expected value comes from the code under test: `expect(f(a)).toBe(f(a))`, `expect(parsed.url).toBe(buildUrl(...))`.
|
|
20
|
+
- **Constant pin.** The assertion restates a hand-maintained constant, config default, table row, or prompt string: `expect(LIMITS.maxTools).toBe(8)`, `expect(PROMPT).toContain("You are")`.
|
|
21
|
+
- **Fixture asserts fixture.** The assertion reads data the test built or a value computed in `beforeEach`, and the subject never runs inside the body.
|
|
22
|
+
|
|
23
|
+
**The fix:** call the subject inside the test body with one concrete input and assert the literal output or the observable effect, `expect(slugify("Hello, World!")).toBe("hello-world")`. For an absence, assert the presence on the other input in the same test. For a constant, test the mechanism that reads it with one input instead of restating the value. For a mock, assert the payload it received or the state after the call, not that it was called. When no such assertion exists, delete the test.
|
|
24
|
+
|
|
25
|
+
**Keep** a test of a relation across a table's rows (a key present in two tables, a parent that exists), and a compile-time check in a `*.test-d.ts` file.
|