CLI Reference
init
Initialize Intent-Guard in a new project.
Usage:
bash
npx intent-guard initEffect:
- Creates
.intentguard/directory. - Generates default
intent.config.yaml. - Adds
.intentguard/to.gitignore.
validate
Scan the project for architectural violations.
Usage:
bash
npx intent-guard validate [options]Options:
--format <json|text>: Output format (default:text)--diff: Validate only changed files (requires git)
Examples:
bash
# Validate entire codebase
npx intent-guard validate
# Validate only changed files (faster)
npx intent-guard validate --diff
# JSON output for CI/CD
npx intent-guard validate --format json
# Combine options
npx intent-guard validate --diff --format jsonExit Codes:
0: Success (No violations)1: Violations found or configuration error
Notes:
--diffmode requires a git repository- Changed files include modified, staged, and untracked files
- Use
--diffin CI/CD to validate only PR changes
rules-for
Get specific rules for a single file. Useful for injecting context into AI prompts.
Usage:
bash
npx intent-guard rules-for <file-path>Example:
bash
npx intent-guard rules-for src/domain/user.tsOutput (JSON):
json
{
"file": "src/domain/user.ts",
"layer": "domain",
"allowedImports": [],
"isProtected": false,
"bannedDependencies": [...]
}