Grain traces every AI-generated line back to the conversation that created it. See your AI contribution, enforce policies, ship with confidence.
$ grain commit-trend --last 5 ──── Commit Trend ────────────────────────────────────────── SHA AI% Composer Tab Human Message ──────────────────────────────────────────────────────────────────────────────── a3f1e29c 87% +142/-38 +22/-4 +12/-8 feat: add policy engine d90bc144 52% +64/-12 +18/-6 +48/-21 refactor: sanitize paths 7e8f3a01 18% +8/-2 +12/-0 +71/-34 fix: handle empty transcripts c42b91e7 94% +210/-0 +31/-0 +6/-2 feat: conversation ranker 1a0e8d33 41% +29/-14 +0/-0 +55/-22 docs: update README
AI coding tools generate hundreds of lines per session. Code flows from conversations into files into commits — with no audit trail. When something breaks in production, you can't trace it back. When compliance asks, you can't answer.
Three steps from blind spot to full visibility.
Grain reads Cursor's built-in tracking database and agent transcripts locally. No SDK, no wrapper, no instrumentation required.
Every commit is scored with an AI percentage. Conversations are ranked by relevance and linked to the files they changed.
Define policies: max AI%, restricted paths, allowed models. Run grain policy-check in CI. Violations return exit code 1.
See recent commits with AI contribution percentage, broken down by composer, tab-complete, and human-written lines.
Full provenance report: AI score, files changed, linked conversations, transcript excerpts, and model attribution.
See which models were used, which files were touched, time window, summary, and the full transcript of any AI conversation.
Evaluate any commit against configured policies. Returns exit code 1 on violations — drop it into your CI pipeline.
List all configured policies and their thresholds. Know exactly what rules are enforced in your environment.
Four provenance levels — minimal, standard, enhanced, full — that control how much detail is disclosed based on your environment.
$ grain explain a3f1e29c ──── Environment ───────────────────────────────────────── Environment: production Provenance Level: enhanced (level 2) ──── Commit ────────────────────────────────────────────── SHA: a3f1e29c Message: feat: add policy engine Author: jane@company.com Date: 2026-03-05 14:22:08 ──── AI Attribution ────────────────────────────────────── AI%: 87% Composer: +142/-38 Tab: +22/-4 Human: +12/-8 Total: +176/-50 ──── Files Changed ─────────────────────────────────────── • src/analysis/policy.ts • src/commands/policy-check.ts • src/commands/policy-list.ts • src/types.ts ──── Linked Conversations ──────────────────────────────── #1 conv_8a3f21e9 matches: 4 models: claude-4-sonnet via: composer files: src/analysis/policy.ts, src/commands/policy-check.ts query: Build a policy engine that evaluates commits against configurable thresholds… summary: Implemented policy evaluation with five rule types and CI integration
$ grain policy-check a3f1e29c ──── Policy Check ──────────────────────────────────────── Commit: a3f1e29c Environment: production Rules Evaluated: 4 PASS allowed_models Model claude-4-sonnet is allowed PASS restricted_paths No AI changes in restricted paths WARNING ai_contribution AI% 87 exceeds warn threshold 60 VIOLATION agent_mode Agent-mode code requires review Result: 1 warning(s), 1 violation(s)
Define guardrails. Enforce them in CI. Five rule types, zero ambiguity.
Warn or block commits that exceed AI percentage thresholds. Set separate warn and max levels.
Flag AI-generated code in sensitive directories like auth/, billing/, or security/.
Require human review for any code generated by an AI agent in autonomous mode.
Restrict which AI models are permitted to generate code in your repository.
Cap the number of AI code events per commit to prevent bulk AI-generated changes.
grain policy-check returns exit code 1 on violations. Add it to your pipeline in one line.
# Policy configuration policies: ai_contribution: warn_threshold: 60 max_threshold: 90 restricted_paths: - auth/ - billing/ - security/ agent_mode: require_review: true allowed_models: - claude-4-sonnet - claude-4-opus
Grain runs entirely on your machine. No data leaves your environment. No telemetry, no cloud, no accounts.
Three commands. That's it.
Prerequisites: Cursor with AI tracking enabled · Git repository