Skip to main content

General Principles

Code in the Modrinth monorepo should be:
  • Self-documenting: Clear variable and function names that explain their purpose
  • Consistent: Follow established patterns in the codebase
  • Maintainable: Easy for others to understand and modify
  • Tested: Include appropriate test coverage for new features

Indentation

Use TAB everywhere, never spaces - This is enforced across the entire monorepo.
The .editorconfig file defines:

Exceptions

Only these file types use spaces:
  • YAML files (.yml, .yaml): 2 spaces (required by YAML spec)
  • TOML/JSON (.toml, .json): 2 spaces
  • Markdown (.md): 2 spaces for lists
  • Rust (.rs): Spaces (Rust community standard)

Rust Formatting

rustfmt Configuration

Rust code uses rustfmt with these settings (rustfmt.toml):

Running rustfmt

Clippy Linting

Zero warnings required - CI will fail if there are any clippy warnings.
Custom clippy rules are defined in Cargo.toml:

Rust Code Guidelines

JavaScript/TypeScript Formatting

ESLint & Prettier

All frontend code uses ESLint and Prettier, configured in packages/tooling-config:

TypeScript Guidelines

Vue Component Guidelines

Naming Conventions

Rust

TypeScript/JavaScript

Files and Directories

Documentation Standards

Code Comments

DO NOT use “heading” comments like // === Helper methods ===Use doc comments for public APIs, but avoid inline comments unless absolutely necessary for clarity. Code should aim to be self-documenting!

README Files

Each major package should have a README.md with:
  • Brief description of the package
  • Installation instructions (if applicable)
  • Basic usage examples
  • Link to main documentation

CLAUDE.md Files

Project-specific AI instructions are in CLAUDE.md files:
  • Architecture overview
  • Key directories
  • Development commands
  • Testing instructions
  • Pre-PR requirements

Commit Message Format

Follow the Conventional Commits specification:

Commit Types

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation changes
  • style: Code style changes (formatting, no logic change)
  • refactor: Code refactoring
  • perf: Performance improvements
  • test: Adding or updating tests
  • chore: Maintenance tasks, dependency updates
  • ci: CI/CD changes

Examples

Commit Body Guidelines

  • Focus on why rather than what
  • Keep the first line under 72 characters
  • Use the body to explain context and reasoning
  • Reference issue numbers when applicable

Pre-PR Requirements

Frontend (Web/App)

Run these commands before opening a PR:

Backend (Labrinth)

NEVER run cargo sqlx prepare --workspace - only run it from apps/labrinth/

All Changes

File-Specific Guidelines

No New Scripts

Do not create new non-source code files (e.g., Bash scripts, SQL scripts) unless explicitly needed and approved.

Output Handling

When running commands:
  • DO NOT pipe output through head, tail, less, or more
  • Run commands directly without truncation
  • Use command-specific flags for limiting output (e.g., git log -n 10 instead of git log | head -10)

Tailwind CSS Guidelines

Use semantic color variables from @modrinth/assets:
See the Frontend Web guide for complete color usage rules.

Tool Configuration Files

  • .editorconfig - Editor settings (tabs, line endings)
  • rustfmt.toml - Rust formatting
  • clippy.toml - Clippy linting rules
  • .prettierignore - Files to exclude from Prettier
  • _typos.toml - Spell checking configuration

Summary Checklist

1

Formatting

  • Use tabs for indentation (except YAML, Rust)
  • Run cargo fmt for Rust
  • Run pnpm fix for JS/TS
2

Linting

  • Zero clippy warnings for Rust
  • Zero ESLint errors for JS/TS
  • All imports organized
3

Documentation

  • Doc comments for public APIs
  • No heading comments
  • Updated README if needed
4

Commits

  • Follow conventional commit format
  • Clear, descriptive messages
  • Reference issues when applicable
5

Pre-PR

  • Run pnpm prepr for frontend
  • Run clippy and sqlx prepare for backend
  • All tests pass