[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EKMP408JG0E21KDB96BC7W":3,"skill-same:01M7EKMP408JG0E21KDB96BC7W":74},{"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":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":27,"ownerDescription":28,"updatedAt":29,"install":30,"resources":43},"01M7EKMP408JG0E21KDB96BC7W","lang-c",null,"raillen\u002Fdaisy-code-editor","raillen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F50306048?v=4","01M7EKBDVVBSPF21PBPVJYMNYR","Raillen Santos","01M7EKBDWD12A1K9N9Y638FGX9",0,"MIT","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\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","2e465213b972294984c8c9515a47f811e4b358da",".ai\u002Fskills\u002Flang-c","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor","https:\u002F\u002Fgithub.com\u002Fraillen","https:\u002F\u002Fraillen.com","\u003C\u003CMarketing & IT>>\r\n\r\n@poppy-team\r\n@wasd-lat ","2026-10-16 09:17:52",{"source":7,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add raillen\u002Fdaisy-code-editor --skill lang-c",{"tool":36,"command":37},"bunx","bunx skills add raillen\u002Fdaisy-code-editor --skill lang-c",{"tool":39,"command":40},"pnpm","pnpm dlx skills add raillen\u002Fdaisy-code-editor --skill lang-c","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002FSKILL.md",true,[44,50,56,60,64,70],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"checks\u002Fbounded-apis.md","REFERENCE","参考文档",518,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fchecks\u002Fbounded-apis.md",{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fsafe-buffer.c","OTHER","其他",3275,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fexamples\u002Fsafe-buffer.c",{"path":57,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":58,"sourceHtmlUrl":59},"manifest.json",1806,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fmanifest.json",{"path":61,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Fc-memory-safety.md",3167,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Freferences\u002Fc-memory-safety.md",{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"scripts\u002Fverify.sh","SCRIPT","脚本",2879,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Fscripts\u002Fverify.sh",{"path":71,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":72,"sourceHtmlUrl":73},"templates\u002Fc-verification-report.md",345,"https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Flang-c\u002Ftemplates\u002Fc-verification-report.md",[75,81,87,94,101,108],{"skillNo":76,"name":77,"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":78,"categories":79,"keywords":80,"publishedAt":18},"01M7EKQYSDAX3SGSCRF873Z8E2","zoom-reflow","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fzoom-reflow\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"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":84,"categories":85,"keywords":86,"publishedAt":18},"01M7EKQX0MWJNQD482GGZPGES4","wireframe-styleguide","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fwireframe-styleguide\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M7EKQS57FS6JYE6KWW6X5ADJ","visual-regression","Pixel-by-pixel snapshot testing, Playwright integration, dynamic content masking, deterministic font rendering, and cross-browser CI gates","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fvisual-regression\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M7EKQMFR7651NVH100P5781Z","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\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Fui-implementation\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":18},"01M7EKQG3NVX6DPCYS6Q4PA71V","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\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Ftui-editor-engine\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"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":111,"categories":112,"keywords":113,"publishedAt":18},"01M7EKQEJ993JGC72FE2KFY3ZZ","tree-sitter-context-indexing","https:\u002F\u002Fgithub.com\u002Fraillen\u002Fdaisy-code-editor\u002Fblob\u002Fmain\u002F.ai\u002Fskills\u002Ftree-sitter-context-indexing\u002FSKILL.md",[],[]]