c-conventions/SKILL.md
C coding conventions and best practices for C17 development. Use when writing, reviewing, or refactoring C code to ensure security, const-correctness, platform portability, and consistent parameter and naming conventions.
npx skillsauth add heikopanjas/agent-skills c-conventionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
const when not modifiedconst to pointer targets, not just pointers: const char* not char* constconst to document intent and prevent accidental modificationKString KStringCreate(const char* pStr, const size_t Size);int KStringCompare(const KString a, const KString b);KString KStringCreate(char* pStr, size_t Size);= is used instead of ==if (NULL == ptr), if (0 == value), if (true == condition)if (ptr == NULL), if (value == 0), if (condition == true)= is mistakenly used instead of ==Size: Count of bytes (for byte array parameters)cchSize: Count of characters (for character array parameters when distinct from bytes)p prefix (e.g., pStr, pData, pBuffer)Encoding, Length, Index)char* pointersstrlen() in library code)size_t for all size-related parameters and return valuesKString prefix)KStringCreate, KStringCompareKS_ValidatePointer, KS_ReleaseMyVariable, StringLength, BufferSize)InputString, MaxLength)p prefix (e.g., pData, pBuffer, pString)KString, KStringEncoding)KSTRING_ENCODING_UTF8)KSTRING_MAX_SHORT_LENGTH)KS_ for KString internals)typedef for struct types to avoid struct keyword in declarationstypedef enum to avoid enum keyword in declarationstypedef enum {
KSTRING_ENCODING_UTF8 = 0, // Default UTF-8 encoding
KSTRING_ENCODING_UTF16LE = 1, // UTF-16 Little Endian
KSTRING_ENCODING_UTF16BE = 2, // UTF-16 Big Endian
KSTRING_ENCODING_ANSI = 3 // ANSI/Windows-1252 (legacy)
} KStringEncoding;
calloc() for all dynamic allocations (zero-initialization)malloc() - always prefer calloc() for safetyconst pointers do not take ownershipKStringDestroy)UINT32_MAX for invalid size)#ifndef/#define/#endif#ifndef KSTRING_H
#define KSTRING_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
// Macros and constants
#define KSTRING_MAX_SHORT_LENGTH 12
// Type definitions
typedef struct KString KString;
typedef enum { /* ... */ } KStringEncoding;
// Public API declarations
KString KStringCreate(const char* pStr, const size_t Size);
void KStringDestroy(const KString kstr);
#endif // KSTRING_H
// for all comments (single-line and multi-line).clang-format configuration for automatic formattingstatic_assert to verify size assumptions at compile time<stdint.h>: uint32_t, uint64_t, size_t<stdbool.h> for bool type instead of custom definitions-Wall -Wextra -Wpedantic/W4static_assert to verify compile-time assumptions#include <assert.h>
// Verify structure size matches specification
static_assert(sizeof(KString) == 16, "KString must be exactly 16 bytes");
// Verify bit field sizes
static_assert(sizeof(uint32_t) * 8 >= 32, "uint32_t must be at least 32 bits");
static inline for small, performance-critical helpersconst to enable compiler optimizations_examples/ directorysize_t typecalloc(), checked for NULL.clang-format_examples/ subdirectory_build/ directory (gitignored)testing
Record recent changes and decisions in the AGENTS.md file. Use when making project decisions, choosing technologies, establishing conventions, or completing significant changes that should be tracked in the project history.
development
Swift coding conventions and best practices for modern Swift development. Use when writing, reviewing, or refactoring Swift code to ensure consistency with naming conventions, access control, async/await patterns, and SwiftUI/framework best practices.
development
Determine whether a version bump is required after code changes and apply semantic versioning (SemVer). Use when making code changes, fixing bugs, adding features, or introducing breaking changes to a project that uses SemVer.
development
Rust coding conventions and best practices for idiomatic Rust development. Use when writing, reviewing, or refactoring Rust code to ensure consistency with error handling, RAII principles, naming conventions, and Rust edition best practices.