wtm
CLAUDE.md2 starsChanged 47 days agoMITView on GitHub
Mandatory coding standards for wtm. For Go idioms and their sources, consult the go-style skill (.claude/skills/go-style/SKILL.md). Use the fff MCP tools for all file search operations instead of default tools. Read on demand — docs/dev/ is the developer reference; open the page before working on its topic: Self-maintaining docs: when a structural decision changes (new package, renamed layer, new dependency, new convention), update this file, the relevant docs/dev/ page and/or the build-validator agent in the same session. Standards must reflect…
- Reads credentials
In this repository7 other files it gives its agents.
- llms.txtllms.txt
- go-styleSkill
- open-prSkill
- orchestrateSkill
- wtm-docsSkill
- wtm-sandboxSkill
- wtm-siteSkill
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 1 is distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Self-maintaining docs: when a structural decision changes (new package, renamed layer, new dependency, new convention), update this file, …
- Very specific: line 30
The landing and the README: follow docs/dev/identity.md.
- Very specific: line 36
Prefer := for values that do not change.
- Very specific: line 68
Every string key, exit code, flag name, env var name and format identifier is a named constant in internal/domain/constants.go.
- Very specific: line 77
Every error or guard returns immediately.
- Distinctive: line 90
When you modify any file, delete the comments in it that restate the code.
- Very specific: line 127
Every package of service/, infra/ and store/ has a package doc stating its one responsibility (pkgdoc).
- Very specific: line 140
Every worktree-mutating command (create, clean, sync, fast-forward, prune, relocate, reparent, extract, checkout, env), and init/run init, …
- Very specific: line 155
Every commit message — subject and body — is in English, whatever language the conversation was held in.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md — Go CLI Development Principles
Mandatory coding standards for wtm. For Go idioms and their sources, consult the go-style skill (.claude/skills/go-style/SKILL.md). Use the fff MCP tools for all file search operations instead of default tools.
Read on demand — docs/dev/ is the developer reference; open the page before working on its topic:
| Read | Before |
docs/dev/architecture.md | adding a package, an import between layers, or a service→service edge (annotated package map) |
docs/dev/store.md | writing meta.json, config.toml or a managed .env (store.Meta, ProjectConfig, EnvFiles) |
docs/dev/state-files.md | writing any file, or changing the format of a state file (fs.UpdateFile, fs.Change, locks, schema versions) |
docs/dev/flow-layer.md | touching anything under internal/flow/, a Prompter/Presenter, a step kind, or the dashboard's run of a flow |
docs/dev/adding-a-mutation-command.md | adding a worktree-mutating command: vocabulary, rules, the flow package, its wiring, presenter, tests |
docs/dev/cli.md | touching internal/surface/cli itself: the root (signals, --quiet, exit code), flag wiring |
docs/dev/output.md | adding a command or changing what one prints (frame, glyphs, block helpers, --quiet, JSON contract, hook view) |
docs/dev/lint.md | adding an archlint rule or an exception, or when make lint fails and the reason is unclear |
docs/dev/identity.md | touching the landing, the docs theme, the README pitch, the social preview or any launch material (positioning, voice, colours, type, logo, layout) |
docs/dev/changelog.md | writing a CHANGELOG.md entry |
docs/dev/run-addressing.md, docs/dev/shared-services.md | touching the run proxy / addressing, or scope = "shared" jobs |
Self-maintaining docs: when a structural decision changes (new package, renamed layer, new dependency, new convention), update this file, the relevant docs/dev/ page and/or the build-validator agent in the same session. Standards must reflect the actual codebase.
Docs & README
Two skills carry the detail: wtm-docs for any documentation change (where a fact belongs, the guide page shape, the guide index, audits) and wtm-site for the landing, the legal pages, the docs theme and the README pitch (identity rules in code, before/after screenshots). What every change must respect:
- Docs follow the code in the same change. A command, flag, output or behaviour that changes updates its docs in the same session:
make docsregeneratesdocs/wtm_*.mdanddocs/commands.jsonfrom the Cobra tree (never hand-edit them), the guide (docs/guide/) and developer docs (docs/dev/) are hand-written. - User-facing agent skill —
internal/surface/cli/agents/assets/using-wtm/ships to end users so their LLM can drivewtm: a shortSKILL.mdandreferences/*.mdby topic. Update it whenever the command surface or agent-relevant behaviour changes (command or flag,--output jsonshape, failure/abort semantics, interactive vs non-interactive). Skip internal refactors and TUI-only changes. - The docs site (
site/, Starlight) is built fromdocs/,README.mdandCHANGELOG.mdas they are: never write site-only Markdown indocs/. The guide sidebar is built from the sections ofdocs/guide/README.md, so a guide page not listed there does not appear.make sitebuilds it and validates links,make site-devserves it; thedocs-siteworkflow publishes it on each release tag.site/site.config.mjsholds the domain, the base path and the archived versions. - The landing and the README follow
docs/dev/identity.md; their terminals and visuals replay real output (thewtm-sandboxskill,make demosfor the README GIFs), re-captured when a shown command's output changes. CHANGELOG.mdfollowsdocs/dev/changelog.md; each release section becomes the GitHub release notes (make release-notes VERSION=x.y.z).- Markdown: English, never hard-wrapped — one paragraph is one line.
1. Immutability first
Prefer := for values that do not change. var only for zero-value initialization or package-level declarations. If a block reassigns a variable, extract it into a function.
2. Structs for 2+ inputs
A function taking 2 or more of its own inputs takes a single <Name>Params struct, initialized with named fields.
// ❌
func Connect(host string, port int) error
// ✅
type ConnectParams struct {
Host string
Port int
}
func Connect(params ConnectParams) error- Carriers don't count:
io.Writer,context.Context,testing.TB,*cobra.Commandare plumbing.render.Warning(w, text)respects the rule. - Where it bites: misorderable neighbours (
RenameJobRefs(cfg, from, to)— two strings the compiler lets you swap) and a list that grew (every service and flow entry point takes<Name>Params). - Symmetric pairs are exempt:
differ(a, b string),MergeRunConfigs(a, b),ClampIndex(index, length int)— the order is the meaning. - This is a review rule, not a lint rule, deliberately (measured: see
docs/dev/lint.md).
3. Shared types — no duplication
Types, enums, sentinel errors and constants are defined once in internal/domain/. Pure functions with no I/O (lookups, transforms, classification) live in internal/rules/.
4. Validate all external input
Config files, CLI flags and environment variables are validated at the boundary (config/ or command entry) with guard clauses. The service layer receives only clean data.
5. Centralized constants — no magic strings or numbers
Every string key, exit code, flag name, env var name and format identifier is a named constant in internal/domain/constants.go.
// ❌ os.Exit(1); cmd.Flags().String("output", ...)
// ✅ os.Exit(domain.ExitCodeError); cmd.Flags().String(domain.FlagOutput, ...)6. Early returns — no nesting
Every error or guard returns immediately; the happy path is last. Never nest if blocks.
7. No unsafe type assertions
Always comma-ok (s, ok := v.(string); if !ok { return fmt.Errorf("expected string, got %T", v) }). Prefer typed interfaces and concrete structs over any. Type at the source, not downstream. A value that takes one of a closed set of shapes is a sealed interface (an unexported method) with one type per shape, declared //go-sumtype:decl on a line of its own so make lint checks every type switch over it (fs.Change, envcopy.Warning) — never one struct whose fields are valid only for some value of another.
8. Comments — the exception, not the rule
Encode meaning in names and signatures (Skip func(Answers) (skip bool, reason string) needs no prose).
- What stays: a quirk of git, macOS or
flockthe code cannot show; a workaround with its reference; an ordering invariant or a non-obvious decision (why, never what); a one-line package doc; godoc on an exported symbol whose name and signature leave a caller guessing. - What goes: a comment that restates the name or the code; a doc comment on an unexported declaration (its why moves into the body, beside the line it explains); architecture prose (→
docs/dev/); section banners and copied headers in test files.
When you modify any file, delete the comments in it that restate the code.
9. Clean architecture layers
main.go the entry point: cli.Execute
internal/
domain/ types, errors, constants only; a new one goes in the sub-package of its subject
(domain/statefile), never at the root, which only shrinks
rules/ pure functions (stdlib + domain only, no I/O); a new decision goes in the sub-package
of its subject (rules/statefile, rules/envcopy), never at the root
config/ load & validate config.toml, run.toml, global config; writes the JSON schema beside each
store/ the one writer of each state file: meta.json, config.toml's changes, the managed .env files
flow/ the flow of each command, surface-independent (one package per command)
service/ impure orchestration: git exec, I/O, hooks, the run daemon, the event bus
styles/ all Lipgloss styles
infra/ git, filesystem and process wrappers; fs/ the only writer of state files (UpdateFile),
proc/ processes and the Shield
surface/ the interfaces
cli/ the root (signals, --quiet, exit code); flag wiring → flow (zero business logic)
render/ format and print results (zero decision logic)
tui/ Bubbletea models (rendering only): flowui (the wizard of a command), dashboard (`wtm ui`), runviewThe annotated map of every sub-package is in docs/dev/architecture.md.
Hard rules (the import and call rules are checked by make lint, tools/archlint):
surface/cli/has zero business logic.domain/has types, errors and constants only — no methods, no free functions.rules/imports only stdlib andinternal/domain— no I/O, no side effects.service/never importscobra,bubbletea,lipgloss.surface/cli/render/andsurface/tui/have zero decision logic — only rendering.styles/is the only package allowed to instantiatelipgloss.Style.flow/imports onlyinternal/service/,internal/rules/,internal/domain/and the stdlib — never cobra, bubbletea, lipgloss,surface/,config/orinfra/. Need something frominfra/? Add a thinservice/wrapper (e.g.worktree.FindByBranch).service/ximportsservice/yonly along an edge declared intools/archlint(serviceEdges).- The daemon (
service/process,service/proxy) is blind to git: noservice/worktree|branch|github|events, noconfig, only allow-listedinfra/functions. - A service mutator (the table in
tools/archlint/chokepoint.go) is called only frominternal/flow/. - Every package of
service/,infra/andstore/has a package doc stating its one responsibility (pkgdoc). The roots ofrules/anddomain/only shrink (rootfreeze): no new file nor exported symbol there. meta.json, the changes toconfig.toml(the remembered answers,base_path, the.envtargets) and the managed.envfiles are written bystore/only, each through its interface (store.Meta,ProjectConfig,EnvFiles);config/loads and validates, and keepsinit's full render. Seedocs/dev/store.md.- A file is named after what it declares, and a port lives with its implementation: its interface, the types it takes and returns and the implementation share one file (
store/meta.go), never an interfaces-only file beside the code. A type a whole package turns around has its own file; options sit beside the call that takes them. - A file is written through
infra/fsonly:fs.UpdateFile(ctx, {Path, Mutate})(lock, read,Mutatedecides anfs.Change, atomic rename), neveros.WriteFile/os.Create/os.Rename/os.Remove/os.RemoveAll/a writingos.OpenFileoutsideinfra/(statewrite), andfs.UpdateFileonly fromstore/, the owner of each state file (stateowner). A state file carriesschema(absent = 1, written from 2 on) and a write refuses a newer one (*statefile.NewerError, exit 22). Seedocs/dev/state-files.md.
Every worktree-mutating command goes through flow/ — Request/Outcome/Presenter/Params/Run in internal/flow/<cmd>/, its questions as flow.Step in steps.go, a runner that is only flags → Request → Prompter and Presenter → <cmd>.Run; a flow never frames, never picks a stream, and returns errors. Recipe: docs/dev/adding-a-mutation-command.md; model: docs/dev/flow-layer.md.
Output — each command frames its human output exactly once (render.Frame, or FrameStart/FrameEnd) and the body writes to the writer Frame hands it; JSON and machine output are never framed. A block prints only if it changes what the reader does next: success contracts to a count, anomalies are named one by one. Glyph runes come from domain constants, the glyph carries the only colour on its line, and Muted is for chrome and non-event lines only. Full rules: docs/dev/output.md.
Designating a worktree — the subject is positional; a worktree that is not the subject is a flag named after its role (extract [source] --to, create --from, run up [worktree] --profile). Omitted positional → the current directory when that is a safe default for the command (run), a picker otherwise (clean). A resolved worktree is always the root as git spells it (infra.Toplevel), never os.Getwd().
Bypass flags — two orthogonal axes
Every worktree-mutating command (create, clean, sync, fast-forward, prune, relocate, reparent, extract, checkout, env), and init/run init, which wire it by hand, follow this model:
--yes/-y— the confirmation axis: fully unattended, zero prompts. Each input resolves as:- Decision / confirmation → its flag, else the remembered answer (
[wizard.remembered], ticked "Always use this answer" in the wizard), else a documented safe default, never destructive (sync --yesdoes not push;extract --yesaborts on conflict;clean/prune --yesleave orphans unless--reparent-children). Only aStepSelectopting in withStep.Memoryremembers, never a confirmation or a destructive option (rules.RememberableValues);--askignores the memory for one run. - Required selection with no safe default → its flag/arg, else an error naming the missing flag. Never fall back to a picker.
- A picker runs only in a fully interactive run (no
--yes, TTY, human output).
- Decision / confirmation → its flag, else the remembered answer (
--yesis the only spelling of that axis — no--non-interactive. JSON mode requires--yes.--force— the safety axis, strictly separate. It only lifts safety refusals (dirty / unpushed / open PR / locked). It does not imply--yes:--forcealone still runs the wizard and asks to confirm, with--forcethreaded in as a preset.
Implementation: interactive := isTTY && rules.IsHumanFormat(format) && !yes; a command expresses case 2 as a step Resolve that names the flag (see internal/flow/sync/steps.go). Decision defaults go through a pure rule where one exists (rules.DecidePush).
Recap completeness: a flag or a remembered answer never makes a recap line disappear, nor its line in the wizard trail — the recap reads the step's answer, else the flag/arg that resolved it (Session.Presets, or Step.Given for a step its Skip can rule out). A flag answers its step, never only preselects it. Re-init completeness: a re-init step shows the complete candidate list, pre-filled from the config on disk, and reads an answer that may be empty as (value, asked) so a step never reinstates what the user removed. Details: docs/dev/flow-layer.md.
10. Commit messages in English
Every commit message — subject and body — is in English, whatever language the conversation was held in. CHANGELOG.md is in English too (see Docs & README).
11. Validate before commit
make lint # fmt + vet + arch (tools/archlint) + dead (deadcode) + sumtype (go-sumtype) + staticcheck — all gating
make test # go test ./... -race -count=1
make docs # regenerate docs/ from the Cobra tree
make demos # re-record the README GIFs and stills (needs vhs)
make release-notes VERSION=x.y.z # print a CHANGELOG section as release notes
make dupl # clone report, informative only- Tests of
infra/fs,store/, thestatefilepackages and therules/sub-packages use testify (assert,require); each test file holds onlyTest…functions, the example and fakes infixture_test.go, shared helpers inhelpers_test.go. The rest of the repository keeps stdlibtesting. - A new architectural rule goes into
tools/archlint, not into a paragraph here..archlint-migratingand.deadcode-ignoremay only shrink; a new entry needs a stated reason. Seedocs/dev/lint.md. .claude/hooks/pre-commit-gates.shrunsmake lintand ago mod tidycheck on everygit commitand blocks it on failure. It does not run the tests.WTM_SKIP_GATES=1 git commit …only when the gate itself is wrong.- Invoke the
build-validatorsubagent before marking any task done — it adds the-racetest suite, dependency hygiene and the duplication report. - See it run before calling it done — the
wtm-sandboxskill drives the built binary in an isolated sandbox (tmux, VHS). Open a PR with theopen-prskill: base fromwtm tree, that proof attached, the short body template. - Several issues at once — the
orchestrateskill makes this session the orchestrator: one wtm worktree and one Claude worker per Linear issue in herdr panes, product questions relayed to the user, PRs verified before they are reported.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

