Code quality and readability are first-class priorities in the Graphite project. Clean, well-documented code makes the codebase accessible to new contributors and sustainable over the long term. These guidelines reflect the conventions the team has established — following them closely will make code review go smoothly and your contributions land faster.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/GraphiteEditor/Graphite/llms.txt
Use this file to discover all available pages before exploring further.
Linting
Clippy is the Rust linter of choice for Graphite. It should be enabled automatically in VS Code via the suggested extensions. Run it manually at any time from the project root:Naming
Use descriptive names for variables, functions, and symbols. Minimize abbreviations — prefer spelling out full words in most cases. Monitors are wide enough to display long identifiers, and descriptive names dramatically reduce the mental burden on readers.| ✅ Prefer | ❌ Avoid |
|---|---|
generate_document_format | gen_doc_fmt |
maximum_layer_count | max_lyr_cnt |
evaluate_expression | eval_expr |
maxfor “maximum”evalfor “evaluate”infofor “information”
Whole-Number Floats
Always write whole-number float literals as42. rather than 42.0. This maintains consistency and brevity across the codebase.
Comments
Comments are important — but they must follow consistent formatting conventions:- Use
//for inline comments; use///for doc comments on public items - Always leave one space after
//or/// - Write
//comments in Sentence case (capital first letter) - Do not end a single-sentence
//comment with a period — unless the comment contains multiple sentences - Doc comments (
///) should always end with a period - Avoid
/* */block comment style - Place comments on a separate line above the code they describe, not at the end of the same line
- Do not include commented-out code in PRs open for review unless there is a compelling documented reason
Blank Lines
Blank lines are the paragraphs of source code. Use them to group related lines into logical blocks, just as a writer uses paragraphs to organize prose.- Separate distinct logical steps with a blank line between them
- Aim for at least 10% blank lines in any given block of code
- A long, unbroken wall of logic with no blank lines is a readability concern — find sensible partitions and insert spacing between them
Import Organization
Imports in Graphite follow a specific formatting rule thatrustfmt does not enforce automatically — it must be applied by hand.
Always combine imports that share a common path, but only at the same depth:
:: inside {}:
AI Contribution Policy
Many open source projects — including Graphite — have experienced a rise in low-quality PRs written partly or wholly by AI tools. These waste maintainer time and delay review of genuine contributions. The project has established firm rules to address this.Acceptable AI usage
- Debugging assistance and tab-completion from non-agent tools (e.g., GitHub Copilot inline completions) may assist you — including single lines of code you would have otherwise written yourself — without disclosure.
- AI chat tools (not agents) may help generate small snippets under 40 lines, provided you manually copy, paste, and carefully review every line for correctness and consistency with your own intent. This requires disclosure in your PR.
Unacceptable AI usage
- Agent-driven or “vibe-coded” PRs where the contributor does not understand the code they are submitting
- AI-written PR descriptions, review responses, or issue comments
- Submitting any AI-generated content without disclosure
Required disclosure
Graphite has zero tolerance for undisclosed AI-generated content. If your PR contains any lines you did not personally write using your own understanding:- Leave a self-review comment on the specific lines in the GitHub PR diff immediately after pushing
- Write a detailed, human-authored justification explaining why each line is correct and appropriate
- Be prepared to explain the code in a code review discussion
The standard is simple: you are personally responsible for every line of code you submit. Do not submit code you cannot fully explain and defend.