This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Mojo programming language repository, containing the Mojo standard library, examples, and documentation. Mojo is a programming language that bridges the gap between research and production by combining Python syntax and ecosystem with systems programming and metaprogramming features.
./stdlib/scripts/build-stdlib.shThis creates a build/stdlib.mojopkg file in the repo root.
# Run all tests
./stdlib/scripts/run-tests.sh
# Run specific test file
./stdlib/scripts/run-tests.sh ./stdlib/test/utils/test_span.mojo
# Run tests in specific directory
./stdlib/scripts/run-tests.sh ./stdlib/test/utils
# Run specific test suites with lit directly
lit -sv stdlib/test/builtin stdlib/test/collectionsTests are run with -D ASSERT=all by default.
# Run all benchmarks
./stdlib/scripts/run-benchmarks.sh
# Run specific benchmark
./stdlib/scripts/run-benchmarks.sh path/to/benchmark.mojo# Format all Mojo files
mojo format ./
# Format is automatically applied via pre-commit hooksmojo doc --diagnose-missing-doc-strings --validate-doc-strings \
-o /dev/null stdlib/stdlib/stdlib/: Mojo standard library implementationstdlib/stdlib/: Source code organized by module (builtin, collections, memory, etc.)stdlib/test/: Unit tests mirroring the source structurestdlib/benchmarks/: Performance benchmarksstdlib/scripts/: Build and test scriptsstdlib/docs/: Technical documentation
docs/: User-facing documentation and manualexamples/: Mojo example codeintegration-test/: Integration testsproposals/: RFC-style proposal documents
When developing standard library code that imports other standard library modules:
# Build the standard library first
./stdlib/scripts/build-stdlib.sh
# Use the locally built stdlib
MODULAR_MOJO_MAX_IMPORT_PATH=../build mojo main.mojo- Tests use the
littool withFileCheckfor validation - Migrating to use
testingmodule assertions (assert_equal,assert_true, etc.) - Test files must start with:
# RUN: %mojo %s
- Follow value semantics and ownership conventions
- Use
Referencetypes and lifetimes in APIs - Prefer
AnyTypeoverAnyTrivialRegType(except for MLIR interactions)
- Branch from
main: Always work off the main branch (for nightly builds) - Install nightly Mojo: Use the nightly build for development
- Use nightly VS Code extension: Install the Mojo nightly extension
- Small PRs: Keep pull requests under 100 lines when possible
- Test your changes: Run relevant tests before submitting
- Format code: Ensure code passes
mojo format - Document APIs: Add docstrings following the style guide
- Do NOT commit secrets or API keys
- Do NOT break existing APIs without discussion
- Do NOT add dependencies to the stdlib module
- Always sign commits with
Signed-off-by(usegit commit -s) - Always follow the Apache License v2.0 with LLVM Exceptions
- Prefer using Batch tool for multiple file operations to reduce context usage
- When making multiple bash calls, use Batch to run them in parallel
- Performance improvements must include benchmarks
- Don't sacrifice readability for minor performance gains
- Use the benchmarking infrastructure to track regressions
- Linux x86_64 and aarch64
- macOS ARM64
- Windows is not currently supported
The following are private/internal APIs without backward compatibility guarantees:
- MLIR dialects (
pop,kgen,lit) - Compiler runtime features (prefixed with
KGEN_CompilerRT_)
- Bug fixes should include reproducing tests
- New features should align with the roadmap
- All code must have corresponding tests
- Follow the coding style guide strictly
- Use pre-commit hooks for automatic formatting