This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
rbx (rbx-cp on PyPI) is a CLI tool for competitive programming problem setters. It manages the full lifecycle of problems and contests: test generation, solution judging, statement building (PDF/HTML/Markdown), and packaging for judge systems (Polygon, BOCA, MOJ, PKG).
uv sync# Run all tests (exclude CLI tests which are slow)
uv run pytest --ignore=tests/rbx/box/cli
# Run a single test file
uv run pytest tests/path/to/test_file.py
# Run a specific test
uv run pytest tests/path/to/test_file.py::test_function_name
# Run tests in parallel
uv run pytest -n auto
# Run with coverage
uv run pytest --ignore=tests/rbx/box/cli --cov=rbx --cov-branch --cov-report=xml -n autoTest markers: e2e, slow, docker (these are excluded from default CI runs via mise run test).
uv run ruff check . # Lint
uv run ruff check --fix . # Lint with auto-fix
uv run ruff format . # Formatuv run rbx- Single quotes for strings (enforced by ruff)
- Absolute imports only — relative imports are banned (
TIDrule) - Ruff rules enabled:
E4,E7,E9,F,B,I,TID,SLF - Pre-commit hooks run ruff check/format and commitizen (conventional commits)
You MUST use the /commit skill when creating commits. This project enforces Conventional Commits via commitizen (cz_conventional_commits). The pre-commit hook will reject non-compliant messages. See .claude/skills/commit.md for the full workflow and allowed commit types.
For complex modules, see the inner CLAUDE.md files:
rbx/box/CLAUDE.md-- Schema system, build pipeline, solution running, generators, checkers, code compilationrbx/grading/CLAUDE.md-- Grading engine: sandbox execution, caching, storage, resource limitsrbx/box/ui/CLAUDE.md-- Textual TUI: screens, widgets, terminal emulator, navigationrbx/box/packaging/CLAUDE.md-- Packaging for judge systems: Polygon (with API upload), BOCA, MOJ, PKGrbx/box/statements/CLAUDE.md-- Statement building: rbxTeX/LaTeX/Jinja pipeline, conversion steps, templates
Entry point: rbx/box/main.py:app → delegates to Typer commands in rbx/box/cli.py.
Key CLI commands: rbx build, rbx run, rbx stress, rbx statements build, rbx package build, rbx create, rbx ui.
- Package loading (
package.py): Discovers and parsesproblem.rbx.ymlvia Pydantic models inschema.py - Build pipeline (
builder.py): Orchestrates generation → validation → output generation → solution running - Generators (
generators.py): Run generator programs to create test inputs - Validators (
validators.py): Validate inputs against constraints - Solutions (
solutions.py): Run solutions in sandboxed environment, collect verdicts - Checkers (
checkers.py): Verify outputs via checker programs
Low-level sandboxed execution layer:
steps.py: Execution steps andOutcomeenum (AC, WA, TLE, RTE, MLE, OLE, etc.)judge/sandbox.py: Base sandbox interface;sandboxes/stupid_sandbox.py: main implementationcaching.py/steps_with_caching.py: Dependency-aware compilation/execution caching
problem.rbx.yml: Problem structure, test cases, solutions, validatorscontest.rbx.yml: Contest-level settingsenv.rbx.yml: Language settings, compilation flags, sandbox configuration
box/contest/: Contest management and multi-problem operationsbox/packaging/: Export to judge formats (Polygon, BOCA, MOJ, PKG); Polygon has API upload supportbox/statements/: Statement building with LaTeX, Jinja, Markdown; multi-language supportbox/stressing/: Stress testing with generator/finder parsersbox/ui/: Textual-based TUI (textualframework)box/wizard/: AI-powered problem creation usingopenai-agentsSDK
- Async throughout: Most operations are async;
syncerbridges sync Typer commands to async code - Pydantic v2: Extensive use for all configuration, schemas, and data validation
@package.within_problemdecorator: Guards CLI commands to ensure they run inside a valid problem directory- Rich output: Custom Rich console theme in
console.py - Caching via symlinks:
FileCacheruses symlinks; symlink support is checked at startup
- Reuse existing pytest fixtures from
tests/rbx/conftest.pyandtests/rbx/box/conftest.py - Key fixtures:
cleandir,cleandir_with_testdata(uses@pytest.mark.test_pkg),pkg_from_testdata,testing_pkg,mock_pdflatex - Test behavior, not implementation details; avoid mocking private functions
- Use
mock.patchfrom stdlib; assert over entire objects where possible - Reuse files in
testdata/folders or create new ones in a folder related to the test - Always run written tests to verify they pass