Claude Code Plugins

Community-maintained marketplace

Feedback

cpython-code-style

@gpshead/cpython-skills
3
0

Use this skill when writing or modifying CPython code to ensure it follows proper coding standards (PEP 7 for C, PEP 8 for Python), formatting rules, linting requirements, and pre-commit checks. It covers whitespace handling, type annotations policy, and documentation formatting.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name cpython-code-style
description Use this skill when writing or modifying CPython code to ensure it follows proper coding standards (PEP 7 for C, PEP 8 for Python), formatting rules, linting requirements, and pre-commit checks. It covers whitespace handling, type annotations policy, and documentation formatting.

CPython Coding Style and Standards

Style Guidelines

Python code (Lib/ etc): Follow PEP 8. Be consistent with nearby code.

C code (Modules/, Objects/, Python/, Include/): Follow PEP 7. Be consistent with nearby code.

Critical Rules

NEVER leave trailing whitespace on any line. Pre-commit hooks will catch this.

ALWAYS preserve the final newline at the end of files.

NEVER add type annotations to Lib/ tree. Stdlib doesn't use inline annotations (maintained in typeshed separately). Annotations may be OK in Tools/ or test code if requested.

No autoformatting by default. Only use Doc/venv/bin/ruff format if explicitly requested.

Pre-Commit Workflow

Before committing, run from repo root:

# 1. Pre-commit hooks (checks whitespace, file endings, syntax)
pre-commit run --all-files

# 2. Patchcheck (MUST PASS - validates C/Python style, docs, whitespace)
make -C $BUILD_DIR patchcheck

# 3. If you modified Doc/, verify reStructuredText
make -C Doc check

# 4. Run relevant tests
$BUILT_PY -m test test_yourmodule -j $(nproc)

Documentation

  • Python docstrings: Follow PEP 257, document params/returns/exceptions
  • C comments: Follow PEP 7, document complex algorithms
  • reStructuredText (Doc/): Follow Sphinx/reST conventions, verify with make -C Doc check