contxt scan
Extract @decision, @pattern, and @context annotations from code comments across your codebase.
Comment Syntax
Contxt recognizes three annotation tags anywhere inside a code comment. An optional [category] bracket and a | key: value metadata trailer are both optional but encouraged for richer indexing.
//@decisionUse Prisma over Drizzle|rationale:better TS support//@decision[infrastructure]JWT in httpOnly cookies|rationale:stateless, refresh rotation//@patternAPI route: Zod schema → validate → handler → typed response//@pattern[api]Error handler|when:transient failures//@contextCurrently building user onboarding flow
Multi-line Support
An annotation can span multiple lines. Any immediately following comment line that starts with two slashes and at least two spaces (not a new tag) is treated as a continuation of the previous annotation.
//@decisionUse server-side rendering for all marketing pages//rationale: SEO is critical; hydration cost on static pages//is unjustified. RSC removes the client bundle entirely.//@patternWrap every fetch in a try/catch and log with context//Include: requestId, userId, endpoint, durationMs
Supported Languages
| Language(s) | Comment style | Example |
|---|---|---|
| JavaScript / TypeScript | // | // @decision ... |
| Python / Ruby / Shell | # | # @pattern ... |
| SQL | -- | -- @context ... |
| CSS / C / C++ / Java | /* ... */ | /* @decision ... */ |
| HTML / JSX / Svelte | <!-- ... --> | <!-- @pattern ... --> |
CLI Flags
| Flag | Default | Description |
|---|---|---|
contxt scan | — | Scan the current directory recursively. Respects .contxtignore and .gitignore. |
--path <dir> | ./ | Limit the scan to a specific directory or file. |
--dry-run | false | Print discovered annotations to stdout without writing any drafts. Useful for verifying syntax. |
--auto-confirm | false | Skip the draft review queue and immediately confirm all discovered annotations as active entries. |
Deduplication
Every annotation is content-hashed on first scan. On subsequent runs, Contxt compares the current hash against the stored value and assigns one of four statuses:
Scan complete — 47 files, 12 annotationsNEWsrc/lib/auth.ts:14 @decision JWT in httpOnly cookiesNEWsrc/api/users.ts:3 @pattern API route handlerUPDATEDsrc/lib/db.ts:1 @decision Use Prisma for databaseUNCHANGEDsrc/components/Button.tsx:22 @pattern Button variantsSTALEsrc/lib/old-cache.ts @decision Redis caching strategy3 drafts queued — runcontxt reviewto confirm
.contxtignore
Place a .contxtignore file in your project root to exclude paths from scanning. Syntax is identical to .gitignore — glob patterns, one per line. Contxt also respects your existing .gitignore automatically.
# .contxtignore*.generated.tssrc/vendor/****/__tests__/****/fixtures/**src/lib/legacy-migrations.ts