house-rules
house-rules: every folder has house rules — write them down, keep them true. Claude Code plugin & portable Agent Skill (works in Codex too) that documents each directory's file pattern into a short AGENTS.md, kept honest by a pre-push staleness gate.
house-rules
[](https://github.com/Mariusz-Lazarz/house-rules/actions/workflows/ci.yml)
> Every folder has house rules. Write them down. Keep them true.
A Claude Code plugin (and portable [Agent Skill](https://developers.openai.com/codex/skills)
— works in Codex CLI too) that documents each directory's **purpose and local
convention** into a short AGENTS.md — and then keeps those docs honest with
an on-demand freshness check (/house-rules --check) you can wire into your
own pre-push hook or CI, if you want it automatic.
Every area doc answers two questions always, and a third and fourth when the
directory's own files support them, inferred from the files actually on disk
(never from asking you):
> here is the purpose → here is what's here → here is the reference and how to
> extend it (when either genuinely applies)
Install
``bash`
claude plugin marketplace add Mariusz-Lazarz/house-rules
then inside Claude Code:
``
/plugin install house-rules
Codex & other agents
The skill folder is self-contained and follows the open Agent Skills standardSKILL.md
( + bundled scripts/), so any compatible agent can run it:
`bash`
npx skills add Mariusz-Lazarz/house-rules # installs to .agents/skills/ and
# symlinks into detected agents
or copy skills/house-rules/ manually into ~/.agents/skills/ (user-wide) or<repo>/.agents/skills/ (per repo). Codex discovers both locations natively.--init
Every command below (, --check, --all, --backfill, <dir>)
works the same in Codex as in Claude Code.
Quick start
``
/house-rules --init # onboard a repo: create the manifest, scaffold the root index (asks first)
/house-rules src/handlers # document one directory
/house-rules --all # find every undocumented candidate dir, document each via sub-agents
/house-rules --check # audit: drift + undocumented dirs + missing baselines, report only
/house-rules --backfill # baseline area docs that predate the manifest
What it does
/house-rules <dir> — document one directory
Reads 2–4 representative sibling files, extracts the convention (naming, imports,<dir>/AGENTS.md
exports, test co-location) and greps the repo for who calls into this directory,
picks a canonical reference file when one genuinely stands out, and writes a
120–250-word :
`markdown
Area: handlers — HTTP endpoint handlers for the public API
> See @AGENTS.md at the repo root for repo-wide rules.
Purpose ← what this directory does, and how it's called from elsewhere
What's here ← evidence-based inventory: shape (pattern dirs) or per-file jobs (logic dirs)
Reference ← the one file to start from — OPTIONAL, omitted if no natural pick
Extending ← numbered clone-steps or a concrete extension point — OPTIONAL, omitted if neither exists
Tripwires ← observed "never do X" rules — OPTIONAL, only if real
`Runs on an existing doc → surgical update, not a rewrite (your wording is
preserved wherever it is still accurate).
After every doc it also:## Subdirectory Knowledge
1. upserts a one-line entry into a index in your rootAGENTS.md
/CLAUDE.md, so agents landing at the root see what local docs exist;.claude/house-rules.lock.json
2. records the directory's shape hash into .
/house-rules --all — bulk mode
Enumerates every git-tracked directory that looks worth documenting (≥ 2 files ofAGENTS.md
a dominant extension, no , not ignored), filters out vendor/system treesnode_modules
(, venv, dist, dotted dirs, …), asks you per directory, then
documents the approved ones in parallel sub-agent batches. Shared files (root
index, lock manifest) are updated serially by the parent to avoid write races.
/house-rules --init — onboard a project
Consent-driven scaffolding, generates zero docs:.claude/house-rules.lock.json
- creates — the shape-hash baselines and/house-rules --check
discovery ignore list that reads;## Subdirectory Knowledge
- adds an empty section to your root rules file.
Each step is proposed first; nothing happens without a yes. Nothing gets--init
installed anywhere — only writes files inside your repo.
/house-rules --check — audit on demand
The deterministic engine's report mode: which documented directories drifted,
which directories qualify for a doc but have none, and which area docs still
lack a baseline. Writes nothing, blocks nothing, asks for nothing — each
finding comes with the command that fixes it.
/house-rules --backfill — baseline pre-existing docs
Records manifest baselines for area docs that predate.claude/house-rules.lock.json (fills only missing entries, neverdocs/backfill.md
overwrites — real drift is never masked). Previews the list, asks once, then
writes. This is the only supported way to run the bundled backfiller — see
[](docs/backfill.md).
Keeping docs honest — and wiring your own gate
--check is manual by design: this project ships the checks, not anskills/house-rules/scripts/staleness.sh check
installed hook. If you want it automatic, the same deterministic engine
( / discover — no LLM, gitpre-push
blob SHAs hashed from the current worktree in milliseconds) is a couple of
lines to wire into your own hook or a CI step:
`sh`
STALENESS=skills/house-rules/scripts/staleness.sh # path from repo root, or wherever you installed the skill
[ -f .claude/house-rules.lock.json ] || exit 0 # this repo never ran --init
"$STALENESS" check || exit 1
[ -z "$("$STALENESS" discover)" ] || { "$STALENESS" discover; exit 1; }
See [docs/how-it-works.md](docs/how-it-works.md) for the full recipe
(including a CI-step version).
Project state
Everything lives in the target repo, nothing in the plugin:
| Path | Contents |<dir>/AGENTS.md
|---|---|
| | the area docs |AGENTS.md
| root / CLAUDE.md | the ## Subdirectory Knowledge index |.claude/house-rules.lock.json
| | shape-hash baselines + discovery ignore list |
Adopting house-rules in a repo with pre-existing area docs? Run/house-rules --backfill to baseline them (fills only missing entries, neverdocs/backfill.md
overwrites) — see [](docs/backfill.md).
Tuning
| Env var | Default | Effect |HOUSE_RULES_DISCOVER_MIN
|---|---|---|
| | 2 | min files of the dominant extension before a dir is flagged |HOUSE_RULES_DISCOVER_EXCLUDE
| | – | extra comma-separated dir names discovery should skip |
Documentation
In [docs/](docs/README.md):
- [docs/how-it-works.md](docs/how-it-works.md) — start here: all the parts, and how to wire the checks into your own gatedocs/directory-mode.md
- [](docs/directory-mode.md) — /house-rules [<dir> | <file.md>]: document or refresh one directorydocs/all.md
- [](docs/all.md) — /house-rules --all: bulk-document every undocumented candidatedocs/init.md
- [](docs/init.md) — /house-rules --init: onboard a repo (manifest + index skeleton)docs/check.md
- [](docs/check.md) — /house-rules --check: audit doc freshness on demand, report onlydocs/backfill.md
- [](docs/backfill.md) — /house-rules --backfill: baseline area docs that predate the manifest
Update / Uninstall
`bash`
claude plugin update house-rules # pull the latest version
claude plugin uninstall house-rules # remove the plugin (skill)
Nothing else to clean up — house-rules never installs anything outside your.claude/house-rules.lock.json
repo's and the <dir>/AGENTS.md files itAGENTS.md
writes. If you wired the checks into your own pre-push hook or CI, remove that
yourself the same way you added it. The generated files are plain
docs in your repo either way; they stay (and stay useful) no matter what you
do with the plugin.
Tests
`bash`
tests/run.sh
Pure-bash, one file per invocation mode (directory-mode, all, check,init); each builds a throwaway git repo and asserts on exit codes and output
of the bundled scripts. No LLM involved.
Requirements
- git, bash (3.2+ — stock macOS works), python3 (3.8+)sha256sum
- or shasum (GNU coreutils / macOS — detected automatically)
- Claude Code with plugin support
Notes
- /house-rules never writes your root rules file's prose — it only maintains the## Subdirectory Knowledge
list, and only creates the file (minimal) if you--init`.
approve it during
License
MIT
````
/house-rules --init # onboard a repo: create the manifest, scaffold the root index (asks first)
/house-rules src/handlers # document one directory
/house-rules --all # find every undocumented candidate dir, document each via sub-agents
/house-rules --check # audit: drift + undocumented dirs + missing baselines, report only
/house-rules --backfill # baseline area docs that predate the manifest
- git, bash (3.2+ — stock macOS works), python3 (3.8+)
- sha256sum or shasum (GNU coreutils / macOS — detected automatically)
- Claude Code with plugin support