agentleFS
Gzyms69Gzyms69/agent-setup-bundle/skills/c-cpp-systems/SKILL.md

c-cpp-systems

Skill0 starsChanged 3 months agoMITView on GitHub

Writes, analyzes, optimizes, and debugs low-level C and C++ systems code, memory safety, pointers, manual RAII, struct alignment, bitwise arithmetic, and sanitizers (ASan/UBSan). Use when inspecting C/C++ source code, emulator cores, compiler flags, memory corruption, or native bindings.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every dynamically allocated pointer (malloc, calloc, new) must have an unambiguous single owner responsible for its deallocation (free, …

    line 20
  2. Very specific:

    Never dereference a pointer after freeing (use-after-free).

    line 21
  3. Distinctive:

    When compiling native cores or diagnostic builds:

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

C & C++ Systems Programming Skill

Specialist in high-performance C and C++ systems engineering, memory safety, zero-overhead abstractions, binary representation, and low-level debugging.


1. Memory Management & Pointer Arithmetic

  1. Manual RAII & Ownership Rules:
    • Every dynamically allocated pointer (malloc, calloc, new) must have an unambiguous single owner responsible for its deallocation (free, delete, unique_ptr).
    • Never dereference a pointer after freeing (use-after-free). Explicitly set freed pointers to NULL/nullptr in non-RAII code.
  2. Alignment & Padding:
    • Align data types according to machine natural boundary (4 bytes for 32-bit, 8 bytes for 64-bit).
    • For binary headers (ROMs, network packets), use explicit packing to prevent compiler padding:
      #pragma pack(push, 1)
      typedef struct {
          uint32_t magic;
          uint32_t clock_rate;
          uint32_t pc;
          uint32_t release;
          uint32_t crc1;
          uint32_t crc2;
      } RomHeader;
      #pragma pack(pop)

2. Bitwise Manipulation & Endianness Handling

  • Byte Extraction: uint8_t byte = (val >> (shift * 8)) & 0xFF;
  • Bitmask Assertion: if ((status_reg & STATUS_READY) != 0)
  • Big-Endian to Little-Endian (32-bit swap):
    static inline uint32_t swap32(uint32_t val) {
        return ((val & 0x000000FF) << 24) |
               ((val & 0x0000FF00) << 8)  |
               ((val & 0x00FF0000) >> 8)  |
               ((val & 0xFF000000) >> 24);
    }
  • Byte-Swapped (16-bit Middle-Endian swap for .v64):
    static inline uint16_t swap16(uint16_t val) {
        return (val << 8) | (val >> 8);
    }

3. Sanitizers & Diagnostic Verification

When compiling native cores or diagnostic builds:

  • AddressSanitizer (ASan): -fsanitize=address -fno-omit-frame-pointer — Catches out-of-bounds access, stack overflows, and use-after-free.
  • UndefinedBehaviorSanitizer (UBSan): -fsanitize=undefined — Catches integer overflows, invalid bit shifts, and misaligned pointer dereferences.
  • MemorySanitizer (MSan): -fsanitize=memory — Detects uninitialized memory reads.
  • Valgrind Memcheck: valgrind --leak-check=full --track-origins=yes ./binary

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.