<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cmake on RockB</title><link>https://baeseokjae.github.io/tags/cmake/</link><description>Recent content in Cmake on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 19 Sep 2026 01:01:48 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/cmake/index.xml" rel="self" type="application/rss+xml"/><item><title>C++ Coding Agent Guide: AI Pair Programming for Systems Development in 2026</title><link>https://baeseokjae.github.io/posts/cpp-coding-agents-ai-systems-development/</link><pubDate>Sat, 19 Sep 2026 01:01:48 +0000</pubDate><guid>https://baeseokjae.github.io/posts/cpp-coding-agents-ai-systems-development/</guid><description>The 2026 guide to using a C++ coding agent: best agents, agent-ready repos, CMake verification loops, and memory-safety guardrails for systems development.</description><content:encoded><![CDATA[<p>A C++ coding agent works best when your repository is set up so it can build and verify its own edits—the median C++ repo scores just 42/100 on agent-readiness because 88% pin no toolchain version and 78% leave no discoverable test command. In 2026, roughly 90% of professional developers use at least one AI coding tool at work, and CLI-based agentic tools such as Claude Code handle cross-file systems refactors better than IDE composers like Cursor. This guide shows you which agent to pick, how to make C++ repos agent-friendly, and how to keep AI-generated C++ memory-safe at agent speed.</p>
<h2 id="why-c-is-the-highest-stakes-frontier-for-ai-pair-programming">Why C++ Is the Highest-Stakes Frontier for AI Pair Programming</h2>
<p>C++ sits at an unusual intersection: it is among the most technically demanding languages to write correctly, yet it powers the operating systems kernels, game engines, firmware, fintech, and trading systems where bugs are the most expensive. That makes it both the hardest and the highest-value target for AI pair programming.</p>
<p>The stakes are literal. Memory-safety bugs account for 65–70% of high and critical severity vulnerabilities in Chrome, Android, iOS, Windows, and the Linux kernel, year after year, according to Endor Labs analysis. When you hand a C++ codebase to an AI agent, you are asking a system that <em>imitates the patterns around it</em> to produce correct code in a language where an off-by-one on an array index can corrupt memory silently. In old, C-style codebases, agents reliably reproduce the same classes of memory-corruption bugs that humans produce—only faster than a reviewer can keep up.</p>
<p>At the same time, adoption is surging. The AI code-assistant market was roughly $3.5 billion in 2025 (Gartner), and GitHub Copilot reached 4.7 million paid subscribers by January 2026. AI-authored code now makes up 26.9% of all production code, up from 22% the prior quarter. The industry has decided to let agents write systems code. The question is whether our guardrails keep pace.</p>
<h2 id="how-c-differs-from-managed-languages-for-coding-agents">How C++ Differs from Managed Languages for Coding Agents</h2>
<p>A coding agent that writes Python, JavaScript, or Go has a fundamentally easier job than one writing C++, and understanding that difference is the key to using a C++ agent well. Four structural differences explain most of the friction:</p>
<p><strong>No standard package manager.</strong> Python has pip, JavaScript has npm, Go has go mod. C++ has <code>find_package</code>, <code>FetchContent</code>, Conan, vcpkg, and dozens of platform-specific incantations. An agent cannot reliably install—or even locate—the dependencies a project needs, so it cannot reproduce your build on its own.</p>
<p><strong>Build-system diversity.</strong> CMake, Bazel, Meson, Makefiles, and hand-rolled build scripts each demand different invocation patterns. The reference project might build with <code>cmake -B build</code>, but the agent has no way to guess that unless the instructions are written down.</p>
<p><strong>Templates and compile-time complexity.</strong> C++ template metaprogramming, concepts, and type deduction produce errors that are notoriously obscure. A small agent edit to a header can trigger a cascade of template errors far from the change site, and the agent struggles to correlate the cause with the symptom.</p>
<p><strong>Memory and lifetime semantics.</strong> Raw pointers, manual <code>new</code>/<code>delete</code>, iterators, and references mean the same correctness rules that a managed-language agent never thinks about. An agent that has internalized smart-pointer idioms in modern C++ is dramatically safer than one defaulting to C-style ownership.</p>
<p>Together these factors explain why C++ repos score the lowest of any major language on agent-readiness. The highest-leverage fix is a single configuration file plus two written-down commands.</p>
<h2 id="the-best-c-coding-agents-in-2026-cli-agents-vs-ide-composer-agents">The Best C++ Coding Agents in 2026: CLI Agents vs IDE Composer Agents</h2>
<p>C++ agents in 2026 split into two families with genuinely different strengths, and the best setups use both.</p>
<p><strong>CLI/agentic-loop agents</strong> (Claude Code, Aider, Codex) read files as needed and maintain a running mental model of the entire codebase across tool calls. They are built to reason about cross-file changes—exactly what a systems refactor demands. You tell them &ldquo;migrate this subsystem from raw pointers to <code>std::span</code>,&rdquo; and they trace the affected headers, translation units, and call sites themselves. Their weakness is the opposite: they do not live in your editor, so granular, in-the-moment completions are clunkier.</p>
<p><strong>IDE-composer agents</strong> (Cursor, GitHub Copilot) operate inside your editor and depend on you <em>mentioning</em> the files they should consider. They excel at single-file edits and small, local changes where the scope is obvious. Their weakness is context: on a large C++ refactor, the context window fills up fast, and because the agent only reasons about files you @-mention, it can miss the distant header that its edit breaks.</p>
<p>The research-backed pattern is the hybrid: use an IDE composer for granular single-file work, and a CLI agent for cross-file refactors, verifying with the full test suite after each phase.</p>
<h2 id="claude-code-vs-cursor-vs-copilot-vs-aider-for-c-work">Claude Code vs Cursor vs Copilot vs Aider for C++ Work</h2>
<table>
  <thead>
      <tr>
          <th>Agent</th>
          <th>Type</th>
          <th>Best for C++</th>
          <th>Watch out for</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Claude Code</td>
          <td>CLI agentic</td>
          <td>Cross-file refactors, building a codebase mental model, memory-safe modern C++ idioms</td>
          <td>Steeper learning curve; needs a well-configured build/test loop</td>
      </tr>
      <tr>
          <td>Cursor</td>
          <td>IDE composer</td>
          <td>Single-file edits, in-editor completions with compiler-aware suggestions</td>
          <td>Context fills on large refactors; depends on you @-mentioning files</td>
      </tr>
      <tr>
          <td>GitHub Copilot</td>
          <td>IDE composer</td>
          <td>Inline completions, quick local edits (29% global work adoption)</td>
          <td>Best as a complement, not for whole-subsystem changes</td>
      </tr>
      <tr>
          <td>Aider</td>
          <td>Terminal-based</td>
          <td>Git-centric, scriptable, good for diff-driven review</td>
          <td>Less visual; pair with your own review discipline</td>
      </tr>
  </tbody>
</table>
<p>Adoption numbers contextualize the choice: GitHub Copilot leads worldwide work adoption at 29%, with Cursor and Claude Code each at 18% (JetBrains AI Pulse, January 2026). The leaders differ less in model capability than in workflow fit. For systems work, the deciding factor is how well the agent maintains a whole-codebase model—which is precisely the CLI family&rsquo;s strength.</p>
<h2 id="making-your-c-repo-agent-ready-agentsmd-pinned-toolchains-deterministic-builds">Making Your C++ Repo Agent-Ready: AGENTS.md, Pinned Toolchains, Deterministic Builds</h2>
<p>The single highest-leverage change you can make for a C++ coding agent is to write down how to build and test the project. According to agent-readiness analysis of 41 top C++ repos, 88% pin no toolchain version, 78% leave no discoverable test command, and 78% commit no dependency pinning. The result is an agent that hits template and build errors unrelated to its own edit, burning its context and your time.</p>
<p>The fix is an <code>AGENTS.md</code> file at the repository root. This is the tool-agnostic file every modern agent reads (tool-specific variants such as <code>CLAUDE.md</code> and <code>.cursorrules</code> still work and target specific tools, but <code>AGENTS.md</code> is the durable contract). At minimum it should state:</p>
<ol>
<li><strong>The install command.</strong> Typically <code>cmake -B build -DCMAKE_BUILD_TYPE=Release</code> plus any dependency bootstrap.</li>
<li><strong>The verify loop.</strong> <code>cmake --build build -- -j$(nproc)</code> then <code>ctest --test-dir build</code> (or <code>ctest --output-on-failure</code>).</li>
<li><strong>The toolchain policy.</strong> Pin the compiler and standard, e.g. &ldquo;GCC 13, C++20,&rdquo; and the minimum CMake version, so the agent produces compatible code.</li>
<li><strong>Conventions.</strong> Naming, header style, ownership rules (smart pointers over raw), and whether exceptions are enabled.</li>
</ol>
<p>Deterministic builds matter beyond convenience: a build the agent cannot reproduce is a build the agent cannot verify, and verification is the entire point of pairing. When the loop &ldquo;run build → run tests → iterate&rdquo; works for the agent as reliably as it works for you, you unlock agent autonomy without babysitting.</p>
<h2 id="memory-safety-at-agent-speed-sanitizers-static-analysis-and-human-review">Memory Safety at Agent Speed: Sanitizers, Static Analysis, and Human Review</h2>
<p>The uncomfortable truth about AI-generated C++ is that agents imitate surrounding patterns, so in a legacy codebase full of raw pointers they will reproduce memory-corruption bugs faster than any human can review them. Stack Overflow&rsquo;s 2025 data shows developer trust in AI output fell to 29%, down from 40% the prior year—and memory safety is a large part of why experienced C++ developers are the most skeptical.</p>
<p>Because C++ has no safe-by-default runtime model, you need <em>runtime</em> guardrails that flag actual bugs rather than static heuristics that produce noise. Sanitizers are the closest C++ has to a safety net:</p>
<ul>
<li><strong>AddressSanitizer (ASan)</strong> catches buffer overflows, use-after-free, and leaks.</li>
<li><strong>UndefinedBehaviorSanitizer (UBSan)</strong> flags signed overflow, misaligned access, and other UB.</li>
<li><strong>LeakSanitizer</strong> complements ASan for leak detection.</li>
</ul>
<p>The caveat is real: sanitizers are opt-in and only flag bugs on paths your tests actually exercise. Static analysis alone is not a control at agent speed—the NSA&rsquo;s 2022 guidance to move toward memory-safe languages, and Stroustrup&rsquo;s counter-argument that C++ can be made safer through RAII, smart pointers, <code>std::span</code>, and enforcement, both accept the same premise: untrained C++ is dangerous.</p>
<p>The practical policy for AI pair programming on C++:</p>
<ol>
<li>Build with ASan+UBSan in every agent verification loop (add <code>-fsanitize=address,undefined</code> to the CMake flags). This converts &ldquo;the agent probably corrupted memory somewhere&rdquo; into &ldquo;ctest exited non-zero with a precise stack trace.&rdquo;</li>
<li>Run static analysis as a non-blocking advisory, not a gate.</li>
<li>Require explicit human review of every AI-generated pointer, lifetime, or ownership change. The agent is a multiplier, not a reviewer.</li>
</ol>
<h2 id="practical-c-pair-programming-workflows-refactor-test-verify">Practical C++ Pair-Programming Workflows: Refactor, Test, Verify</h2>
<p>To keep an agent productive without letting it run wild, use small, well-defined verify loops. The research favors the same discipline professional devs apply to large refactors: complete one extracted module at a time and run the full test suite after each phase, rather than dumping a dozen interdependent changes at once.</p>
<p>A reliable C++ agent loop looks like this:</p>
<ol>
<li><strong>Scope the phase.</strong> Decompose the refactor into independent, verifiable chunks.</li>
<li><strong>Hand the agent one chunk</strong> with an explicit contract: expected files, ownership rules, and the test command it must run.</li>
<li><strong>Agent edits, builds, runs tests.</strong> Sanitizers must be enabled; the agent must treat any failure as a block until resolved.</li>
<li><strong>You review the diff</strong> at the ownership/lifetime level, not the token level.</li>
<li><strong>Commit with sanitizer green, then move to the next chunk.</strong></li>
</ol>
<p>Two traps recur. First, letting the agent attempt the entire refactor in one pass—partial-refactor regressions become impossible to localize. Second, skipping the sanitizer build to save time—you lose exactly the signal that distinguishes an agentic C++ edit from a safe one. The average developer reportedly saves about 3.6 hours per week (187 hours a year) with AI tools, but those savings compound only if you spend the reclaimed hours on verification.</p>
<h2 id="c2023-features-that-give-agents-guardrails">C++20/23 Features That Give Agents Guardrails</h2>
<p>Modern C++ is measurably friendlier to agents than legacy C-style code because it gives the compiler—and by extension the agent—explicit intent to reason about:</p>
<ul>
<li><strong>Smart pointers (<code>std::unique_ptr</code>, <code>std::shared_ptr</code>)</strong> encode ownership instead of implying it. An agent cannot &ldquo;forget&rdquo; to delete what it never calls <code>new</code> on.</li>
<li><strong><code>std::span</code></strong> replaces raw pointer + length pairs, eliminating a whole class of buffer-boundary bugs and making iterator hygiene explicit.</li>
<li><strong>Concepts</strong> express interface contracts at compile time, so the agent gets an early, nameable error when its code violates expectations instead of a template-explosion 200 lines down.</li>
<li><strong>Ranges</strong> and <strong>coroutines</strong> provide higher-level, composable control flow that reduces manual loop and iterator fiddling.</li>
</ul>
<p>The practical implication: if your goal is AI pair programming, investing in modern C++ idioms is not stylistic hygiene—it is direct agent safety engineering. A C++20 codebase that leans on concepts, smart pointers, and <code>span</code> gives an agent guardrails a plain-C hot-path codebase simply does not have. Agent-specific skills (such as the <code>cpp-pro</code> configuration for C++20/23, template metaprogramming, SIMD, and CMake setups) further focus the model on performance, concurrency, and memory management rather than generic codegen.</p>
<h2 id="choosing-the-right-setup-for-systems-and-embedded-development">Choosing the Right Setup for Systems and Embedded Development</h2>
<p>Whether a C++ coding agent is a sound investment for you depends on two things: your domain&rsquo;s safety tolerance and your repository&rsquo;s readiness.</p>
<p><strong>Low-risk domains (tooling, analytics, internal libraries):</strong> You can lean on agents aggressively. The modern-C++ guardrails plus sanitizer loops catch most mistakes, and the stakes of a latent bug are manageable. Default to agentic CLI tools with a strong <code>AGENTS.md</code>.</p>
<p><strong>High-risk domains (embedded firmware, kernels, safety-critical, financial):</strong> Treat the agent as a high-speed drafting assistant with the same verification bar you hold for any human engineer. Pin the toolchain, enable sanitizers across all tests, add cross-compilation toolchain files for embedded targets, and require human sign-off on every memory/lifetime change. Your review is the difference between a useful multiplier and a liability.</p>
<p>For embedded specifically, bake cross-compile into the agent loop (<code>--toolchain</code> files in CMake) and configure the sanitizer/emulator path explicitly—an agent that &ldquo;builds fine&rdquo; on the host but targets the wrong architecture is dangerously plausible.</p>
<h2 id="final-thoughts-and-next-steps">Final Thoughts and Next Steps</h2>
<p>C++ coding agents in 2026 are real, widely adopted, and genuinely effective—the 90% of professional developers using AI tools are not delusional. But C++ rewards preparation more than any other language. The agent&rsquo;s ceiling is set by your repository and your guardrails: write an <code>AGENTS.md</code> with an install command and a discoverable <code>ctest</code> loop, pin your toolchain, build with sanitizers, keep memory/lifetime changes under human review, and prefer modern C++ idioms that give the model something safe to imitate.</p>
<p>Start with three concrete actions: add the <code>AGENTS.md</code> build and verify commands, enable ASan/UBSan in your CMake test configuration, and run one bounded refactor (say, migrating one module from raw pointers to <code>std::span</code>) with a CLI agent while you review the diff. That single loop is the highest-leverage way to begin AI pair programming on systems code.</p>
<h2 id="faq">FAQ</h2>
<p><strong>Is a C++ coding agent actually good at systems programming?</strong>
Yes, when the repository is agent-ready. The bottleneck is not the model but the build and test loop: C++ repos score lowest on agent-readiness (median 42/100) largely because they leave no documented build or test commands. Add an <code>AGENTS.md</code> with an install and <code>ctest</code> command and the agent succeeds dramatically more often.</p>
<p><strong>Which coding agent is best for C++ in 2026?</strong>
For cross-file refactors, CLI agentic tools like Claude Code and Aider (which maintain a whole-codebase model) are the strongest. For single-file edits and inline completions, IDE composers like Cursor and GitHub Copilot are more convenient. Most teams use a hybrid, using a CLI agent for refactors and an IDE composer for granular edits.</p>
<p><strong>How do I make my C++ project agent-friendly?</strong>
Write an <code>AGENTS.md</code> at the repo root that states the install command (<code>cmake -B build</code>), the verify loop (<code>ctest --test-dir build</code>), the pinned toolchain and C++ standard, and ownership conventions. Also pin the toolchain version and dependency versions—88% of top C++ repos pin neither, which is the main cause of agent template and build errors.</p>
<p><strong>Can AI agents write memory-safe C++?</strong>
They can, but only with the right idioms and guardrails. Agents imitate surrounding patterns, so in legacy raw-pointer codebases they reproduce memory bugs faster (memory-safety bugs remain 65–70% of critical vulnerabilities). Prefer smart pointers, <code>std::span</code>, and concepts, and always build with AddressSanitizer and UndefinedBehaviorSanitizer in the agent verification loop.</p>
<p><strong>Do I still need to review AI-generated C++ code?</strong>
Yes, especially memory and lifetime changes. Developer trust in AI output is only 29% in 2025, and sanitizers only flag bugs on tested paths. Keep human review at the ownership/lifetime level, require sanitizer-green tests before commit, and treat the agent as a high-speed drafting assistant rather than a replacement for verification.</p>
]]></content:encoded></item></channel></rss>