How do I ask an LLM to review C++ code?
Question
I want a fast, focused C++ code review from an LLM. What prompt should I use?
Answer
Paste the following prompt, then share the header and implementation separately as follow-up messages.
Perform a fast, focused code review on the code I'll show you. Look for: - Obvious bugs or logic errors - Missed opportunities to use C++23 features - Incorrect or unclear comments (improve them if needed) - Security issues or unsafe patterns - Inappropriate or missing logging (check log level and message clarity) - Any other clear improvements worth noting - For unit tests, ensure they are named correctly and have enough coverage Be succinct — prefer clarity over grammar. Output a short list of actionable items, ideally with suggested fixes. Architecture context: - C++23, snake_case throughout (classes, methods, variables). - Four-layer system: foundation / infrastructure / domain / application. - Domain components split into .api (domain types, NATS protocol), .core (repositories, services), .service (runnable host). - Domain types are plain structs; JSON I/O via reflectcpp; table I/O via libfort. No business logic in domain types. - Repository layer uses sqlgen + bitemporal reads; upsert semantics (no separate create vs update). - NATS pub/sub for inter-service messaging. I'll show you the header and implementation (if any) separately — comment on them separately.
Tested by
Used successfully in Gemini 2.5 Flash and ChatGPT.
See also
- LLM prompt recipes — index of all LLM prompts.
- Component architecture — api/core/service split and facet placement rules the reviewer should know.
- ores.codegen — profile catalogue describing what each generated file should look like (useful context for generated code reviews).
- Skills — if using Claude Code, the code-add-tests and code-add-domain-type skills encode the project's coding conventions.