Context Drift scans supported source files, summarizes their naming styles, and highlights the files that changed relative to git or an explicit file list.
|
What it checks
What it ignores
|
npm install
npm run build
npx context-drift check --base mainIf you already know which files changed, you can pass them directly:
npx context-drift check --changed src/cli.ts,src/scanner.tsThe default report is intentionally simple:
Context Drift
Files scanned: 142
Changed files: 3
Format: markdown
Naming conventions:
- PascalCase: 12%
- kebab-case: 18%
- camelCase: 41%
- snake_case: 9%
- lower-case: 20%
- upper-case: 0%The project exposes one command:
context-drift checkOptions:
--base <branch>: diff againstbase...HEADand treat those files as changed.--changed <files>: comma-separated, repo-relative paths to mark as changed.--format <format>: acceptsmarkdownorjsonand is reflected in the report header.
Examples:
npx context-drift check --base origin/main
npx context-drift check --format json
npx context-drift check --changed src/index.ts,src/cli.tsThis repository includes a small clean/drifted Next.js-style example under examples/.
After building, run:
node dist/index.js check --changed "examples/nextjs-drifted/src/utils/apiClient.ts,examples/nextjs-drifted/src/components/user_profile_card.tsx,examples/nextjs-drifted/src/utils/dateFormat.ts"The drifted example includes an API helper in an unusual folder, a snake_case component file, and a date helper that resembles existing utilities.
This repository runs Context Drift automatically on pull requests with
.github/workflows/context-drift.yml. The workflow checks out the full git
history, runs the local action against the pull request diff, and posts or
updates a single bot comment when drift findings exist.
Add this workflow to run Context Drift on pull requests:
name: Context Drift
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
context-drift:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: 7shep/context-drift@v0.1
with:
base-ref: origin/${{ github.base_ref }}
min-confidence: "0.75"
format: markdown
github-token: ${{ secrets.GITHUB_TOKEN }}When github-token is provided on a pull request event, the action posts one Context Drift comment and updates that same comment on later runs.
npm run dev
npm test
npm run typecheckRead CONTRIBUTING.md before opening a pull request.
Typical contribution flow:
- Create a branch for one issue.
- Make the smallest change that solves that issue.
- Run the relevant checks:
npm run buildnpm testnpm run typecheck
- Open a focused PR with a clear summary and validation notes.
- Resolve changed files from
--changedorgit diff --name-only <base>...HEAD. - Scan the repository for supported source files.
- Normalize paths and mark files that are part of the changed set.
- Classify file names into naming styles such as PascalCase, camelCase, kebab-case, and snake_case.
- Print a compact summary that is easy to read in a terminal or CI log.
src/index.tsbootstraps the CLI.src/cli.tsdefines commands and output.src/scanner.tsfinds supported files and normalizes paths.src/git.tsreads git diff output.src/naming.tsclassifies file naming styles.tests/contains the Vitest coverage for the scanner, git helpers, and naming logic.
- Node.js
20or newer - Git for
--basecomparisons