C++20 coroutines skill for understanding coroutine mechanics and debugging.

MITAuto-check passedDevelopment

Install Cpp Coroutines

skills CLI
$ npx skills add mohitmishra786/low-level-dev-skills --skill cpp-coroutines -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mohitmishra786/low-level-dev-skills cpp-coroutines --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/low-level-programming/cpp-coroutines .claude/skills/cpp-coroutines && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cpp-coroutines
GitHub stars
253
Token cost
~2.5k tokens
SKILL.md length
389 words
Files
1
Skills in repo
138
Repo updated
First seen
Licence
MIT

At a glance

C++20 coroutines skill for understanding coroutine mechanics and debugging.

  • Works in 11 steps: The three coroutine keywords → Minimal coroutine type — Task → Generator with co_yield → …
  • Working with coawait
  • SKILL.md covers Purpose, Triggers, Workflow and Related skills
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Cpp Coroutines is an agent skill from mohitmishra786/low-level-dev-skills. C++20 coroutines skill for understanding coroutine mechanics and debugging. Use when working with coawait, coyield, coreturn, implementing promisetype, understanding coroutine frame layout, debugging suspended coroutines in GDB, or inspecting frame allocation with Compiler Explorer. Activates on queries about C++20 coroutines, coawait, coyield, promisetype, coroutinehandle, coroutine suspension, or coroutine frame.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Debugging. It works with C++. The repository describes itself as: A curated suite of AI agent skills for systems and low-level programming with C/C++, Rust, and Zig toolchains, covering compilers, debuggers, profilers, build systems…. The licence is MIT.

When your agent uses it

  • Working with coawait
  • Implementing promisetype
  • Understanding coroutine frame layout
  • Debugging suspended coroutines in GDB

Example prompts

  • “/cpp-coroutines”

Workflow steps

11 steps, taken from the step headings in SKILL.md.

  1. The three coroutine keywords
  2. Minimal coroutine type — Task
  3. Generator with co_yield
  4. Awaitable — custom co_await target
  5. Coroutine frame layout and memory
  6. Debugging suspended coroutines in GDB
  7. Boost.Asio co_spawn and co_await
  8. std::generator (C++23)
  9. Coroutine frame layout in GDB
  10. Compilation time impact
  11. Common pitfalls

What it can do on your machine

Read from SKILL.md and the folder at commit bdc5847. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp, bash and gdb).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cpp Coroutines loads about 2.5k tokens when it runs. Until then it costs about 110 tokens; SKILL.md has 389 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mohitmishra786/low-level-dev-skills at commit bdc5847, republished under its MIT licence (© mohitmishra786). 389 words, ~2,537 tokens.

Download SKILL.mdSave it as .claude/skills/cpp-coroutines/SKILL.md (or your agent's skills folder).
name
cpp-coroutines
description
C++20 coroutines skill for understanding coroutine mechanics and debugging. Use when working with co_await, co_yield, co_return, implementing promise_type, understanding coroutine frame layout, debugging suspended coroutines in GDB, or inspecting frame allocation with Compiler Explorer. Activates on queries about C++20 coroutines, co_await, co_yield, promise_type, coroutine_handle, coroutine suspension, or coroutine frame.

C++20 Coroutines

Purpose

Guide agents through C++20 coroutine mechanics: co_await, co_yield, co_return, implementing the required promise_type, understanding coroutine frame memory layout, debugging suspended coroutines in GDB, and reducing frame allocation overhead.

Triggers

  • "How do co_await, co_yield, and co_return work?"
  • "How do I implement promise_type for a coroutine?"
  • "How does a coroutine suspend and resume?"
  • "How do I debug a suspended coroutine in GDB?"
  • "How much memory does a coroutine frame use?"
  • "How do I write a generator with co_yield?"

Workflow

1. The three coroutine keywords
cpp
// co_return — return a value and end the coroutine
co_return value;

// co_yield — produce a value, suspend, resume later
co_yield value;

// co_await — suspend until an awaitable completes
auto result = co_await some_awaitable;

A function is a coroutine if it contains any of these three keywords. Its return type must be a coroutine type with a promise_type.

2. Minimal coroutine type — Task
cpp
#include <coroutine>
#include <stdexcept>
#include <optional>

template <typename T>
struct Task {
    struct promise_type {
        std::optional<T> value;
        std::exception_ptr exception;

        Task get_return_object() {
            return Task{std::coroutine_handle<promise_type>::from_promise(*this)};
        }

        std::suspend_always initial_suspend() { return {}; }  // lazy start
        std::suspend_always final_suspend() noexcept { return {}; }

        void return_value(T v) { value = std::move(v); }

        void unhandled_exception() { exception = std::current_exception(); }
    };

    std::coroutine_handle<promise_type> handle;

    explicit Task(std::coroutine_handle<promise_type> h) : handle(h) {}

    Task(Task&&) = default;
    Task& operator=(Task&&) = default;

    ~Task() { if (handle) handle.destroy(); }

    T get() {
        handle.resume();                      // resume to completion
        if (handle.promise().exception)
            std::rethrow_exception(handle.promise().exception);
        return std::move(*handle.promise().value);
    }
};

// Usage
Task<int> compute() {
    co_return 42;
}

int main() {
    auto task = compute();
    int result = task.get();   // 42
}
3. Generator with co_yield
cpp
template <typename T>
struct Generator {
    struct promise_type {
        T current_value;

        Generator get_return_object() {
            return Generator{std::coroutine_handle<promise_type>::from_promise(*this)};
        }

        std::suspend_always initial_suspend() { return {}; }
        std::suspend_always final_suspend() noexcept { return {}; }
        void return_void() {}
        void unhandled_exception() { throw; }

        std::suspend_always yield_value(T value) {
            current_value = value;
            return {};                     // suspend after yielding
        }
    };

    std::coroutine_handle<promise_type> handle;

    explicit Generator(std::coroutine_handle<promise_type> h) : handle(h) {}
    ~Generator() { if (handle) handle.destroy(); }

    struct iterator {
        std::coroutine_handle<promise_type> handle;
        bool done;

        iterator& operator++() {
            handle.resume();
            done = handle.done();
            return *this;
        }
        T operator*() const { return handle.promise().current_value; }
        bool operator!=(std::default_sentinel_t) const { return !done; }
    };

    iterator begin() {
        handle.resume();                   // advance to first yield
        return {handle, handle.done()};
    }
    std::default_sentinel_t end() { return {}; }
};

// Usage
Generator<int> iota(int start, int end) {
    for (int i = start; i < end; ++i)
        co_yield i;
}

for (int x : iota(0, 5)) {
    std::cout << x << ' ';   // 0 1 2 3 4
}
4. Awaitable — custom co_await target
cpp
// An awaitable has three methods:
// await_ready() — true means don't suspend
// await_suspend(handle) — suspend: store handle, schedule resume
// await_resume() — return value of co_await expression

struct TimerAwaitable {
    int delay_ms;

    bool await_ready() const noexcept { return delay_ms <= 0; }

    void await_suspend(std::coroutine_handle<> h) {
        // Schedule h.resume() to be called after delay
        std::thread([h, this]() {
            std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms));
            h.resume();
        }).detach();
    }

    void await_resume() const noexcept {}  // no return value
};

// suspend_always and suspend_never are built-in awaitables
std::suspend_always{};   // always suspends
std::suspend_never{};    // never suspends (no-op)
5. Coroutine frame layout and memory

The compiler allocates a coroutine frame (heap object) containing:

  • Local variables that live across suspension points
  • The promise object
  • The current suspension state (where to resume)
  • A pointer to the resumption/destruction functions
cpp
// Inspect frame size with Compiler Explorer (godbolt.org)
// Compile with: g++ -std=c++20 -O2 -S
// Look for: operator new call size in the generated asm
// Or: clang -std=c++20 -O2 -emit-llvm -S | grep "coro.size"

// Reduce frame size:
// 1. Don't keep large objects alive across co_await
struct Bad {
    std::vector<char> large_buf;   // whole vector lives in frame
    co_return large_buf.size();    // large_buf crosses suspension
};

// 2. Move data out before suspending
std::vector<char> buf = get_data();
size_t sz = buf.size();            // capture only what's needed
buf.clear();                       // release before suspension
co_await next_event;
// sz still valid; buf released
6. Debugging suspended coroutines in GDB
bash
# Coroutines appear as regular stack frames after resume()
# To inspect a suspended coroutine:

(gdb) info locals
# Look for coroutine_handle variables

# Print the promise object
(gdb) p *(promise_type*)(handle.__handle_)
# GDB 14+ has coroutine-specific support
(gdb) info coroutines        # GCC coroutine support (experimental)

# Step through coroutine execution
(gdb) step     # enters co_await implementation
(gdb) finish   # returns from coroutine frame function
(gdb) next     # step over suspension point

# View all threads (coroutines running on thread pool)
(gdb) info threads
(gdb) thread 2
(gdb) bt
7. Boost.Asio co_spawn and co_await
cpp
#include <boost/asio.hpp>
#include <boost/asio/co_spawn.hpp>
#include <boost/asio/awaitable.hpp>

namespace net = boost::asio;

net::awaitable<void> echo_session(net::ip::tcp::socket socket) {
    char buf[1024];
    for (;;) {
        std::size_t n = co_await socket.async_read_some(net::buffer(buf));
        co_await net::async_write(socket, net::buffer(buf, n));
    }
}

int main() {
    net::io_context io;
    net::co_spawn(io, listen_accept(io), net::detached);
    io.run();
}

co_spawn launches coroutines on an executor; co_await chains completion tokens without callback nesting.

8. std::generator (C++23)
cpp
#include <generator>
#include <ranges>

std::generator<int> fibonacci() {
    int a = 0, b = 1;
    while (true) {
        co_yield a;
        auto next = a + b;
        a = b;
        b = next;
    }
}

// Usage
for (int v : fibonacci() | std::views::take(10))
    printf("%d\n", v);

Lazy sequences without manual coroutine handle management — compiler provides std::generator promise type.

9. Coroutine frame layout in GDB
bash
# Compile with debug info
g++ -std=c++20 -g -O0 -o app app.cpp
gdb ./app
gdb
(gdb) break my_coro
(gdb) run
(gdb) info frame                    # current stack frame
(gdb) info locals                   # promise, handle in scope

# Inspect coroutine frame pointer (compiler-specific mangling)
(gdb) p *(MyPromise*)h.address()    # h = coroutine_handle

# GCC coroutine support (GCC 14+)
(gdb) info coroutines

# Pretty-print promise state
(gdb) set print pretty on
(gdb) p promise

Suspended coroutines may not appear on stack until resumed — trace via stored coroutine_handle.

Show full SKILL.md (170 more words)Show less
10. Compilation time impact

Coroutines increase template instantiation and header parsing cost:

MitigationEffect
-O2 HALOReduces generated frame glue
Out-of-line co_await in .cppCuts recompilation cascade
Pimpl for coroutine return typesHides awaitable templates from headers
ccache / modulesSee skills/rust/rust-build-times patterns for C++

Measure with g++ -ftime-report or clang -ftime-trace. Coroutine-heavy headers (Asio) benefit from unity builds sparingly — balance with RAM use.

11. Common pitfalls
IssueCauseFix
co_await in a non-coroutineFunction missing coroutine return typeChange return type to a coroutine type
Dangling handle after co_returnUsing handle after coroutine finishesCheck handle.done() before resume
Double-resumeResuming an already-resumed coroutineTrack state; only resume when suspended
Coroutine frame never freedForgot handle.destroy()Use RAII wrapper (Task, Generator)
Heap allocation overheadNew frame per coroutine callEnable HALO (Heap Allocation eLision Optimization) with -O2
Recursive co_await depthStack overflow from deep chainsUse std::coroutine_handle<> tail-call pattern
  • Use skills/compilers/cpp-templates for other advanced C++20 features
  • Use skills/rust/rust-async-internals for Rust's equivalent Future/Poll model
  • Use skills/debuggers/gdb for GDB session management

© mohitmishra786, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/low-level-programming/cpp-coroutines of mohitmishra786/low-level-dev-skills.

Open the folder on GitHubat commit bdc5847

Compare with similar skills

Cpp Coroutines next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cpp Coroutines compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cpp Coroutines this skillmohitmishra786/low-level-dev-skills253—~2.5kAutomated safety check: PassMIT
Extempore JIT Debugging Guidedigego/extempore1.5k—~4.4kAutomated safety check: PassNone
OpenROAD Bug FixerThe-OpenROAD-Project/OpenROAD3.2k—~784Automated safety check: PassBSD-3-Clause
Cppcrazyguitar/cppcheatsheet290—~1.8kAutomated safety check: PassMIT
MCP Debuggerdebugmcp/mcp-debugger171—~3.8kAutomated safety check: PassMIT
Dbgtheodo-group/debug-that158—~1.9kAutomated safety check: PassMIT

Similar skills

  • Debugging guide for Extempore covering its three layers, compilation paths, startup sequence and the batch, eval and interactive modes used to isolate JIT problems.

    1.5k GitHub stars~4.4k tokensUpdated 13 days ago
    DevelopmentAuto-check passed
  • OpenROAD Bug Fixer

    The-OpenROAD-Project/OpenROAD

    Fixes an OpenROAD bug from a GitHub issue or error code: finds the root cause, implements the fix, adds a regression test and prepares a signed-off commit.

    3.2k GitHub stars~784 tokensUpdated today
    DevelopmentAuto-check passed
  • Cpp

    crazyguitar/cppcheatsheet

    Comprehensive C/C++ programming reference covering everything from C11-C23 and C++11-C++23, system programming, CUDA GPU computing, debugging tools, Rust interop, and advanced topics.

    290 GitHub stars~1.8k tokensUpdated 5 days ago
    DevelopmentAuto-check passed
  • MCP Debugger

    debugmcp/mcp-debugger

    A skill your agent uses when investigating a bug, failing test, or unexpected runtime behavior and the mcp-debugger MCP server is available — drives real step-through debuggers (breakpoints, stack…

    171 GitHub stars~3.8k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Dbg

    theodo-group/debug-that

    Debug applications using the dbg CLI debugger. An agent skill from theodo-group/debug-that.

    158 GitHub stars~1.9k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed
  • Ue Live Debugging

    JasonMa0012/MooaToon

    A skill your agent uses when debugging UE C++ crashes, runtime bugs, or unexpected behavior with Rider MCP available.

    749 GitHub stars~2.9k tokensUpdated 19 days ago
    DevelopmentAuto-check: notes

More from mohitmishra786/low-level-dev-skills

All 138 skills in this repo
  • ARM and AArch64 Assembly

    mohitmishra786/low-level-dev-skills

    Guides reading and writing AArch64 and ARM Thumb assembly: compiler output, inline asm, registers, the AAPCS calling convention and NEON or SVE basics.

    253 GitHub stars~1.9k tokensUpdated 3 mo ago
    Auto-check passed
  • RISC-V Assembly Guide

    mohitmishra786/low-level-dev-skills

    Reference for RISC-V assembly on RV32 and RV64: register names and calling convention, extension naming, GCC and Clang inline asm, and QEMU with GDB debugging.

    253 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check passed
  • x86-64 Assembly Reference

    mohitmishra786/low-level-dev-skills

    Explains x86-64 registers, the System V AMD64 calling convention, and how to read compiler-generated or inline assembly.

    253 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Bazel for C and C++

    mohitmishra786/low-level-dev-skills

    Guides your agent through Bazel for C/C++ projects: BUILD files, Bzlmod dependencies, toolchain registration, remote execution, dependency queries and sandbox debugging.

    253 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Binary Hardening

    mohitmishra786/low-level-dev-skills

    Binary hardening skill for security-hardened C/C++ builds. An agent skill from mohitmishra786/low-level-dev-skills.

    253 GitHub stars~2k tokensUpdated 3 mo ago
    Auto-check passed
  • Binutils

    mohitmishra786/low-level-dev-skills

    GNU binutils skill for binary manipulation and analysis. An agent skill from mohitmishra786/low-level-dev-skills.

    253 GitHub stars~1.2k tokensUpdated 3 mo ago
    Auto-check passed

Works with

Categories

Questions about Cpp Coroutines

What does Cpp Coroutines do?

C++20 coroutines skill for understanding coroutine mechanics and debugging. Cpp Coroutines is an agent skill from mohitmishra786/low-level-dev-skills. C++20 coroutines skill for understanding coroutine mechanics and debugging.

When should I use Cpp Coroutines?

Cpp Coroutines fits situations like: working with coawait; implementing promisetype; understanding coroutine frame layout; debugging suspended coroutines in GDB.

How do I install Cpp Coroutines in Claude Code?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill cpp-coroutines -a claude-code`. Or copy the skill folder (skills/low-level-programming/cpp-coroutines in mohitmishra786/low-level-dev-skills) into .claude/skills/cpp-coroutines in your project. Claude Code loads it when a task matches its description.

How do I install Cpp Coroutines in Codex?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill cpp-coroutines -a codex`. Or copy the skill folder (skills/low-level-programming/cpp-coroutines in mohitmishra786/low-level-dev-skills) into .agents/skills/cpp-coroutines in your project. Codex loads it when a task matches its description.

Can I use Cpp Coroutines in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mohitmishra786/low-level-dev-skills --skill cpp-coroutines -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cpp-coroutines, .gemini/skills/cpp-coroutines, .github/skills/cpp-coroutines and .opencode/skills/cpp-coroutines in your project.

What does Cpp Coroutines need to run?

SKILL.md names no scripts, command-line tools or credentials: Cpp Coroutines is instructions for the agent only.

Does Cpp Coroutines access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cpp Coroutines safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cpp Coroutines use?

Cpp Coroutines is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cpp Coroutines use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cpp Coroutines?

Skills that share tags, products or a category with Cpp Coroutines: Extempore JIT Debugging Guide (digego/extempore, 1.5k stars), OpenROAD Bug Fixer (The-OpenROAD-Project/OpenROAD, 3.2k stars), Cpp (crazyguitar/cppcheatsheet, 290 stars) and MCP Debugger (debugmcp/mcp-debugger, 171 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cpp Coroutines?

mohitmishra786 (a GitHub user) maintains it in mohitmishra786/low-level-dev-skills, which has 253 GitHub stars. The repository holds 138 skills in this directory. The repository was last updated on June 27, 2026.

Source: mohitmishra786/low-level-dev-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.