Quick Start
1. Install Archgate
Section titled “1. Install Archgate”If you have not installed the CLI yet, install it globally via npm:
npm install -g archgateSee the Installation page for platform details and troubleshooting.
2. Initialize your project
Section titled “2. Initialize your project”Navigate to your project root and run the init command:
cd my-projectarchgate initThis creates the .archgate/ directory with the following structure:
.archgate/ adrs/ ARCH-001-example.md # Example ADR ARCH-001-example.rules.ts # Example rules file lint/ archgate.config.ts # Archgate configurationThe generated files give you a working example to build on.
3. Edit the example ADR
Section titled “3. Edit the example ADR”Open .archgate/adrs/ARCH-001-example.md. Every ADR starts with YAML frontmatter that defines its identity:
---id: ARCH-001title: Example Decisiondomain: architecturerules: truefiles: ["src/**/*.ts"]---- id — Unique identifier. Convention is
ARCH-NNNbut any string works. - title — Human-readable name for the decision.
- domain — Groups related ADRs together (
architecture,backend,frontend,data, orgeneral). - rules — Set to
trueif this ADR has a companion.rules.tsfile with automated checks. - files — Optional glob patterns that scope which files the rules apply to.
Below the frontmatter, write the decision in markdown. Archgate does not enforce a specific section structure, but the recommended sections are: Context, Decision, Do’s and Don’ts, Consequences, Compliance, and References.
4. Add a companion rules file
Section titled “4. Add a companion rules file”Create a .rules.ts file next to your ADR with the same name prefix. Rules are written in TypeScript using the defineRules function:
import { defineRules } from "archgate/rules";
export default defineRules({ "no-console-error": { description: "Use logError() instead of console.error()", async check(ctx) { for (const file of ctx.scopedFiles) { const matches = await ctx.grep(file, /console\.error\(/); for (const match of matches) { ctx.report.violation({ message: "Use logError() instead of console.error()", file: match.file, line: match.line, fix: "Import logError from your helpers and use it instead", }); } } }, },});Each rule has a unique key, a description, and an async check function. Inside check, you have access to:
ctx.scopedFiles— Files matching the ADR’sfilesglob patterns.ctx.grep(file, pattern)— Search a file for regex matches, returning file paths and line numbers.ctx.report.violation()— Report a violation with a message, file path, line number, and optional fix suggestion.
5. Run checks
Section titled “5. Run checks”Run the compliance checker against your codebase:
archgate checkArchgate loads every ADR with rules: true, executes its companion rules file, and prints results. The exit code tells you the outcome:
| Exit code | Meaning |
|---|---|
| 0 | All rules pass. No violations found. |
| 1 | One or more violations detected. |
| 2 | Internal error (e.g., malformed ADR or rule). |
To check only staged files (useful in pre-commit hooks or CI):
archgate check --stagedWhat’s next?
Section titled “What’s next?”Now that you have a working setup, dive deeper:
Understand the concepts:
- ADRs — What Architecture Decision Records are and how Archgate uses them.
- Rules — How companion
.rules.tsfiles turn decisions into automated checks. - Domains — How domains group related ADRs and scope file matching.
Write your own:
- Writing ADRs — Learn the full ADR format and best practices for writing effective decisions.
- Writing Rules — Explore the rule API, advanced patterns, and how to test your rules.
- Common Rule Patterns — Copy-pasteable patterns for dependency checks, naming conventions, and more.
Integrate into your workflow:
- CI Integration — Wire
archgate checkinto GitHub Actions, GitLab CI, or any pipeline. - Pre-commit Hooks — Run checks locally before every commit.
- Claude Code Plugin — Give AI agents a full governance workflow with role-based skills.
- Cursor Integration — Use Archgate with Cursor IDE for AI-assisted development.