Skip to content
cccskills
FreePublished on GitHubEnglish overview

Code style

Apply Carbon toolchain conventions for formatting Bazel, C++, Carbon, Markdown, and Python files. The skill also covers clear comments and documentation, accurate names, design choices, and concise commit descriptions.

OriginalShow the original description

Instructions for code formatting and style guidelines in the Carbon toolchain.

carbon-language/carbon-lang33,929 stars(GitHub 33,929 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Formatting a changed source file
  • Writing or revising code comments
  • Choosing names that match their meaning
  • Preparing a clear commit description

Overview

What it does

This skill describes conventions for editing Carbon toolchain code and documentation. It names the formatting tools and checks for Bazel, C++, Markdown, and Python. The Carbon format command is currently unreliable, so the guidance is to follow existing Carbon code and C++ style. Other topics include writing comments that explain current behavior or its reason, starting documentation with a direct summary, and choosing names that match their actual role or meaning. It also covers keeping documentation consistent with code changes, avoiding changes to the data model just to improve printed output, and describing the result clearly in commit messages.

When it helps

Use it when writing or changing Carbon toolchain code. It is also useful for reviewing whether comments, names, documentation, and commit descriptions follow the project's conventions.

Example requests

  • “Which formatter should I use for this C++ file?”
  • “Check whether this comment and variable name fit the conventions.”
  • “Rewrite this commit description to explain the change clearly.”

Notes

The tools differ by file type. C++ follows the Carbon C++ Project Style Guide, Markdown follows the Google developer documentation style guide, and Python follows PEP 8. The Carbon format command is described as currently not working well.

This overview was written by AI (OpenAI Codex) from the public SKILL.md. Check the original below for the exact behavior.

Document check

AI checked the SKILL.md for operations that need care and for setup requirements. The score comes only from actually running the skill (hands-on test).

SafetyAre sending data, deleting files, and running commands disclosed?
AGoodThe instructions focus on formatting and review, with no external sending or deletion.
Easy setupDoes it need few tools or API keys, and are they documented?
BPartly lackingIt uses `pre-commit` and formatters but does not provide setup steps.

Not counted in the score. Rated by AI (OpenAI Codex) as of Oct 26, 2026. Treat it as a guide and read the original before installing.

Disagree? Request a re-evaluation

Tell us which point is wrong and why. No login needed. We will check it against the SKILL.md, redo the evaluation, and show the result here.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

Files included (1)

  • SKILL.md6.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Code style

<!-- Part of the Carbon Language project, under the Apache License v2.0 with LLVM Exceptions. See /LICENSE for license information. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->

License

Formatting

  • Bazel: Use pre-commit run buildifier --files <file.bzl> to format Bazel files.
  • C++: Use pre-commit run clang-format --files <file.cpp> to format C++ files.
  • Carbon: The toolchain's format command doesn't work well right now. Instead, try to format Carbon code based on other Carbon files and the C++ style.
  • Markdown: Use pre-commit run prettier --files <file.md> to format markdown files.
  • Python: Use pre-commit run black --files <file.py> to format Python files.

Comments

  • Describe the code that is there. A comment should explain what the current code does or why it is the way it is, not narrate what the code used to be. Do not add a comment to justify a deletion or explain that something is no longer necessary; a reader of the new code has no idea what is being contrasted against, and the comment rots as soon as the old shape is forgotten. Put that reasoning in the commit message instead.
  • Do not introduce a local variable just to host a comment. If a call argument reads clearly on its own, inline it rather than naming it so that a comment has somewhere to attach.
  • Lead with a plain summary. Start a doc comment with a direct statement of what the function does or returns, such as "Returns true if the InstKind is a singleton." Put nuance in a following sentence rather than qualifying the summary into something harder to read.
  • Re-read a comment before updating it. When a symbol is renamed or changes meaning, a comment that mentions it is not automatically stale. Work out what the comment actually asserts first: it may be describing what the code uses, which is still true, and rewriting it loses information.

Documentation

This covers standalone prose: /docs, README.md files, and the skill files under .agents/skills.

  • Be true of the tree it lands in. Documentation shipping in the same commit as the code it describes should name that code freely. Documentation that lands separately must not: a reader who greps for an identifier from an unlanded change finds nothing, and a claim that only holds after that change is false until it lands. This is easy to get wrong when writing up a lesson while the change that taught it is still in flight.
  • Use placeholders for illustrations. When an example only needs to show a shape, name it Foo rather than reaching for a real symbol. Save real identifiers for documenting that identifier, where going stale is at least detectable.
  • Make each point stand alone. A reader has none of the discussion that produced it. State the rule, and enough of the reason to apply it, without assuming knowledge of the change that motivated it.

Naming

  • A name is a claim, so keep it true. When a change invalidates the invariant a name describes, rename it in the same change. A factory called MakeSingletonFooId has to be renamed once Foo is no longer a singleton, even though nothing forces you to.
  • Types in a signature are part of the claim. A function returning the id of a namespace should return InstId, not TypeInstId, because a namespace is not a type. Do not let a convenient wider or narrower id type imply something false.
  • Delete a predicate whose name stops distinguishing anything. If a change widens a test so that it no longer says what its name implies, remove it and let callers use the underlying test, rather than keeping a wrapper that sounds meaningful. What callers actually want is often the inverse, and is worth adding under its own name.
  • Name a variable for its role, not its representation. If the role a value plays is unchanged, keep its name even when a change means it is now held or spelled differently.

Commit descriptions

  • Say what the change is, not how you made it. Describe the resulting code. Only describe process when the process is more interesting than the change, as with a large mechanical transformation.
  • Do not narrate your own work. Statements like "each such site was audited" or "we investigated every caller" describe effort, not the change.
  • Omit routine mechanical steps. Do not mention running the testdata autoupdater or the formatter. Every change is expected to include those.
  • Do not enumerate each edit. Describe the change as a whole rather than listing every function or file touched; the diff already lists them.
  • Use the project's terms precisely. Reach for the term of art the codebase uses. Calling something a "type alias" or a "namespace" when it is a named scope misleads, and is worse than a vaguer but accurate word.
  • Scope claims to what changed. Say the specific thing that is now true, rather than a broader statement that happens to contain it.

Design

  • Do not distort the data model to improve output. If printed or golden output is undesirable, change the printer, not the data structures that feed it.

Style Guides

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Use this skill to read GitHub issue details and comments from the command line with `gh`. It covers issues referenced by number or URL, including issues in other repositories, and keeps access read-only so issue state is not changed.

  • Reading an issue and its full comment history
  • Opening an issue referenced by URL
  • Viewing an issue from another repository
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

Agent tools

FreeSummary

Use this skill to guide an AI assistant working in the Carbon repository on viewing, searching, and editing files with specialized environment tools. It also sets rules for temporary files and when custom programs may be used.

  • Choosing approved tools to view, search, or edit files
  • Checking where temporary analysis and test files belong
  • Deciding when a custom transformation program is allowed
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

Bazel usage

FreeSummary

Follow the Carbon project's Bazel workflow through Bazelisk, a version-managing launcher. Learn commands for building targets, running tests and binaries, enabling AddressSanitizer, and refreshing cached state after system dependency changes.

  • Building a Carbon target
  • Running focused project tests
  • Launching a Bazel-built binary
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

Use this skill to implement builtin functions in the Carbon compiler, from registering a function name and checking its signature to evaluating constant calls and generating LLVM IR for runtime calls. It also covers prelude bindings and focused tests.

  • Registering a new Carbon builtin function
  • Adding compile-time evaluation behavior
  • Lowering runtime builtins to LLVM IR
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

Diagnostics

FreeSummary

Use this skill to add or revise diagnostics in the Carbon toolchain. It explains how to register message kinds, format typed arguments, attach source labels and context, and verify that diagnostics follow the project’s wording and test coverage rules.

  • Adding an error or warning to the Carbon compiler
  • Attaching source locations and explanatory labels
  • Checking diagnostic wording and formatting conventions
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

GitHub CLI usage

FreeSummary

Use `gh`, the GitHub command-line tool, to list, inspect, and search issues, pull requests, repositories, and code. The skill also explains read-only REST and GraphQL queries, pagination, and ways to filter or format returned data.

  • Checking an issue or pull request
  • Searching issues, code, or repositories
  • Querying GitHub data with the API
carbon-language/carbon-lang33.9KUpdated Oct 26, 2026

See all skills by carbon-language

Report a problem with this skill