c-coding-standards

Enforce ISO C, CERT C, and MISRA-style safety rules when writing or reviewing C code.

Updated May 28, 2026
One-click install
npx skills add https://github.com/changfengpro/agent-skills --skill c-coding-standards-changfengpro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: c-coding-standards
Source: https://github.com/changfengpro/agent-skills/tree/main/skills/c-coding-standards
Command: npx skills add https://github.com/changfengpro/agent-skills --skill c-coding-standards-changfengpro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? C code is prone to memory leaks, buffer overflows, undefined behavior, and portability bugs that are hard to catch in review. This Skill provides a complete, rule-based coding standard derived from ISO C (C11/C17/C23), CERT C, and MISRA-style defensive practices so every C change follows consistent, auditable safety conventions. ## Core Features & Use Cases - Rule-based guidance across 12 domains: interfaces, functions, types, pointers/arrays/strings, resource management, expressions, error handling, const-correctness, concurrency, standard library, preprocessor, and file organization. - Concrete DO/DON'T examples: each section includes compilable C snippets showing correct patterns (bounds-aware buffers, overflow-safe allocation, single cleanup paths) alongside anti-patterns to avoid. - Tooling baseline and checklist: recommended compiler warnings, sanitizers, static analyzers, and a pre-merge quick reference checklist. - Use Case: When reviewing a pull request that adds a new C module, apply the standards to verify ownership contracts, length-annotated buffers, checked return values, and self-contained headers before approving. ## Quick Start Use the c-coding-standards skill to review this C file for memory safety, undefined behavior, and portability issues.

Frequently Asked Questions about c-coding-standards

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review C code for memory safety and undefined behavior?

Apply the rule set covering pointers, arrays, resource management, and expressions: check that buffers carry explicit lengths, allocations use sizeof *ptr with overflow checks, every resource has one cleanup path, and no signed overflow or strict-aliasing violations exist. The included checklist walks through each verification step.

What C coding standard should I use for a new project?

This standard combines ISO C (C11/C17/C23) with CERT C security rules and MISRA-style defensive practices, making it suitable for libraries, services, CLI tools, and embedded code. Projects with a mandatory standard like MISRA C or AUTOSAR C should follow that stricter baseline instead.

Does this standard apply to C++ or MISRA C projects?

No. C++ projects should use the C++ Core Guidelines as their baseline, and projects with a mandatory standard such as MISRA C, AUTOSAR C, or a vendor or kernel style guide should follow those rules, which override this guidance.

Which unsafe C functions should be avoided?

Avoid gets, strcpy, strcat, sprintf, unbounded scanf, atoi, atol, and atof. Prefer snprintf with truncation detection, fgets, strtol and strtoul with full validation, and memcpy or memmove with checked sizes.

What compiler warnings and tools should I enable for C development?

Enable -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wstrict-prototypes and -Wmissing-prototypes. Add AddressSanitizer, UndefinedBehaviorSanitizer, LeakSanitizer, and ThreadSanitizer in test builds, plus static analysis with clang-tidy, cppcheck, or CodeQL.