StemCode for Rust Developers: AI Coding with Cargo, rust-analyzer, and explicit ownership.

Use StemCode with Rust, Cargo workspaces, rust-analyzer, Tokio, Axum, Actix Web, tests, Clippy, refactoring, and repository-aware code review.

PUBLISHED 2026-10-01STEMCODE DEVELOPER GUIDELOCAL-FIRST AI CODING
PROJECT INSTRUCTIONS / AGENTS.MD

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.

Keep AGENTS.md practical and repository-specific

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 --workspace

Commit the file with the project so the same instructions are reviewable and shared by everyone using StemCode in the repository.

01 / WHY STEMCODE

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.

GOOD FIT FOR RUST WORK

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.

02 / SETUP

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.

npmnpm install -g stemcode
pnpmpnpm add -g stemcode
cd your-project
stemcode
/init

Keep StemCode at the repository root so project instructions, source, configuration, tests, and Git history are visible from one workspace.

03 / PROJECT CONTEXT

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.

INSPECT

Keep source-of-truth files visible.

Cargo.toml
Cargo.lock
crates/
src/
tests/
benches/
build.rs
IGNORE

Skip generated or disposable output.

target/
dist/
coverage/
temporary generated output

Add generated paths to Git ignore rules or .stemcode/.stemcodeignore so repository search stays focused.

FIRST PROMPT

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.

04 / CODE INTELLIGENCE

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.

RUST-ANALYZERInstall rust-analyzer using your normal Rust toolchain or package manager
/lsp refresh
/lsp
Use both semantic navigation and repository search

Use 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.

05 / DEVELOPMENT WORKFLOW

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.

ASYNC

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.

TRAITS

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.

ERRORS

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.

PERFORMANCE

Review allocation and locking

Inspect this hot path for unnecessary clones, allocations, lock contention, blocking calls inside async tasks, and avoidable serialization work.

06 / BUILD AND TEST

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.

FORMATcargo fmt --check
CHECKcargo check --workspace
CLIPPYcargo clippy --workspace --all-targets
TESTcargo test --workspace

Respect 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.
07 / PROJECT MEMORY

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.
08 / REVIEW

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 results
09 / FAQ

Common 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.

NEXT STEP

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.

INSTALL

Start with the CLI.

npm install -g stemcode
cd your-project
stemcode
LEARN

Go deeper.

Read the full StemCode documentation for providers, permissions, LSP integrations, memory, MCP, CI review, and advanced workspace configuration.

READ THE DOCS →