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.
.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.Cargo.toml:
Rust Code Guidelines
JavaScript/TypeScript Formatting
ESLint & Prettier
All frontend code uses ESLint and Prettier, configured inpackages/tooling-config:
TypeScript Guidelines
Vue Component Guidelines
Naming Conventions
Rust
TypeScript/JavaScript
Files and Directories
Documentation Standards
Code Comments
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 featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasks, dependency updatesci: 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)
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, ormore - Run commands directly without truncation
- Use command-specific flags for limiting output (e.g.,
git log -n 10instead ofgit log | head -10)
Tailwind CSS Guidelines
Use semantic color variables from@modrinth/assets:
Tool Configuration Files
.editorconfig- Editor settings (tabs, line endings)rustfmt.toml- Rust formattingclippy.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 fmtfor Rust - Run
pnpm fixfor 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 preprfor frontend - Run clippy and sqlx prepare for backend
- All tests pass
