[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78FF0R2R7P1W6MVD63AF196":3,"skill-same:01M78FF0R2R7P1W6MVD63AF196":75},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":28,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M78FF0R2R7P1W6MVD63AF196","lang-c",null,"poppyTM\u002Foride","poppyTM","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F339400917?v=4","01M78F6YNKFR5S5JQR27X9F09Z","Poppy Team","01M78F6YP8ZZTRES9X8Q2ZAD21",1,"MIT","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# ISO C Systems Programming & Memory Safety Contract\n\n## 1. Purpose\nAuthor, refactor, and audit systems software written in modern **ISO C** (C11, C17, or C23). This skill mandates strict bounded buffer operations, elimination of banned and dangerous standard library functions, pointer provenance discipline, zero unchecked allocations, automatic scope cleanup via `__attribute__((cleanup))` where supported, zero-warning compilation with `-Werror`, and runtime verification with AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan).\n\n---\n\n## 2. Use When\n- Developing low-level systems libraries, operating system interfaces, embedded modules, or runtime runloops in C.\n- Authoring C-ABI foreign function interface (FFI) bindings for Go, Rust, Python, or WebAssembly.\n- Writing high-throughput data processing algorithms requiring raw memory access with zero compiler-induced overhead.\n- Auditing legacy C codebases for memory corruption vulnerabilities, buffer overflows, or integer wrap-around defects.\n- Operating in mode(s): `implementation`, `review`, `testing`, `audit`.\n\n---\n\n## 3. Do Not Use When\n- Developing in C++ with RAII, templates, and classes (use `lang-cpp`).\n- Writing memory-safe systems code where Rust's compiler borrow checker is available and mandated (use `lang-rust`).\n- Working purely on web frontend UI or scripting environments.\n\n---\n\n## 4. Required Context\nBefore implementing or modifying C code, determine:\n- **Standard Dialect**: ISO C11 (`-std=c11`), C17 (`-std=c17`), or C23 (`-std=c2x` \u002F `-std=c23`).\n- **Platform ABI & Alignment Constraints**: Data model (LP64 on 64-bit Linux\u002FmacOS vs LLP64 on Windows), pointer size, and structure alignment requirements.\n- **Buffer Safety Protocol**: Use of explicit `(void *buf, size_t cap, size_t *out_len)` parameter tuples or structured slice types (`struct BufferSlice { uint8_t *data; size_t len; size_t cap; }`).\n- **Fortification & Compiler Hardening**: Presence of `_FORTIFY_SOURCE=2` or `_FORTIFY_SOURCE=3`, stack canaries (`-fstack-protector-strong`).\n\n---\n\n## 5. Procedure\n\n```\n[API Design & Type Definition]\n         |\n         v\n[1. Buffer Tuple Specification] ----> (ptr, cap, out_len) mandatory on all writes\n         |\n         v\n[2. Dangerous API Ban & Scan] -------> Eradicate gets, strcpy, strcat, sprintf\n         |\n         v\n[3. Allocation & Pointer Discipline]-> Immediate NULL checks, zero after free\n         |\n         v\n[4. Static Analysis & Fortify] ------> -Wall -Wextra -Wpedantic -Werror -D_FORTIFY_SOURCE=3\n         |\n         v\n[5. Dynamic ASan\u002FUBSan Gauntlet] ----> Zero leaks, zero out-of-bounds, zero UB\n```\n\n### Step 1: Bounded Buffer Operations\n- Every function accepting or populating a buffer must accept explicit capacity constraints:\n  ```c\n  int safe_copy_string(char *dest, size_t dest_cap, const char *src);\n  ```\n- Use structured buffer descriptors for binary I\u002FO:\n  ```c\n  typedef struct {\n      uint8_t *data;\n      size_t len;\n      size_t cap;\n  } ByteBuffer;\n  ```\n- Variable Length Arrays (VLAs, e.g. `char buf[n]`) are **strictly prohibited**. Use fixed-size stack buffers with overflow checks, or heap\u002Farena allocation.\n\n### Step 2: Elimination of Banned APIs\nThe following legacy C standard library functions are strictly forbidden:\n- `gets()` $\\rightarrow$ use `fgets()` with bounded length.\n- `strcpy()`, `strcat()` $\\rightarrow$ use `snprintf()` or explicit bounded loops with null termination.\n- `sprintf()`, `vsprintf()` $\\rightarrow$ use `snprintf()`, `vsnprintf()`.\n- `atoi()`, `atol()` $\\rightarrow$ use `strtol()`, `strtoll()` with `endptr` and `errno` validation.\n\n### Step 3: Allocation Safety & Lifecycle Hygiene\n1. Check every allocation immediately:\n   ```c\n   void *ptr = malloc(size);\n   if (ptr == NULL) {\n       return ERR_OUT_OF_MEMORY;\n   }\n   ```\n2. Free and nullify:\n   ```c\n   free(ptr);\n   ptr = NULL; \u002F\u002F Prevent Use-After-Free\n   ```\n3. When targeting GCC or Clang on Linux\u002FPOSIX, utilize `__attribute__((cleanup))` to implement deterministic RAII-like scope cleanups for dynamic resources.\n\n### Step 4: Strict Aliasing & Provenance Invariants\n- Never cast between incompatible pointer types (e.g., `float *` to `int *`).\n- To inspect or reinterpret binary representation, use `memcpy()` or copy into `unsigned char *`:\n  ```c\n  uint32_t raw_bits;\n  memcpy(&raw_bits, &float_val, sizeof(raw_bits));\n  ```\n- Obey pointer provenance: arithmetic on a pointer must remain within the bounds of the original allocated object.\n\n### Step 5: Static Hardening & Dynamic Sanitizers\n1. Compile with strict flags:\n   `-std=c17 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Werror -D_FORTIFY_SOURCE=3 -fstack-protector-strong`.\n2. Compile and run the test suite under AddressSanitizer and UndefinedBehaviorSanitizer:\n   `-fsanitize=address,undefined -fno-omit-frame-pointer`.\n\n---\n\n## 6. Decision Rules & Invariants\n- **RULE 1 (Explicit Buffer Bounds)**: Any function writing to a pointer without receiving an explicit capacity parameter is rejected immediately.\n- **RULE 2 (No Unchecked Heap Operations)**: Any dereference of a pointer returned by `malloc`, `calloc`, or `realloc` without an antecedent `NULL` check is a fatal quality defect.\n- **RULE 3 (No VLAs on Stack)**: Variable-length arrays (`type arr[n]`) are forbidden; they risk unbounded stack growth and remote code execution vulnerabilities.\n- **RULE 4 (Explicit Return Codes)**: Every fallible function must return an explicit status code (enum or negative error integer) or error struct. Functions must never rely on side effects to communicate failure.\n\n---\n\n## 7. Evidence Required\n- **Compiler Evidence**: Clean compilation under `-std=c17` or `-std=c2x` with `-Werror` and `-D_FORTIFY_SOURCE=3`.\n- **Sanitizer Evidence**: Zero memory leaks, zero buffer overflows, and zero undefined behavior warnings under ASan\u002FUBSan execution.\n- **Boundary Verification**: Unit test evidence verifying that buffer truncated conditions return expected error codes without heap or stack corruption.\n\n---\n\n## 8. Output Contract\n- Hardened C source (`.c`) and header (`.h`) files with full prototype signatures and header guards.\n- Makefile or CMake configuration specifying strict flags and sanitizer profiles.\n- C Verification Report (`templates\u002Fc-verification-report.md`).\n\n---\n\n## 9. Stop Conditions\n- All tests pass with zero findings under ASan and UBSan.\n- Static analysis and compiler run with `-Werror` and report zero diagnostics.\n- Token budget exhausted.\n- Blocked on external dependency.\n\n---\n\n## 10. Escalation Rules\n- Escalate immediately if an external legacy C library with known buffer overflow risks must be linked without a memory-safe wrapper boundary.\n- Escalate if hardware-specific memory-mapped I\u002FO requires disabling strict aliasing flags (`-fno-strict-aliasing`).\n",{},"main","1cd515630b8ceb57777d466bee4970fe7c2e30e0",".ai\u002Fskills\u002Flang-c",0,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride","https:\u002F\u002Fgithub.com\u002FpoppyTM","https:\u002F\u002Fpoppy.lat","Construímos linguagens de programação e ferramentas para quem lê código com o mesmo cuidado com que escreve.","2026-09-30 10:15:52",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add poppyTM\u002Foride --skill lang-c",{"tool":37,"command":38},"bunx","bunx skills add poppyTM\u002Foride --skill lang-c",{"tool":40,"command":41},"pnpm","pnpm dlx skills add poppyTM\u002Foride --skill lang-c","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002FSKILL.md",true,[45,51,57,61,65,71],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"checks\u002Fbounded-apis.md","REFERENCE","参考文档",518,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fchecks\u002Fbounded-apis.md",{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"examples\u002Fsafe-buffer.c","OTHER","其他",3275,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fexamples\u002Fsafe-buffer.c",{"path":58,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":59,"sourceHtmlUrl":60},"manifest.json",1806,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fmanifest.json",{"path":62,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fc-memory-safety.md",3167,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Freferences\u002Fc-memory-safety.md",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Fverify.sh","SCRIPT","脚本",2879,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fscripts\u002Fverify.sh",{"path":72,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":73,"sourceHtmlUrl":74},"templates\u002Fc-verification-report.md",345,"https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Ftemplates\u002Fc-verification-report.md",[76,82,88,95,102,109],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M78FHQN254KEH0DETXT5JM29","zoom-reflow","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fzoom-reflow\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M78FHP1880S695V8GQEE0RXK","wireframe-styleguide","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fwireframe-styleguide\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":18},"01M78FHHYM6AN2H819FABW01DZ","visual-regression","Pixel-by-pixel snapshot testing, Playwright integration, dynamic content masking, deterministic font rendering, and cross-browser CI gates","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fvisual-regression\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":18},"01M78FHE53D8DD0QVRY5C37DA4","ui-implementation","Component-driven UI implementation, multi-state matrix (default, hover, focus-visible, active, disabled, loading, empty, error), DTCG design tokens, responsive layout contracts, and accessibility tree mapping.","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fui-implementation\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":18},"01M78FHBJ1KXFF734GFE509TBJ","tui-editor-engine","Text buffer and editing semantics for a terminal code editor — index conversion, transaction-first editing, multi-cursor invariants, undo grouping, and large-file behaviour.","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Ftui-editor-engine\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":18},"01M78FH9X6CPJX1H61ZDWTTVW8","tree-sitter-context-indexing","https:\u002F\u002Fgithub.com\u002FpoppyTM\u002Foride\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Ftree-sitter-context-indexing\u002FSKILL.md",[],[]]