This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Rustfinity is an interactive learning platform for Rust developers. The repository contains:
- challenges/: Individual coding exercises with starter code, solutions, and tests
- crates/cli: CLI tool for downloading and submitting challenges locally
- crates/rustfinity-runner: Test runner that executes code in secure Docker containers
- crates/syntest: Syntax-based testing library using Rust AST analysis
# Build entire workspace
cargo build
# Build with release optimizations (uses LTO)
cargo build --release
# Run all workspace tests
cargo test
# Run challenge validation tests (ensures all challenges have required files)
cd challenges && cargo test# Test a specific challenge
cargo test -p <challenge-name>
# Example: Test the fibonacci challenge
cargo test -p fibonacci
# Run a single test file
cargo test --test tests -p fibonacci# Build the CLI
cargo build -p rustfinity
# Run CLI commands
cargo run -p rustfinity -- get challenge <challenge-slug># The rustfinity-runner is designed to run in Docker
# It accepts base64-encoded code, tests, and Cargo.toml
cargo run -p rustfinity-runner -- test --code <base64> --tests <base64> --cargo-toml <base64>Each challenge in challenges/<challenge-name>/ follows this strict structure:
- description.md: Challenge instructions and examples
- Cargo.toml: Package definition (package name must match directory name)
- src/lib.rs: Complete solution implementation
- src/starter.rs: Starter code template for users (incomplete solution)
- tests/tests.rs: Test cases that validate the solution
The challenges/tests.rs file validates that all challenges follow this structure.
The workspace uses Cargo's resolver v2 and includes:
challenges- Parent crate that provides shared utilitieschallenges/*- Individual challenge packagescrates/*- Supporting tools (CLI, runner, syntest)
- challenges/lib.rs: Utilities for reading and validating challenges
challenges_json(): Parses challenges.json metadatachallenges_dir_list(): Lists all challenge directoriesget_max_id(): Returns highest challenge ID
- challenges/challenges.json: Metadata for all challenges (id, title, slug, difficulty, track, tags, dates)
- challenges/cli.rs: CLI tool for challenge management
All challenges are registered in challenges/challenges.json with:
- Unique
id(numeric, validated for duplicates) slug(must match directory name)difficulty: BEGINNER, EASY, MEDIUM, HARD, ADVANCEDtrack: RUST_BASICS, CONTROL_FLOW, DSAtags: Array of topic tagscreated_atandupdated_at: ISO 8601 timestamps (validated)
- Create directory under
challenges/<slug>/ - Add required files: description.md, Cargo.toml, src/lib.rs, src/starter.rs, tests/tests.rs
- Ensure Cargo.toml package name matches directory slug
- Add entry to challenges/challenges.json with unique ID (use
challenges::get_max_id()+ 1) - Run
cargo test -p challengesto validate structure
- Challenge tests (
challenges/*/tests/tests.rs): Validate challenge solutions - Structure tests (
challenges/tests.rs): Validate all challenges have required files and metadata - Syntest: AST-based syntax validation for advanced testing scenarios
- Challenge structure validation catches common issues:
- Missing required files
- Mismatched package names
- Duplicate IDs or slugs
- Invalid timestamps
- Missing metadata entries
The rustfinity CLI allows users to download challenges locally:
# Download a specific challenge
rustfinity get challenge <challenge-slug>
# The CLI checks for updates on each run and prompts users to upgrade if outdated- Uses
clapfor command-line parsing reqwestfor HTTP requests (with rustls-tls)tokioasync runtime- Downloads challenges from GitHub repository
- Designed for secure, isolated test execution in Docker
- Uses
ductfor process management - Base64 encoding for code/test transport
- Supports both regular challenges and Rustlings exercises
- AST-based syntax testing using
syncrate - Allows testing code structure without execution
- Use
create_bin_and_run()to compile and execute code snippets
When modifying challenges:
- Edit solution in
src/lib.rs - Update starter template in
src/starter.rs(should be incomplete) - Verify tests in
tests/tests.rspass with solution - Update
description.mdif requirements change - Update
updated_atin challenges.json - Run
cargo test -p challengesto validate structure - Run
cargo test -p <challenge-name>to verify tests pass
- scripts/run-challenge-in-docker.py: Utility for running challenges in Docker environment