Agent skill
C
Write safe C avoiding memory corruption, buffer overflows, and undefined behavior traps.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/c-ljt-520-openclaw-backup
Metadata
Additional technical details for this skill
- clawdbot
-
{ "os": [ "linux", "darwin", "win32" ], "emoji": "\u2699\ufe0f", "requires": { "bins": [ "gcc", "clang" ] } }
SKILL.md
Quick Reference
| Topic | File |
|---|---|
| malloc/free, leaks, double free | memory.md |
| Null, dangling, pointer arithmetic | pointers.md |
| Null terminator, buffer overflow | strings.md |
| Integer overflow, signed/unsigned | types.md |
| Macro traps, include guards | preprocessor.md |
| Common undefined behavior | undefined.md |
Critical Rules
mallocreturnsvoid*— cast required in C++, optional in C but check for NULLfree(ptr); ptr = NULL;— always null after free to prevent double-freesizeof(array)in function gives pointer size, not array size — pass length separatelychar str[5] = "hello";— no room for null terminator, UB when used as stringstrcpydoesn't check bounds — usestrncpyand manually null-terminate- Signed overflow is UB — compiler can optimize assuming it never happens
i++ + i++is UB — no sequence point between modifications- Returning pointer to local variable — dangling pointer, UB on use
#define SQUARE(x) x*x—SQUARE(1+2)=1+2*1+2= 5, not 9memcpywith overlapping regions — usememmoveinstead- Uninitialized variables — contain garbage, UB if used
- Array out of bounds — no runtime check, silent corruption or crash
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?