diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a0915..d38a9aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - `.githooks/` gains `commit-msg`, `prepare-commit-msg`, `post-commit`, `post-rewrite`, and the pre-entire `pre-push` variant, completing the commit-gate set that `make install` wires via `core.hooksPath`; `BACKLOG.md` tracks module-level follow-ups - `skills/ForgeSkill/` — BuildSkill's router and companions merged with the eval machinery adopted from [anthropics/skills](https://github.com/anthropics/skills) skill-creator (grader/comparator/analyzer agents, eval and description-optimization scripts, browser viewer), pinned per-file by SLSA provenance sidecars (Apache-2.0 under EUPL-1.2). New companions `EvalLoop.md` and `DescriptionOptimization.md` route the test-improve-iterate loop and trigger optimization. BuildSkill remains until the artifact-merge analysis lands - `skills/BashConventions/` + `BashPatterns.md` companion — Bash pitfalls (BSD vs GNU, `set -euo pipefail` traps, subprocess env) relocated from forge-dev +- Behavioral rules batch: `NoBackstory`, `OnePurpose`, `PresentTense`, `ScratchDirectory` (+ claude variant), `UserConfig`, `VerifyDecisions`, `VerifyRenderedOutput`, `WorkSessionFlow`, `LocalInferenceKeys`, `claude/Scheduling`; updates to `Deslop`, `KnownIssues`, `VerifyClaims`; `StartFresh` and the codex/gemini `AgentTeams` qualifier rules retired - `skills/VersionControl/GitWorktrees.md` — companion covering parallel feature work via `git worktree`, with SLSA provenance (adapted from [davila7/claude-code-templates](https://github.com/davila7/claude-code-templates) MIT under EUPL-1.2) - `VersionControl` now serves as the canonical home for git conventions and platform-specific repo governance (absorbing the retired forge-dev `Git` skill). forge-dev's `GitHub` skill remains distinct — it covers CI, Actions, releases, and operational `gh` workflows diff --git a/rules/Deslop.md b/rules/Deslop.md index 9c0e03c..20c56b8 100644 --- a/rules/Deslop.md +++ b/rules/Deslop.md @@ -17,4 +17,6 @@ Construction tells: Human test: read it aloud. If you would not say it to a colleague, rewrite it. If deleting the sentence loses nothing, delete it. +Deslop at write time, not on request. The first draft of any PR title and body, commit message, ADR, issue, or doc must already pass this checklist; never emit slop and wait to be told to deslop. ADR Consequences are the usual offender: write them as plain, honest tradeoffs, not a `[+]/[-]` pros-heavy sales list, and cut salesmanship ("reuses the tested path", "falls out of", "byte-for-byte no-op") for the plain effect. + [WPSIGNS]: https://en.wikipedia.org/wiki/Wikipedia:Signs_of_AI_writing diff --git a/rules/KnownIssues.md b/rules/KnownIssues.md index 7fa1400..44558bc 100644 --- a/rules/KnownIssues.md +++ b/rules/KnownIssues.md @@ -5,3 +5,9 @@ macOS TCC permissions are separate from Claude Code sandbox and permission setti Subagents spawned with `mode: 'auto'` cannot write to git submodule paths even with `bypassPermissions`. Symptom: agent reports completion but no files were created. Workaround: do the writes from the parent session, or accept the permission prompt manually when it surfaces. Homebrew's `pip3` on macOS enforces PEP 668 strictly — `pip3 install`, `pip3 install --user`, and `pip3 install --break-system-packages` all fail with "No virtual environment found." Use `uv venv ` to create an isolated environment, then `uv pip install --python /bin/python `. Don't keep retrying pip flags; the wrapper rejects all of them by design. + +A session created with `/branch` and then moved with `/cd` keeps writing its transcript in the original project directory, while cwd-derived consumers (Entire's turn-end hooks) look under the new one. Symptom: every turn ends with a non-blocking `transcript file not found` Stop-hook error and session capture silently stops. Fix: restart the session from the new directory (fresh session id, transcript in the right place). Never patch around it inside `~/.claude/projects` — no symlinks or file moves in harness internals. + +The claude-in-chrome `navigate` tool force-upgrades `file://` URLs to `https://`, breaking local-file preview. To preview a local HTML file, serve its directory with `python3 -m http.server --bind 127.0.0.1` and open `http://127.0.0.1:/file.html`. After scrolling, read rendered state via `javascript_tool` (`getComputedStyle`, `textContent`) rather than screenshots, which can lag the paint. + +Headless `Google Chrome --headless --screenshot` enforces a 500px minimum window width. A capture requested below 500px renders the page at 500px but crops the image to the requested width, so a correct layout looks clipped on the right. Screenshot at 500px or wider, and confirm horizontal overflow by measuring `document.documentElement.scrollWidth` against `window.innerWidth` inside the page rather than trusting the crop. The Chrome binary and its profile dir are blocked under the Bash sandbox (`bootstrap_check_in`, `ProcessSingleton` "Operation not permitted"); run it with `dangerouslyDisableSandbox` and a fresh `--user-data-dir`. It may not self-exit in `--headless=new`, so use old `--headless` with `--virtual-time-budget`, or background it and kill the pid once the PNG appears. diff --git a/rules/LocalInferenceKeys.md b/rules/LocalInferenceKeys.md new file mode 100644 index 0000000..2cffc4f --- /dev/null +++ b/rules/LocalInferenceKeys.md @@ -0,0 +1,7 @@ +Local inference servers (oMLX on `127.0.0.1:8000`, LM Studio on `127.0.0.1:1234`) authenticate with an API key the user owns. + +Read those keys from the environment, `OMLX_API_KEY` and `LMSTUDIO_API_KEY`, which live in `~/.env`. If not already exported, source it first: `set -a; . ~/.env; set +a`. Send the key only as the request `Authorization: Bearer ` header. + +Never pass `--api-key` to `omlx serve` or `omlx start`, and never edit `~/.omlx/settings.json`: both persist the value and silently overwrite the user's key, which loses it. A 401 means the running server holds a different key, so read the key from `~/.env` or ask the user; do not reset it by relaunching with a new `--api-key`. Never kill or relaunch the user's managed oMLX server (`omlx start` / launchd `homebrew.mxcl.omlx`) to change auth or free a port; start a separate `omlx serve` on another port for scratch work and leave the managed server alone. + +oMLX serves MLX/safetensors models only (`config.json` + `*.safetensors`), not GGUF; a GGUF-only download (for example from LM Studio) needs a separate MLX build. When inlining file contents into a model prompt from zsh, iterate an array (`files=(a b c); for f in $files`), not a space-joined string: zsh does not word-split an unquoted scalar, so `for f in "$string"` runs once over the whole value and the reads fail. Use `command cat` to bypass any rtk alias. diff --git a/rules/NoBackstory.md b/rules/NoBackstory.md new file mode 100644 index 0000000..afee78a --- /dev/null +++ b/rules/NoBackstory.md @@ -0,0 +1,9 @@ +Keep the backstory out of the artifact. In documentation, code, config, inline comments, and ADRs, never reference what was wrong, what was removed, or what changed: naming past errors anchors them in context and makes repeating them more likely. + +A change's rationale, why this option and not the alternative, what it replaces or improves, belongs in the commit message, not in a comment or doc; the diff already shows what changed. Even positive justification ("via X, which manages Y") counts as narrating why. + +Not: "Account 39501 was previously thought to be RELIS-only but actually has 854K entries." +Not: "`appearance` removed: bypassed when `theme` is set above, so the field is dead." +Not: "Claude Code over ACP via the registry, which manages the adapter version." + +State the current truth instead; see [[PresentTense]]. diff --git a/rules/OnePurpose.md b/rules/OnePurpose.md new file mode 100644 index 0000000..f81a1b4 --- /dev/null +++ b/rules/OnePurpose.md @@ -0,0 +1,7 @@ +One action, one purpose. Applies to every tool invocation — shell commands, file edits, agent dispatches, API calls. The user must be able to read, understand, and approve each action at a glance, and a failure must be attributable to one step. + +Never chain unrelated operations (validate && stage && diff) into a single command line. Acceptable chaining: a guard and its single consequence (`mkdir -p dir && cd dir`), or a cheap probe before one action. Anything longer splits into separate invocations. + +Pipelines that transform one data stream (`cmd | filter | sort`) are one purpose and stay together. The smell is `&&`/`;` joining independent actions, not pipes. + +The same discipline holds beyond the shell: one edit per concern, one commit per changeset, one agent per task. Batching unrelated work into a single step hides what happened and forces all-or-nothing review. diff --git a/rules/PresentTense.md b/rules/PresentTense.md new file mode 100644 index 0000000..a381ff2 --- /dev/null +++ b/rules/PresentTense.md @@ -0,0 +1,6 @@ +Write documentation, code, config, inline comments, commit messages, and ADRs in the present: state what is true now, as if no earlier version existed. In config-file comments, describe only what the line does now. + +Write: "Account 39501 has 854K journal entries in Helios production." +Write: "`appearance` is ignored when `theme` is set explicitly above." + +If a correction would be cleaner as a rewrite than a patch, rewrite from the current truth. A wrong mental model annotated with corrections is worse than a clean restatement. For what to leave out, see [[NoBackstory]]. diff --git a/rules/PullRequests.md b/rules/PullRequests.md index 5f1d04f..f54e01b 100644 --- a/rules/PullRequests.md +++ b/rules/PullRequests.md @@ -1,5 +1,7 @@ PR titles and commit messages describe what changed, not why it was discovered. The change stands on its own. +Every PR or issue reference in output the user reads — chat replies, reports, review handoffs, docs — carries its link: `[#67](https://github.com/owner/repo/pull/67)` or the bare URL, never a naked `#67`. The bare number is fine only where the platform auto-links it (PR bodies, commit messages, GitHub comments). + ### Body Structure PR bodies explain the *why* before the *what* in as few sentences as possible. One-sentence sections beat padded sections. Code snippets, bulleted "Summary" lists, and prose that paraphrases the diff are forbidden. The diff already shows the code. diff --git a/rules/ScratchDirectory.md b/rules/ScratchDirectory.md new file mode 100644 index 0000000..e5cb36f --- /dev/null +++ b/rules/ScratchDirectory.md @@ -0,0 +1 @@ +Use `mktemp` (or `mktemp -d`) for transient, rebuildable scratch: downloads, archive extraction, build artifacts, intermediate files. Only rebuildable files belong in scratch; anything that must persist goes in the repo or its real target. diff --git a/rules/StartFresh.md b/rules/StartFresh.md deleted file mode 100644 index 52aff22..0000000 --- a/rules/StartFresh.md +++ /dev/null @@ -1,12 +0,0 @@ -When correcting documentation, code, config files, inline comments, commit messages, or ADRs, write the new truth as if the old version never existed. Never reference what was wrong, what was removed, or what changed. Mentioning past errors anchors them in context and increases the probability of repeating them. - -Write: "Account 39501 has 854K journal entries in Helios production." -Not: "Account 39501 was previously thought to be RELIS-only but actually has 854K entries." -Not: "Corrected from the earlier claim that 39501 never reaches Helios." - -In config-file comments, describe current behaviour. Avoid narrating why a line is the way it is. - -Write: "`appearance` is ignored when `theme` is set explicitly above." -Not: "`appearance` removed — when `theme` is explicitly set above, the appearance resolution path is bypassed, so the field is dead and was emitting a warning on startup." - -If a correction is large enough that starting fresh would produce a cleaner result than patching, start fresh. A wrong mental model that gets annotated with corrections is worse than a clean rewrite from the current truth. diff --git a/rules/UserConfig.md b/rules/UserConfig.md new file mode 100644 index 0000000..d2ecd65 --- /dev/null +++ b/rules/UserConfig.md @@ -0,0 +1,5 @@ +Forge artifacts that need per-user runtime data read from `~/.config/forge/.{ext}` — one file per artifact, name matches the artifact (`forensic.yaml` for ForensicAgent, `avatar.yaml` for an avatar skill, `safety-net` for a flat-list hook). Each artifact picks the format that fits its tooling: YAML for shell + yq, TOML for Rust binaries, plain regex list for grep hooks. + +Files live in the user's private dotfiles repo and deploy to `~/.config/forge/`. No artifact in a public forge module may hardcode a value that belongs in its config — names, emails, phones, hostnames, locale-specific identifiers all move out to the artifact's config file. The artifact source documents its expected schema; the values stay private. + +Reserve `config*` at the root of `~/.config/forge/` for forge-cli's own future XDG settings — never name an artifact `config`. See [NAME-0001](../docs/decisions/NAME-0001%20Forge%20Naming%20Collisions.md) for the namespace landscape. diff --git a/rules/VerifyClaims.md b/rules/VerifyClaims.md index d4b503a..f34c1be 100644 --- a/rules/VerifyClaims.md +++ b/rules/VerifyClaims.md @@ -12,4 +12,8 @@ When an agent returns assertions about file existence or constraint compliance ( Counts that subagents report ("12 files verified", "3 sidecars updated") violate [NoItemCounts][NIC] and are unreliable besides. If one slips through, recompute it yourself with `ls | wc -l`, `rg -c`, or equivalent before citing it. The specialist's count is a proposal; your recount is the fact. +Before claiming a tool "can't do X" or "has no analog for Y", check the tool's own config schema or `--help`, not docs or memory: config keys (sandbox modes, network allowlists, hook tables) are easy to miss, and the absence claim is what misleads. A sub-agent's summary of a doc is a proposal, not the source: when it contradicts a confident user or the decision is load-bearing, fetch and read the primary doc yourself before concluding. + +Comparative claims about a third party (a competitor's product, "X beats Y", a rival's limits) must cite that party's primary or binding source, not aggregator or comparison portals — portals are routinely stale or wrong, and one adversarial pass against the primary source overturns many of them. Name the specific subject and read its authoritative document before asserting the comparison, especially where the claim is regulated or published. + [NIC]: NoItemCounts.md diff --git a/rules/VerifyDecisions.md b/rules/VerifyDecisions.md new file mode 100644 index 0000000..9990a03 --- /dev/null +++ b/rules/VerifyDecisions.md @@ -0,0 +1,12 @@ +Verify every key decision with the user before acting — in every harness and every mode, including auto/full-auto modes. Autonomy settings change pacing bias, never this gate. Use the harness's structured question tool (AskUserQuestion in Claude Code); where no such tool exists, stop and ask in plain text before proceeding. + +A decision is key when ANY of these holds: + +- **Irreversible or hard to undo** — deletion, force-push, history rewrite, overwriting user content +- **Scope or architecture** — PR split/bundle, artifact placement, naming, schema shape, include-vs-defer +- **Shared or published surface** — PR, issue, commit, push, release, any external service +- **Ambiguous instruction** — the message allows two or more readings; present the readings as options instead of picking one silently + +Ask at each decision point as it arises, not batched at task start. One decision, one question, then act on the answer. + +Subagents cannot reach the user: they return findings and proposals; the parent session verifies key decisions before applying them. diff --git a/rules/VerifyRenderedOutput.md b/rules/VerifyRenderedOutput.md new file mode 100644 index 0000000..bdb3fb4 --- /dev/null +++ b/rules/VerifyRenderedOutput.md @@ -0,0 +1,7 @@ +A visual or layout change is not verified until you render it and look. Never claim an HTML, CSS, SVG, or UI fix from reading the source. The defect lives in the gap between source and output, so reasoning about the CSS is a hypothesis, not a result. + +Render the change before asserting it works: a headless browser screenshot, a real browser, or the running app. For layout and overflow bugs, measure instead of eyeballing. Compare `document.documentElement.scrollWidth` against `window.innerWidth` to detect horizontal overflow, and query for the widest element rather than guessing which one clips. + +Screenshots can mislead. A capture taken below the renderer's minimum window width crops a correct layout and reads as a clipping bug (headless Chrome enforces a 500px floor). Confirm the render width equals the capture width, or measure from inside the page, before concluding anything about clipping. + +This is the visual-output case of [[VerifyClaims]]: evidence before assertion, applied to pixels. diff --git a/rules/WorkSessionFlow.md b/rules/WorkSessionFlow.md new file mode 100644 index 0000000..14c1986 --- /dev/null +++ b/rules/WorkSessionFlow.md @@ -0,0 +1,3 @@ +Work follows one pipeline, not three independent steps. Enable Entire first so the session and its checkpoint history are captured. Do the work in jj (colocated with git; bookmarks become the branches that get pushed). Then commit while the user is present, so the commit is a GPG-signed git artifact that carries Entire's session history. Pushing without Entire enabled, or trying to sign unattended, breaks the chain. + +Sign with GPG — the active method here (`gpg.format=openpgp`, YubiKey OpenPGP + pinentry-mac). SSH-with-FIDO2 is only the documented fallback, not the default. A `gpg: signing failed: Timeout` on a commit or `jj git push` means pinentry could not prompt from a non-interactive shell, not that the method is wrong: export `GPG_TTY`, let pinentry-mac raise the PIN dialog (the user enters the PIN and touches the YubiKey), or have the user run the push from their own terminal. jj signs on push via its gpg backend and re-signs rebased descendants automatically. Never switch to SSH signing or disable signing to get past a timeout. diff --git a/rules/claude/Scheduling.md b/rules/claude/Scheduling.md new file mode 100644 index 0000000..eed50f0 --- /dev/null +++ b/rules/claude/Scheduling.md @@ -0,0 +1,3 @@ +# Scheduling + +CronCreate jobs live only inside the current session and expire within 7 days — never offer them for anything that must outlive the session. Durable schedules are cloud routines: the schedule skill / RemoteTrigger, cron in UTC (fixed offset — local time drifts across DST), minimum interval 1 hour. Routines cannot be deleted via API; only at claude.ai/code/routines. diff --git a/rules/claude/ScratchDirectory.md b/rules/claude/ScratchDirectory.md new file mode 100644 index 0000000..145b6bd --- /dev/null +++ b/rules/claude/ScratchDirectory.md @@ -0,0 +1,6 @@ +--- +targets: [claude] +mode: append +--- + +Under the Bash sandbox, `mktemp`'s default location (`/var/folders/...` on macOS) and `/tmp/claude` are in the write-allowlist, so `mktemp` works without disabling the sandbox. diff --git a/rules/codex/AgentTeams.md b/rules/codex/AgentTeams.md deleted file mode 100644 index 32632f5..0000000 --- a/rules/codex/AgentTeams.md +++ /dev/null @@ -1,6 +0,0 @@ -Codex CLI does not support agent teams. Council skills use sequential Agent calls without `team_name`: - -1. For each specialist, use Agent tool with `subagent_type` (no `team_name`). Collect results. -2. Present findings, ask user for input. -3. Spawn new Agent per specialist with prior transcript + next round instruction. -4. Repeat for all rounds, then synthesize. diff --git a/rules/gemini/AgentTeams.md b/rules/gemini/AgentTeams.md deleted file mode 100644 index e084a49..0000000 --- a/rules/gemini/AgentTeams.md +++ /dev/null @@ -1,6 +0,0 @@ -Gemini CLI does not have the Agent or Task tools. Council skills use direct `@AgentName` invocation instead: - -1. For each specialist, invoke `@AgentName` with the round prompt inline. Collect results. -2. Present findings, ask user for input. -3. Invoke `@AgentName` again per specialist with prior transcript + next round instruction. -4. Repeat for all rounds, then synthesize.