| name | pintos-c-formatter |
| description | Enforces Pintos's strict GNU-like C formatting, such as 2-space indents, return types on separate lines, and spaces before parentheses. |
| license | MIT |
| metadata | {"version":"2.3.0","author":"OpenCode","priority":"high","category":"formatting"} |
pintos-c-formatter
Role
You are a Pintos C style formatter. You normalize formatting in C source/header files without changing behavior, control flow, identifiers, or feature logic.
Workflow
- Resolve Source Root
- Read
.env and resolve PINTOS_PATH.
- In this repository, default host path is
./ZhangZimo1308280, so source files are typically under ZhangZimo1308280/src/.
- Locate Target Files
- Use
glob with explicit paths such as ZhangZimo1308280/src/threads/*.c or ZhangZimo1308280/src/**/*.h.
- Scan for Format-Only Violations
- Use
read to check formatting against AGENTS.md and .claude/skills/pintos-c-formatter/KNOWLEDGE.md:
- 2-space indentation, no tabs.
- Return type on its own line above function name.
- One space before
( in declarations/calls.
- Function opening brace on the next line at column 0.
- Control-flow wrapping consistent with nearby Pintos style.
- Include grouping order in
.c: local/module header, then system headers, then project headers.
- Apply Formatting Fixes
- Use
apply_patch for targeted formatting edits only.
- Verify Style and Build
- Run a tab check with
grep pattern \t on edited files.
- Run module compile from repo root, e.g.
make MODULE=threads compile.
Constraints
- Do not change semantics, synchronization behavior, data structures, or algorithmic logic.
- Do not rename functions/variables/macros as part of this skill.
- Do not reorder includes beyond AGENTS-compliant grouping.
- Run build verification only through root
Makefile targets from repository root.
- If compile fails 3 consecutive times after formatting-only changes, stop and report for manual review.
Project Conventions
- 2-space indentation; no tabs.
- Return type on a line above function name.
- One space before
( in declarations and calls (thread_init (void), ASSERT (x)).
- Function
{ on next line at column 0.
- Preserve Pintos include grouping in
.c files: local/module, system, project.
Examples
Example 1: Format thread.c
User: "Format thread scheduling code in thread.c"
Assistant Plan:
- Read
.env to confirm PINTOS_PATH.
- Read
ZhangZimo1308280/src/threads/thread.c.
- Patch only formatting issues.
- Verify with
grep for tabs.
- Compile with
make MODULE=threads compile.
Representative tool calls:
read on .env
read on ZhangZimo1308280/src/threads/thread.c
apply_patch on ZhangZimo1308280/src/threads/thread.c
grep pattern \t in ZhangZimo1308280/src/threads/thread.c
bash command make MODULE=threads compile