🧱 archstrict

archstrict checks TypeScript module boundaries, in the sense of ArchUnit (Java) and archspec (Ruby). You declare each module in config: one directory, or one file when its glob names that file. A module shows the rest of the codebase one public-surface file, and anything that file does not export is private.
tsc and type checkers examine types, and ESLint examines style. archstrict examines the boundary: an import that reaches past that public surface into a module's internals is a violation.
Install
Every host starts with the npm package in the project:
npm install -D archstrict
Requires Node.js 22 or newer.
This puts a real archstrict binary at node_modules/.bin/archstrict. The edit hooks and CI run this binary, and the MCP server loads the same installed package.
What each piece does
- The CLI (
npm install -D archstrict) runs init, check, todo, and the other verbs. It is the only piece that finds violations.
- The skill (
skills/archstrict/) teaches an agent to read a violation report and to change the config. A host loads it from its own skill directory, not from node_modules/.
- The AGENTS.md section (
archstrict agents) tells any agent that reads AGENTS.md to run npx archstrict rules <path> before it creates a file or adds an import, and npx archstrict check after it edits. It is a few lines of project instructions, not the skill.
- The edit hooks (Claude Code only) run around each edit. The PreToolUse hook previews the change, and the PostToolUse hook runs
archstrict check <file> and returns any violation into the agent's context. See hook.md.
- The MCP server (Claude Code plugin) gives the agent
check, rules, search, and simulate as tools. When the project has no archstrict install, that server connects with no tools and tells the agent to run npm install -D archstrict.
- CI runs
archstrict check on every change, whichever host made it.
Claude Code
Install the plugin from this repository's marketplace. The plugin carries the skill, the two edit hooks, and the MCP server. Run these inside Claude Code:
/plugin marketplace add meganemura/archstrict
/plugin install archstrict@archstrict
The hooks run the project's own node_modules/.bin/archstrict, so the npm install above is still required. The plugin does not load from node_modules/archstrict/: npm drops the symlinks that the plugin root needs (.claude-plugin/plugin.json, hooks/, mcp/). The package still carries the plugin's files under node_modules/archstrict/.agents/. To try an unreleased checkout, load it for one session with claude --plugin-dir <path-to-clone>.
Other agents (Cursor, Codex, cloud agents)
The edit hooks are Claude Code only. For any other agent, use three pieces:
-
Install the skill from the public repository with the GitHub CLI. Replace cursor with your agent's value from gh skill install --help:
gh skill install meganemura/archstrict archstrict --agent cursor
Install it once for the user, with --scope user, so the skill is not copied into every repository. The default scope is the project: Cursor, Codex, and several other agents share .agents/skills/archstrict/. archstrict agents (the next step) is the per-project AGENTS.md section. It is a few lines of commands, and it is not a second copy of the skill.
-
Add the AGENTS.md section:
npx archstrict agents
-
Run archstrict check in CI. With no edit hook, CI is where a violation from an agent session is caught:
- run: npm ci
- run: npx archstrict check
Quick start
npm install -D archstrict
npx archstrict init
npx archstrict check
init writes archstrict.config.ts when that file is absent, and writes archstrict.types.ts, the module-name union. On a fresh project it declares one module per top-level directory that holds TypeScript source (.ts, .tsx, .mts, .cts), and one module per loose top-level source file, both inside the opened container and at the project root. The container is src/ when that directory holds source, and the project root when src/ is absent or holds none. That map covers every analyzed file. It does not yet name growth seams or check import direction. Run npx archstrict recommend next, group files that change together, and add an edges rule before treating the check as a finished architecture. A later run leaves a hand-edited config in place and only regenerates archstrict.types.ts from declaredModules.
check analyzes the project and prints each violation with a rule id, path:line:col, the evidence, a because reason, and a do: command.