Grain

•

Automatically discovers and documents the unwritten coding conventions and architectural patterns within a codebase by analyzing its syntax trees and Git history.

Grain addresses the common problem where coding agents or new developers struggle to adhere to a project's implicit conventions, as these rules are rarely fully documented. It solves this by mining these "unwritten rules" directly from the codebase's syntax trees and its entire Git history. Unlike tools that *enforce* declared intent, Grain *surfaces* the practiced norms, acting as an instrument to read and understand the actual architecture and coding style of a repository. It provides insights into placement, style, and structure, offering a factual basis for understanding how a repository "does things."

Key Features

01Mines coding conventions and architectural patterns from code and Git history with a denominator on every claim.
02Functions as an MCP server, enabling integration with AI coding agents like Claude Code and other MCP-speaking tools.
03Offers a suite of slash commands and CLI verbs for querying conventions, checking file conformance, reviewing changes, and reporting overall codebase status.
040 GitHub stars
05Provides placement advice before file creation and identifies deviations after edits, delivered via pre-write and post-edit hooks.
06Generates standalone Markdown documents of top conventions and can export the full model as structured JSON data.

Use Cases

01Guiding AI coding agents to produce code that aligns with a repository's established conventions and architectural style.
02Performing code reviews by highlighting deviations from observed norms in new or changed files, ensuring consistency.
03Onboarding new developers by providing an objective understanding of a codebase's actual practices and exemplary patterns.