# Code style

> Code style is an Agent Skill for development published in the carbon-language/carbon-lang repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

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

- Skill name: `Code style`
- Category: [Development](https://www.openparable.com/skill/development/1)
- Source: https://github.com/carbon-language/carbon-lang/blob/HEAD/.agents/skills/code_style/SKILL.md
- Repository: carbon-language/carbon-lang (33,922 GitHub stars when collected)

## SKILL.md

# 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

-   **Licenses**: All Carbon files outside of `third_party/` should have a
    license following
    [CONTRIBUTING license instructions](/CONTRIBUTING.md#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.

## Style Guides

-   **C++ style**: Follow the
    [Carbon C++ Project Style Guide](/docs/project/cpp_style_guide.md).
-   **Markdown style**: Follow the
    [Google developer documentation style guide](https://developers.google.com/style).
-   **Python style**: Follow the [PEP 8](https://peps.python.org/pep-0008/)
    style guide.
    -   Wrap code and comments to 80 columns.
    -   Run `pre-commit run flake8 --files <file.py>` to check Python style.

---

Source: https://www.openparable.com/skill/development/code-style (OpenParable). Cite the canonical URL above.
