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.
# C++ Project Instructions
This is a C++ project.
Important source and configuration paths:
- CMakeLists.txt
- cmake/
- include/
- src/
- tests/
- toolchains/
- compile_commands.json
Generated or disposable paths — do not modify:
- build/
- out/
- bin/
- obj/
- .cache/
- generated binaries
Follow these rules:
- Do not edit generated build directories or binaries.
- Preserve public API and ABI expectations unless the task explicitly changes them.
- Make ownership and lifetime explicit.
- Follow the repository's compiler warnings and language-standard settings.
- Respect platform-specific code paths and feature defines.
- Run focused builds and tests before broader target validation.
Validation:
- cmake -S . -B build
- cmake --build build
- ctest --test-dir build --output-on-failureCommit 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.
Modern C++ applications and libraries using CMake or repository build scripts, clangd, GoogleTest, Catch2, package managers, static analysis, sanitizers, multiple platforms, and normal Git workflows.
Install StemCode and open the project root.
Run StemCode from the repository root so headers, source, build configuration, compile settings, tests, scripts, and Git history can be analyzed together. Keep your compiler, debugger, profiler, and platform SDKs as the source of truth for validation.
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.
Expose headers, source, build files, and tests while excluding generated build trees.
C++ behavior depends on more than source files: build flags, include paths, feature defines, generated headers, platform branches, and linked libraries all affect what actually compiles. Keep authoritative build configuration visible.
Keep source-of-truth files visible.
CMakeLists.txt
cmake/
include/
src/
tests/
toolchains/
compile_commands.jsonSkip generated or disposable output.
build/
out/
bin/
obj/
.cache/
generated binariesAdd generated paths to Git ignore rules or .stemcode/.stemcodeignore so repository search stays focused.
Understand the project before changing it.
Analyze this C++ repository. Map libraries and executables, public and private headers, ownership boundaries, build targets, compile definitions, platform-specific code, external dependencies, and tests. Explain the main dependency direction before modifying files.
Use clangd with an accurate compilation database.
clangd can provide definitions, references, diagnostics, and type information, but it needs build flags and include paths that match the project. A compile_commands.json file or equivalent configured environment makes semantic navigation much more reliable.
Install clangd and make it available on PATHcmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON/lsp refresh
/lspCombine clangd with repository search for preprocessor branches, generated headers, platform code, build options, registration tables, serialization, and macros. A symbol may have different behavior depending on the active target and compile definitions.
Trace ownership, API boundaries, and build configuration before refactoring.
C++ changes can compile locally and still fail under another target, sanitizer, ABI boundary, or ownership path. Ask StemCode to identify those constraints before editing widely used headers or interfaces.
Review object lifetime
Trace ownership for these objects across constructors, factories, containers, callbacks, threads, and shutdown. Identify dangling-reference or double-ownership risks before changing pointer types.
Refactor a public interface
Find all implementations and consumers of this public interface. Explain source, binary, template, and test impact, then propose a staged migration that keeps targets buildable.
Inspect a hot path
Review this path for unnecessary allocations, copies, virtual dispatch, lock contention, cache-unfriendly data access, and work that should be moved out of the critical loop.
Check platform assumptions
Identify compiler-, platform-, endianness-, alignment-, and feature-macro assumptions in this change. Compare against the repository's supported target branches.
Compile with the project’s actual build configuration and run focused tests first.
CMake examples are useful when the repository uses CMake, but checked-in build scripts and CI are the source of truth. Preserve the compiler, generator, toolchain file, and feature options used by the project.
cmake -S . -B buildcmake --build buildctest --test-dir build --output-on-failureFor memory, threading, or undefined-behavior work, run the project’s sanitizer or static-analysis configuration when available. For multi-platform repositories, validate the affected target matrix rather than assuming one local compiler is enough.
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.
Do not edit generated build directories or binaries.
Preserve public API and ABI expectations unless the task explicitly changes them.
Make ownership and lifetime explicit.
Follow the repository's compiler warnings and language-standard settings.
Respect platform-specific code paths and feature defines.
Run focused builds and tests before broader target validation.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 safety
- undefined behavior and bounds issues
- thread safety and synchronization
- public API or ABI impact
- template and header compile impact
- platform and compiler branches
- build-system changes
- tests, warnings, sanitizers, and static analysisCommon setup questions.
Why is compile_commands.json useful?
It gives clangd the include paths, defines, language mode, and compiler flags needed to understand translation units more accurately. Generate it using the repository’s supported build workflow when possible.
Does this replace the compiler or debugger?
No. StemCode helps investigate and change the repository, while the real compiler, linker, tests, debugger, profilers, sanitizers, and static-analysis tools remain the validation source of truth.
Is this also useful for Unreal C++?
The general C++ guidance applies, but Unreal has additional reflection, module, asset, Blueprint, and build-tool constraints. Use the dedicated Unreal Engine guide for that workflow.
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 →