pi-c-review
C code review and auto-correction extension for pi.dev
Package details
Install pi-c-review from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-c-review- Package
pi-c-review- Version
1.0.2- Published
- Nov 2, 2026
- Downloads
- 713/mo · 713/wk
- Author
- bravetux.com
- License
- MIT
- Types
- extension
- Size
- 266.7 KB
- Dependencies
- 1 dependency · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-c-review
C Code Review & Auto-Correction Extension for pi.dev
pi-c-review is a specialized extension for Pi Coding Agent (@earendil-works/pi-coding-agent). It enables developers to audit C source files against strict custom requirements, safety profiles (memory safety, buffer security, MISRA-C guidelines), and immediately obtain dual human/machine reports, targeted section reviews, and selective compilation-ready fixes with alternate file outputs.
Features
- Custom User Requirements: Enforce project-wide guidelines via
.creviewrc.jsonor pass ad-hoc rules directly in slash commands (e.g.,"/c-review main.c 'Ensure all mallocs have NULL checks and proper cleanup'"). - Built-in Safety Presets:
memory-safety: Dynamic allocation hygiene, NULL pointer checks, double-free and use-after-free prevention.buffer-security: Banned functions (gets,strcpy,strcat,sprintf), buffer overrun prevention, explicit null termination.embedded-misra: Core MISRA-C principles, fixed-width types (<stdint.h>), explicit variable initialization, switchdefault:clauses, and resource status validation.
- Slash Commands:
/c-review <filepath> [--func <name>] [--lines <start>-<end>] [custom requirement]: Instant local static scan + deep LLM audit with compliance score, targeted section slicing, and automated dual report generation (.mdand.json) in the workspace root./c-fix <filepath> [1,3 | --issues 1,2 | --rules RULE-ID] [--out <alt_file>]: Selectively or comprehensively fixes diagnosed violations in-place (with.bakbackup) or outputs to an alternate target file./c-review-all [directory] [--report <dir>]: Recursively scans all.cand.hfiles, generating per-file dual reports and a final rollup summary (c-review-summary.mdand.json) in the workspace root./c-rules [list | init | presets]: Manages project rule configurations and preset definitions.
- Dual Human & Machine Reports:
- Markdown report (
<file>.review.md&c-review-summary.md): Clean GitHub Flavored Markdown with compliance scorecards, visual progress bars, issue snippets, and quick-fix commands. - JSON report (
<file>.review.json&c-review-summary.json): Structured machine-readable schema for CI/CD gates, automation, and tooling.
- Markdown report (
- Targeted Section & Function Reviews: Restrict audits to specific functions (
--func <name>) or line numbers (--lines <start>-<end>or<file>:<start>-<end>). - Selective Auto-Fixes: Fix only specific chosen violations (by index numbers like
1,3or rule IDs likeMEM-01) without modifying or reformatting other parts of the file. - Alternate Output Destination: Write corrected code to a new file with
--out <path>/-o <path>, leaving the original source file completely untouched. - Local Static Pre-Scanner: Sub-10ms pattern analyzer detecting banned functions (
gets,strcpy,strcat,sprintf,atoi), contextual NULL allocation checks, dangling pointers afterfree(), unbraced control flow, and non-fixed-width types. - Inline Suppression: Fully supports
// NOLINTand// NOLINT(RULE-ID)comments to selectively bypass specific rules. - Compliance Scoring & Dashboard: Quantitative 0-100 scoring with letter grades (
AthroughF) and visual terminal progress bars. - Agent Tool (
c_review_and_fix): LLM-callable tool enabling Pi to autonomously audit and fix C snippets or files during multi-turn agent sessions. - Auto-Detection Hook: Automatically listens for edits on
.cand.hfiles and alerts the developer when compliance verification is recommended.
Installation
Option 1: Local Development / Project-Local
Place or link this extension in your project's .pi/extensions/ or run:
pi install /path/to/pidev
Option 2: Global Pi Extension Directory
Copy the compiled extension into your global Pi extension folder:
cp -r /path/to/pidev ~/.pi/agent/extensions/pi-c-review
Inside Pi, execute /reload to load the extension.
Option 3: Via npm (when published)
pi install npm:pi-c-review
Usage
1. Review C Code (Full File, Function, or Line Range)
Run /c-review with a file path:
# Full file audit (generates server.c.review.md and server.c.review.json in workspace root)
/c-review src/server.c
# Review only a specific function
/c-review src/server.c --func handle_packet
# Review only a specific line range
/c-review src/server.c --lines 50-120
# Shorthand line range syntax
/c-review src/server.c:50-120 "Ensure socket timeouts"
The extension audits the targeted section, lists categorized violations with indexed numbers ([1], [2], ...), outputs the dual reports, and sends the scoped review to the agent.
2. Selective Auto-Fixes & Alternate File Output
Run /c-fix to apply fixes:
# Fix all violations in-place (creates src/buffer.c.bak)
/c-fix src/buffer.c
# Fix ONLY issues #1 and #3 from the review report
/c-fix src/buffer.c 1,3
# Fix ONLY memory allocation issues by rule ID
/c-fix src/buffer.c --rules MEM-01
# Apply fixes to a NEW file, keeping original buffer.c untouched
/c-fix src/buffer.c 1,2 --out src/buffer_fixed.c
3. Project-Wide Audit & Rollup Reports
Scan an entire project or directory:
/c-review-all src/
Generates:
- Individual reports for every
.c/.hfile:<basename>.review.mdand<basename>.review.json - Final project rollup summary:
c-review-summary.mdandc-review-summary.json
4. Initialize Project Rules
Create a project-specific .creviewrc.json file in your workspace root:
/c-rules init
Example .creviewrc.json:
{
"presets": ["memory-safety", "buffer-security", "embedded-misra"],
"customRules": [
"Every pointer returned from malloc/calloc must be checked against NULL immediately",
"All file handles opened with fopen must be closed before returning on all error paths",
"Do not use magic numbers; use uppercase enum or #define constants"
],
"createBackup": true,
"strictMode": false
}
Check active rules anytime with:
/c-rules list
Documentation
For comprehensive technical specifications, consult the project documentation:
- 🏛️ Architecture Documentation: System topology, subsystems, sequence diagrams, and Pi integration hooks.
- 📐 Design Documentation: Internal data contracts, LCS diff algorithm, prompt engineering, and command specs.
- 🧪 Test Plan & Matrix: Verification strategy, test matrix, fixtures, and acceptance criteria.
- 📜 Sample MISRA-C & Linux Kernel Standards: Industry-grade requirement specification combining MISRA C:2012/2023 with Linux Kernel conventions.
Development & Testing
# Install dependencies
npm install
# Run unit tests (82 tests across 11 test suites)
npm test
# Build TypeScript
npm run build
Author
Vignesh Kumar B (aka Bravetux) (ic19939@gmail.com)
License
MIT © 2026 Vignesh Kumar B (aka Bravetux)