This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Clarinet is a development toolkit for building, testing, and deploying Clarity smart contracts on the Stacks blockchain. It provides a CLI, REPL, testing framework, debugger, and local devnet environment.
This repository contains three tools htat are built on top of the same Rust components
- CLI
- TypeScript SDK
- VSCode Extension (LSP wrapper)
clarity-repl- Interactive REPL with DAP debugger supportclarity-lsp- Language Server Protocol for IDE integrationclarinet-files- Manifest parsing (Clarinet.toml, project structure)clarinet-deployments- Contract deployment orchestrationclarinet-format- Clarity code formatterstacks-network- Local devnet orchestration (Docker-based)stacks-rpc-client- Stacks node HTTP clientstacks-codec- Stacks wire format encoding/decodingclarinet-utils- Cryptographic utilitieshiro-system-kit- Cross-platform system helpers
clarinet-cli- Main CLI binary. Default member of./cargo.toml
# Build
cargo build
# Run all Rust tests (uses cargo-nextest)
cargo tst
# Run single test
cargo tst -p <crate-name> -- <test-name>
# Run clippy
cargo clippy --workspace --exclude clarinet-sdk-wasm
# Format code
cargo fmt-stacks
# Check formatting
cargo fmt-stacks --checkclarinet-sdk-wasm- Rust core built on top of the core components and CLI, compiled to WebAssemblyclarinet-sdk- TypeScript wrapper aroundclarinet-sdk-wasm
Exposes some of the CLI features thanks to Wasm, and contains the Clarity unit testing framework.
The NPM workspace is configureed in the root ./package.json
# Compile the Wasm bindgen (required before SDK tests)
npm run build:sdk-wasm
# Build the SDK
npm run build:sdk
# Run all SDK tests
npm test -w components/clarinet-sdk/node
# Run tests matching a pattern
npm test -w components/clarinet-sdk/node -- tests/<filename>.test.ts -t <test name pattern>
# Run clippy
cargo clippy --package clarinet-sdk-wasm --target wasm32-unknown-unknownclarity-vscode- TypeScript/WASM extension for Microsoft Visual Studio Code
A wrapper around the clarity-lsp, compiled to Wasm to produced a self-contained VSCode extension binary.
It has it's own package.json in ./components/clarity-vscode/package.json
The commands have to run in the components/clarity-vscode
# Build the extension
npm run vsce:package
# Run end-to-end tests
npm testClarity interpreter and Stacks libraries come from stacks-network/stacks-core git dependency (see Cargo.toml for current revision).
- Follow Conventional Commits for commit messages
- PRs merge via "squash and merge"
Write modern, idiomatic Rust. Prefer:
- Iterator chains and combinators over manual loops where they improve clarity
if let/let else/matchover chains ofif/elsewith.is_some()/.is_ok()checks?for error propagation instead of manualmatch/unwrap- Destructuring in function arguments and match arms
- Meaningful type aliases and newtypes where they aid readability
impl Into<T>/AsRef<T>parameters for flexible function signatures when appropriate- Implement
From<T>(notInto<T>) for type conversions; the blanket impl providesIntofor free - Derive macros (
Clone,Debug,Default, etc.) rather than manual implementations - Standard library traits (
From,Display,FromStr) for type conversions