Skip to main content
skill CX Codex

carbon-lang — Claude Code skill: Carbon and installation

carbon-lang is a Claude Code skill for exploring Carbon syntax, C++ interoperability, and toolchain builds. It supports migration prototyping and language assessment.

MIT 329 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill carbon-lang -a claude-code
Open on GitHub

What carbon-lang does

The skill covers Carbon fundamentals and both directions of C++ interoperability: calling C++ from Carbon and exposing Carbon code to C++. It also introduces checked borrows and maps Carbon constructs to their C++ counterparts. For a source build, it provides carbon-toolchain commands and lists LLVM, Clang, CMake, and Ninja as prerequisites.

Carbon is presented as experimental, with no 1.0 release, and its toolchain changes between versions. That matters for project plans: examples and commands can go stale, and Carbon does not yet have a stable standard library equivalent to C++. The guidance frames Carbon as a language to explore and prototype for migration, rather than a production-ready C++ replacement.

What it helps with

  • learn Carbon syntax from examples
  • call a C++ library from Carbon
  • expose a Carbon API to C++ code
  • build carbon-toolchain from source
  • compare Carbon and C++ for a migration plan

Example prompts for the agent

  • Explain how to call a C++ library from Carbon using Carbon.h.
  • Show me how to build carbon-toolchain and check sample.carbon.
  • Compare Carbon with C++ for gradually migrating an existing project.

How to install carbon-lang

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill carbon-lang -a claude-code

2Manually: put the files in place

~/.claude/skills/carbon-lang/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/carbon-lang/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about carbon-lang

How do I install carbon-lang in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill carbon-lang -a claude-code. The skill file is placed at ~/.claude/skills/carbon-lang/SKILL.md.

What does carbon-lang do?

It guides an agent through Carbon syntax, two-way C++ interoperability, and toolchain builds. It also outlines the language’s experimental constraints.

What do I need to build carbon-toolchain?

The build instructions list LLVM, Clang, CMake, and Ninja. The toolchain is under active development, so build steps can vary across versions.

Source text

SKILL.md · MIT
---
name: carbon-lang
description: Carbon language skill for C++ interop and toolchain. Use when evaluating Carbon syntax, bidirectional C++ interop, building carbon-toolchain, or comparing Carbon vs C++. Activates on queries about Carbon language, Carbon.h, carbon-toolchain, checked borrows, or C++ successor.
---

# Carbon

## Purpose

Guide agents through the Carbon programming language: syntax fundamentals, bidirectional C++ interoperability via `Carbon.h`, building from source with `carbon-toolchain`, the experimental memory safety model (checked borrows), current pre-1.0 limitations, and when to evaluate Carbon versus staying on C++.

## When to Use

- Evaluating Carbon for a greenfield project with heavy C++ dependencies
- Calling C++ libraries from Carbon or exposing Carbon to C++
- Experimenting with Carbon toolchain from GitHub source
- Understanding Carbon's migration path from C++ codebases
- Assessing readiness for production (currently experimental)
- Comparing Carbon ergonomics to modern C++ (C++20/23)

## Workflow

### 1. Project status awareness

```
Carbon (2026 state)
├── Experimental — no 1.0 release
├── Focus: C++ interoperability and migration
├── No production stdlib equivalent to C++ yet
└── Toolchain under active development
```

Use Carbon for exploration and migration prototyping, not production systems without team acceptance of instability.

### 2. Build carbon-toolchain

```bash
git clone https://github.com/carbon-language/carbon-lang
cd carbon-lang

# Prerequisites: LLVM, Clang, CMake, Ninja
./scripts/run_bazelisk.py build \
  //toolchain:install \
  --symlink_prefix=carbon/

# Add to PATH
export PATH="$PWD/carbon/bin:$PATH"

carbon --version
```

```bash
# Online explorer (Compiler Explorer instance)
# http://carbon.compiler-explorer.com/
```

### 3. Basic syntax

```carbon
package Sample api;

fn Add(a: i32, b: i32) -> i32 {
    return a + b;
}

fn Main() -> i32 {
    var x: i32 = 3;
    var y: i32 = 4;
    Print(ToString(Add(x, y)));
    return 0;
}
```

| Carbon | C++ equivalent |
|--------|----------------|
| `fn` | function |
| `var x: i32` | `int32_t x` |
| `class` / `interface` | `class` / pure virtual |
| `impl` | method definitions |
| `package` | namespace/module |

### 4. C++ interop — calling C++ from Carbon

```cpp
// math.h (C++ header)
#pragma once
namespace Math {
    int Add(int a, int b);
}
```

```carbon
// Carbon imports C++ via library directive
package MathInterop api;

import Math;

fn Main() -> i32 {
    var sum: i32 = Math.Add(3, 4);
    return sum;
}
```

Interop uses Clang to parse C++ headers and generate Carbon bindings.

### 5. Carbon.h — exposing Carbon to C++

```carbon
// Exported for C++ consumption
package MyLib api;

export fn PublicApi() -> i32 {
    return 42;
}
```

```cpp
// C++ side includes generated Carbon headers
#include "carbon/generated/MyLib.h"

int main() {
    return MyLib::PublicApi();
}
```

Build system links Carbon object files with C++ via the Carbon toolchain driver.

### 6. Memory safety — checked borrows (experimental)

```carbon
// Conceptual — API evolving
fn Process(data: i32*) -> i32 {
    // Checked borrow: compiler tracks lifetime
    var ref: i32* = data;
    return *ref;
}
```

Carbon aims for memory safety without garbage collection — checked pointers and ownership semantics. Feature maturity varies; check latest design docs.

### 7. Current limitations

- No stable standard library matching C++ `<vector>`, `<thread>`, etc.
- Toolchain APIs change between releases
- IDE support limited compared to C++/Rust
- Cross-compilation story immature
- Community and package ecosystem small

### 8. Carbon vs C++ decision tree

```
Choose Carbon exploration when
├── Large C++ codebase to gradually migrate
├── Team wants improved syntax with C++ interop
└── Can tolerate toolchain churn

Stay on C++ when
├── Production stability required now
├── Need full stdlib, Boost, mature tooling
├── Heavy template metaprogramming investment
└── Platform support beyond Carbon targets
```

### 9. Build a Carbon file

```bash
# Compile and link (toolchain evolving — check docs)
carbon compile sample.carbon --output=sample.o
carbon link sample.o --output=sample

# Typecheck only
carbon compile --phase=check sample.carbon

# Or build from source with Bazel in carbon-lang repo
./scripts/run_bazelisk.py build //toolchain:install --symlink_prefix=carbon/
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Build fails missing LLVM | Wrong LLVM version | Match carbon-lang README LLVM pin |
| C++ import errors | Unsupported C++ features | Simplify header; wrap in C API |
| Syntax changed since tutorial | Pre-1.0 churn | Check latest carbon-lang docs |
| No stdlib for task | Not implemented | Bridge to C++ library temporarily |
| Explorer differs from CLI | Different versions | Use same commit for both |
| Link error with C++ | ABI mismatch | Use Carbon toolchain link driver |

## Related Skills

- `skills/compilers/cpp-templates` — C++ being migrated from
- `skills/compilers/cpp-modules` — C++20 modules comparison
- `skills/compiler-internals/compiler-frontend` — Carbon compiler architecture
- `skills/languages/hare-lang` — alternative systems language
- `skills/compilers/clang` — Clang backend for Carbon
- `skills/compilers/llvm` — LLVM IR pipeline

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Programming languages →

From the same set140

The whole set →
af-xdp Configures AF_XDP sockets and shared UMEM buffers for low-latency packet processing. Helps implement fast network filtering directly in userspace. CX Codex +1 359installs triton-lang triton-lang is a Claude Code skill that teaches agents to write Triton GPU kernels with @triton.jit, masked block operations, atomics, autotuning, and PyTorch integration. CX Codex +1 358installs containers-internals containers-internals is a Claude Code skill for Linux container internals, activated for queries about namespaces, runc, seccomp, and escape vulnerabilities. CX Codex +1 358installs rdma-verbs rdma-verbs guides coding agents through RDMA programming using libibverbs for InfiniBand and RoCE fabrics. Useful when setting up queue pairs or perftest benchmarks. CX Codex +1 356installs riscv-privileged The riscv-privileged skill supports RISC-V kernel and firmware development, covering privileged modes, CSRs, traps, interrupt controllers, OpenSBI, page tables, and QEMU testing. CX Codex +1 355installs mpi Guides agents through distributed-memory programming with MPI, collective communications, hybrid OpenMP patterns, and mpirun execution. CX Codex +1 354installs verilog-basics-for-lowlevel verilog-basics-for-lowlevel — a skill that teaches firmware and kernel engineers to read Verilog RTL: modules, clocking, reset logic, bus protocols. Use it when docs are unclear and hardware behavior explains driver bugs. CX Codex +1 345installs hare-lang hare-lang teaches AI assistants systems programming in Hare: hare build workflows, manual hare.mod project layout, tagged union errors, and C FFI via @extern. CX Codex +1 330installs

Project sponsors

Companies that keep this analytics open