Skip to content

feat: add file arguments to check command#147

Merged
rhuanbarreto merged 1 commit into
mainfrom
feat/check-file-flag
Mar 23, 2026
Merged

feat: add file arguments to check command#147
rhuanbarreto merged 1 commit into
mainfrom
feat/check-file-flag

Conversation

@rhuanbarreto

@rhuanbarreto rhuanbarreto commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds positional file arguments to archgate check that scope rule execution to specific files
  • When files are provided, only ADRs whose files glob patterns match are executed; unmatched ADRs are skipped
  • Supports stdin piping for integration with git and other tools
  • Uses existing safePath() security gates for path validation

Usage

# Single file
archgate check src/foo.ts

# Multiple files
archgate check src/foo.ts src/bar.ts

# Piped from git
git diff --name-only | archgate check --json

# Combined with other flags
archgate check --json --adr ARCH-001 src/foo.ts

Motivation

Editor integrations (VS Code, Cursor) need to run archgate check on file save. Without file scoping, every save runs all rules against the entire codebase. With file arguments, only relevant ADRs fire and scopedFiles is narrowed to the specified files — significantly faster for large projects.

Companion PR: archgate/plugins#34 (VS Code extension with live diagnostics)

Changes

File Change
src/commands/check.ts Add [files...] variadic argument, read stdin when piped
src/engine/runner.ts Accept files option, resolve to relative paths, intersect with scopedFiles, skip ADRs with no match
tests/integration/check.test.ts Add 3 tests: single file, multiple files, and ADR skipping when files are out of scope

Test plan

  • archgate check src/foo.ts --json returns only violations for src/foo.ts
  • archgate check src/a.ts src/b.ts --json checks both files
  • archgate check docs/readme.md --json skips ADRs scoped to src/**/*.ts
  • echo "src/foo.ts" | archgate check --json works via stdin pipe
  • archgate check --json (no args) still checks everything
  • Existing tests pass (no regression)

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 23, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: a879aaa
Status: ✅  Deploy successful!
Preview URL: https://73cc2986.archgate-cli.pages.dev
Branch Preview URL: https://feat-check-file-flag.archgate-cli.pages.dev

View logs

@rhuanbarreto rhuanbarreto force-pushed the feat/check-file-flag branch from 45fbcc6 to f40e6a0 Compare March 23, 2026 12:31
@rhuanbarreto rhuanbarreto changed the title feat: add --file flag to check command feat: add file arguments to check command Mar 23, 2026
@rhuanbarreto rhuanbarreto force-pushed the feat/check-file-flag branch 3 times, most recently from 8c516fe to 05d9f84 Compare March 23, 2026 13:27
Accept file paths as positional arguments to scope rule checks:

  archgate check src/foo.ts src/bar.ts
  git diff --name-only | archgate check --json

When files are provided, only ADRs whose file patterns match are
executed, and scopedFiles is narrowed to the intersection. ADRs
with no matching files are skipped entirely. Stdin piping is
supported for integration with git and other tools.

This enables efficient editor integrations (VS Code, Cursor) and
CI pipelines to check only changed files instead of the full codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rhuanbarreto rhuanbarreto force-pushed the feat/check-file-flag branch from 05d9f84 to a879aaa Compare March 23, 2026 13:30
@rhuanbarreto rhuanbarreto merged commit 63299a1 into main Mar 23, 2026
8 checks passed
@rhuanbarreto rhuanbarreto deleted the feat/check-file-flag branch March 23, 2026 13:34
This was referenced Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant