| phase | implementation |
|---|---|
| title | Implementation Guide |
| description | Technical implementation notes, patterns, and code guidelines |
How do we get started?
npm installat repository root.- CLI package local validation commands:
npm run lint(frompackages/cli)nx run cli:test -- --runInBand lint.test.ts(from repo root)
How is the code organized?
packages/cli/src/cli.ts- Registers new
lintcommand and options (--feature,--json).
- Registers new
packages/cli/src/commands/lint.ts- Command entrypoint that runs checks, renders output, and sets process exit code.
packages/cli/src/services/lint/lint.service.ts- Core lint orchestration and business logic only (no terminal rendering).
packages/cli/src/services/lint/rules/- Rule modules split by concern (
base-docs,feature-name,feature-docs,git-worktree).
- Rule modules split by concern (
packages/cli/src/__tests__/services/lint/lint.test.ts- Unit coverage for normalization and check outcomes.
packages/cli/src/__tests__/commands/lint.test.ts- Command-level coverage for orchestration and exit-code behavior.
Key technical details to remember:
- Base readiness checks validate
docs/ai/{requirements,design,planning,implementation,testing}/README.md. - Feature mode normalizes
feature-<name>and<name>into a sharednormalizedName. - Feature names are validated as kebab-case before running feature-level checks.
- Feature mode validates lifecycle docs:
docs/ai/{phase}/feature-<normalizedName>.md
- Git validation behavior:
- Missing git repository => required failure.
- Missing
feature-<name>branch => required failure. - Missing dedicated worktree for branch => warning only.
- Command rendering supports:
- human-readable checklist output
- JSON report output with summary and per-check metadata
runLintChecksaccepts injected dependencies (cwd,existsSync,execFileSync) for testability.- Shared phase-doc rule helper keeps base/feature doc checks consistent while avoiding duplication.
- Check results use a normalized shape (
LintCheckResult) so rendering and JSON use one source of truth. - Required failures drive exit code; warnings are advisory only.
How do pieces connect?
- CLI wiring: Commander action in
packages/cli/src/cli.tscallslintCommand. lintCommanddelegates torunLintChecksthenrenderLintReport.lint.servicecomposes rule modules and usesutil/gitsync helpers to querygit rev-parse,git show-ref, andgit worktree list --porcelain.commands/lintownsrenderLintReportand usesutil/terminal-uifor consistent user-facing output.
How do we handle failures?
- Git command failures are converted into deterministic lint results (miss or warn), not thrown errors.
- Missing files are reported with explicit path and remediation guidance.
- Output includes suggested fixes (for example
npx ai-devkit init,git worktree add ...).
How do we keep it fast?
- Uses direct existence checks and small git commands only.
- No recursive repository scans or network calls.
What security measures are in place?
- Read-only filesystem and git metadata checks only.
- No mutation of repository state.
- Git commands use argument-based process execution (
execFileSync) to avoid shell interpolation risks from user input.
- Design/requirements alignment: aligned for command surface, normalization, check categories, and exit behavior.
- Deviations and gaps:
- Full CLI binary execution via
npm run dev -- lint ...is currently blocked by unrelated pre-existing TypeScript errors insrc/commands/memory.ts.
- Full CLI binary execution via
- Blocking issue found and resolved:
packages/cli/src/services/lint/lint.service.ts: replaced shell-command interpolation with argument-based git execution and added feature-name validation.
- Remaining non-blocking gap:
- Full CLI binary execution remains blocked by unrelated pre-existing TypeScript issues outside this feature.