Give StemCode durable repository instructions before asking it to edit.
Add an AGENTS.md file at the repository root for persistent project instructions. StemCode loads AGENTS.md or .agent/AGENTS.md from the workspace into the model context, so this is the right place for architecture boundaries, generated-file rules, coding conventions, validation expectations, and manual setup notes that should apply across sessions.
Prefer concrete rules the agent can act on: where important source lives, what it must not edit, which patterns it should preserve, and which checks it should run after a change.
# Rust Project Instructions
This is a Rust project.
Important source and configuration paths:
- Cargo.toml
- Cargo.lock
- crates/
- src/
- tests/
- benches/
- build.rs
Generated or disposable paths — do not modify:
- target/
- dist/
- coverage/
- temporary generated output
Follow these rules:
- Respect existing crate and module boundaries.
- Do not edit target or generated build output.
- Prefer existing error types and conversion patterns.
- Avoid unnecessary clone, Arc, Mutex, and boxed trait objects.
- Do not block the async runtime with synchronous I/O or heavy CPU work.
- Run fmt, check, Clippy, and relevant tests before finishing.
Validation:
- cargo fmt --check
- cargo check --workspace
- cargo clippy --workspace --all-targets
- cargo test --workspaceCommit the file with the project so the same instructions are reviewable and shared by everyone using StemCode in the repository.
Use repository-aware AI without replacing the tools your stack already needs.
StemCode works best when it can understand the repository around a task, inspect related files, use code intelligence where available, run the project's normal validation commands, and review the final diff before you accept a change.
Rust applications, CLIs, services, libraries, Cargo workspaces, Tokio, Axum, Actix Web, serde, SQL clients, async systems, unit and integration tests, benchmarks, and normal Git workflows.
Install StemCode and open the project root.
Start StemCode at the Cargo package or workspace root so manifests, lockfiles, crates, features, source, tests, build scripts, and Git history are available in one workspace.
npm install -g stemcodepnpm add -g stemcodecd your-project
stemcode
/initKeep StemCode at the repository root so project instructions, source, configuration, tests, and Git history are visible from one workspace.
Keep crate boundaries, features, source, and tests visible while excluding Cargo build output.
Rust repositories often encode architecture through crates, features, traits, and ownership boundaries. Those files are valuable context; target output and generated artifacts generally are not.
Keep source-of-truth files visible.
Cargo.toml
Cargo.lock
crates/
src/
tests/
benches/
build.rsSkip generated or disposable output.
target/
dist/
coverage/
temporary generated outputAdd generated paths to Git ignore rules or .stemcode/.stemcodeignore so repository search stays focused.
Understand the project before changing it.
Analyze this Rust repository. Map the Cargo workspace, crate responsibilities, feature flags, important traits and implementations, async runtime boundaries, persistence or network layers, tests, and build scripts. Do not modify files yet.
Use rust-analyzer to understand traits, types, references, and diagnostics.
rust-analyzer is particularly valuable in Rust because behavior can be distributed across traits, implementations, generics, feature flags, and macro-heavy APIs.
Install rust-analyzer using your normal Rust toolchain or package manager/lsp refresh
/lspUse semantic navigation together with Cargo manifests and repository search. Feature flags, cfg attributes, proc macros, generated code, and workspace dependencies can change which code actually compiles in a target configuration.
Make ownership, error, async, and crate boundaries explicit before editing.
Ask StemCode to explain lifetimes and ownership only where they matter to the task, then preserve the project’s existing patterns for errors, async execution, traits, and dependency injection rather than adding abstraction for its own sake.
Trace an async request
Trace this request through the Axum or Actix handler, extractors, service layer, async calls, persistence, errors, and tests. Identify blocking work, cancellation assumptions, and shared-state boundaries before editing.
Refactor a trait safely
Find every implementation and caller of this trait, including generic bounds. Explain object-safety, public API, and crate-boundary impact before proposing a staged refactor.
Preserve error context
Review this error path for lost source errors, over-broad mapping, user-facing leakage, and inconsistent conversion between domain and transport errors.
Review allocation and locking
Inspect this hot path for unnecessary clones, allocations, lock contention, blocking calls inside async tasks, and avoidable serialization work.
Use Cargo’s formatter, checker, linter, tests, and build as the validation loop.
Cargo provides a consistent baseline. Repositories may add feature matrices, nextest, deny checks, database setup, integration environments, or platform-specific targets through scripts and CI.
cargo fmt --checkcargo check --workspacecargo clippy --workspace --all-targetscargo test --workspaceRespect the repository’s feature combinations and target matrix. Begin with the affected crate and feature set, then broaden to the workspace after focused checks pass.
Run the smallest relevant validation first. If it passes, run the broader project checks and review the final diff.Keep longer-lived architecture context alongside your project instructions.
Use AGENTS.md for concise rules the agent should follow on every task. Keep longer architecture notes, domain context, and workflow references in repository-level StemCode memory so both stay reviewable and versionable.
Respect existing crate and module boundaries.
Do not edit target or generated build output.
Prefer existing error types and conversion patterns.
Avoid unnecessary clone, Arc, Mutex, and boxed trait objects.
Do not block the async runtime with synchronous I/O or heavy CPU work.
Run fmt, check, Clippy, and relevant tests before finishing.Review the change in terms of your stack, not only the generated code.
Ask StemCode to inspect its own diff and check the integration points that are easiest to miss in a repository-wide change.
- ownership and lifetime correctness
- unnecessary clones and allocations
- Send/Sync and shared-state assumptions
- blocking work in async contexts
- error context and conversions
- feature-flag compatibility
- public crate API impact
- fmt, Clippy, check, and test resultsCommon setup questions.
Does this cover Axum, Actix Web, and Tokio?
Yes. The guide keeps framework-specific routing and runtime behavior in context while treating Cargo, crate boundaries, traits, errors, and tests as the underlying repository workflow.
Should target be indexed?
No in normal development. target is generated build output and can be extremely large. Keep manifests, source, tests, build scripts, and reviewed generated source visible instead.
Can StemCode help with borrow-checker errors?
It can inspect the surrounding types, ownership flow, trait bounds, and compiler diagnostics. The best workflow is to keep the compiler in the loop and prefer a design fix over adding clones simply to silence an error.
Put StemCode to work in a real repository.
Install StemCode, open the project you already work in, and begin with a repository-understanding task before asking the agent to change code. That gives the model better context and keeps the workflow reviewable.
Start with the CLI.
npm install -g stemcode
cd your-project
stemcodeGo deeper.
Read the full StemCode documentation for providers, permissions, LSP integrations, memory, MCP, CI review, and advanced workspace configuration.
READ THE DOCS →