{"id":"cad1d380-7c19-4bea-9c74-57aabe993e45","shortId":"Q3Mv2n","kind":"skill","title":"zephyr-foundations","tagline":"Foundational skills for Zephyr RTOS development. Covers essential Embedded C patterns (BIT, CONTAINER_OF), real-time concurrency primitives (mutexes, semaphores, spinlocks), hardware literacy (datasheet-to-DTS mapping), and defensive programming. Trigger when writing core applica","description":"# Zephyr Foundations\n\nMastering the bedrock of Zephyr is essential for writing efficient, robust, and idiomatic code.\n\n## Core Workflows\n\n### 1. Idiomatic C Patterns\nZephyr uses specific macros to manage memory and hardware-software mapping.\n- **Reference**: **[zephyr_macros.md](references/zephyr_macros.md)**\n- **Key Tools**: `CONTAINER_OF`, `BIT()`, `GENMASK()`, `ARRAY_SIZE`.\n\n### 2. Real-Time Concurrency\nSafe multi-threading and interrupt handling are critical for stability.\n- **Reference**: **[concurrency.md](references/concurrency.md)**\n- **Key Tools**: `k_mutex`, `k_sem`, `k_spinlock`, `atomic_t`, ISR safety rules.\n\n### 3. Hardware Literacy (Devicetree)\nUnderstanding how code interacts with the hardware description.\n- **Reference**: **[devicetree_basics.md](references/devicetree_basics.md)**\n- **Key Tools**: Nodes, properties, phandles, overlays, and advanced deletion.\n\n### 4. Robust Error Handling\nPreventing crashes through defensive programming.\n- **Reference**: **[error_handling.md](references/error_handling.md)**\n- **Key Tools**: `errno.h`, `BUILD_ASSERT`, validation patterns, return code checking.\n\n## Quick Start (Defensive Pattern)\n```c\nint sensor_read_checked(const struct device *dev)\n{\n  if (dev == NULL || !device_is_ready(dev)) {\n    return -ENODEV;\n  }\n\n  return 0;\n}\n```\n\n## Validation Checklist\n- [ ] Shared bit-field logic uses Zephyr macros (`BIT`, `GENMASK`) instead of raw literals.\n- [ ] Thread-shared state is protected with mutex/spinlock/atomic primitives.\n- [ ] Error paths return standard negative `errno` codes.\n- [ ] Defensive guards exist for null pointers, bounds, and device readiness checks.\n\n## Automation Tools\n- **[errno_return_check.py](scripts/errno_return_check.py)**: Detect likely non-negative `errno` return statements in C/C++ code.\n\n## Examples & Templates\n\n- **[template_driver.c](assets/foundation_examples/template_driver.c)**: A complete skeleton showing how to combine DT macros, mutexes, and config-data separation.\n\n## Resources\n\n- **[References](references/)**:\n  - `zephyr_macros.md`: Essential macros (BIT, CONTAINER_OF, etc.).\n  - `concurrency.md`: Mutexes, Semaphores, Spinlocks, and ISR safety.\n  - `devicetree_basics.md`: Devicetree syntax and overlay patterns.\n  - `error_handling.md`: Error codes and defensive programming.\n- **[Scripts](scripts/)**:\n  - `errno_return_check.py`: Return-code sign checker.\n- **[Assets](assets/)**:\n  - `foundation_examples/`: Working code templates for drivers and logic.","tags":["zephyr","foundations","agent","skills","beriberikix","agent-skills","agentic-coding","zephyr-rtos"],"capabilities":["skill","source-beriberikix","skill-zephyr-foundations","topic-agent-skills","topic-agentic-coding","topic-zephyr-rtos"],"categories":["zephyr-agent-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/beriberikix/zephyr-agent-skills/zephyr-foundations","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add beriberikix/zephyr-agent-skills","source_repo":"https://github.com/beriberikix/zephyr-agent-skills","install_from":"skills.sh"}},"qualityScore":"0.462","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 25 github stars · SKILL.md body (2,484 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T07:01:43.122Z","embedding":null,"createdAt":"2026-04-18T23:05:04.454Z","updatedAt":"2026-04-24T07:01:43.122Z","lastSeenAt":"2026-04-24T07:01:43.122Z","tsv":"'0':187 '1':59 '2':86 '3':118 '4':142 'advanc':140 'applica':40 'array':84 'assert':158 'asset':303,304 'assets/foundation_examples/template_driver.c':250 'atom':113 'autom':231 'bedrock':45 'bit':15,82,192,198,272 'bit-field':191 'bound':226 'build':157 'c':13,61,168 'c/c':244 'check':163,172,230 'checker':302 'checklist':189 'code':56,124,162,219,245,291,300,308 'combin':257 'complet':252 'concurr':21,90 'concurrency.md':103,276 'config':263 'config-data':262 'const':173 'contain':16,80,273 'core':39,57 'cover':10 'crash':147 'critic':99 'data':264 'datasheet':29 'datasheet-to-dt':28 'defens':34,149,166,220,293 'delet':141 'descript':129 'detect':235 'dev':176,178,183 'develop':9 'devic':175,180,228 'devicetre':121,284 'devicetree_basics.md':131,283 'driver':311 'driver.c':249 'dt':258 'dts':31 'effici':52 'embed':12 'enodev':185 'errno':218,240 'errno.h':156 'errno_return_check.py':233,297 'error':144,213,290 'error_handling.md':152,289 'essenti':11,49,270 'etc':275 'exampl':246,306 'exist':222 'field':193 'foundat':3,4,42,305 'genmask':83,199 'guard':221 'handl':97,145 'hardwar':26,72,119,128 'hardware-softwar':71 'idiomat':55,60 'instead':200 'int':169 'interact':125 'interrupt':96 'isr':115,281 'k':107,109,111 'key':78,105,133,154 'like':236 'liter':203 'literaci':27,120 'logic':194,313 'macro':66,197,259,271 'manag':68 'map':32,74 'master':43 'memori':69 'multi':93 'multi-thread':92 'mutex':23,108,260,277 'mutex/spinlock/atomic':211 'negat':217,239 'node':135 'non':238 'non-neg':237 'null':179,224 'overlay':138,287 'path':214 'pattern':14,62,160,167,288 'phandl':137 'pointer':225 'prevent':146 'primit':22,212 'program':35,150,294 'properti':136 'protect':209 'quick':164 'raw':202 'read':171 'readi':182,229 'real':19,88 'real-tim':18,87 'refer':75,102,130,151,267,268 'references/concurrency.md':104 'references/devicetree_basics.md':132 'references/error_handling.md':153 'references/zephyr_macros.md':77 'resourc':266 'return':161,184,186,215,241,299 'return-cod':298 'robust':53,143 'rtos':8 'rule':117 'safe':91 'safeti':116,282 'script':295,296 'scripts/errno_return_check.py':234 'sem':110 'semaphor':24,278 'sensor':170 'separ':265 'share':190,206 'show':254 'sign':301 'size':85 'skeleton':253 'skill':5 'skill-zephyr-foundations' 'softwar':73 'source-beriberikix' 'specif':65 'spinlock':25,112,279 'stabil':101 'standard':216 'start':165 'state':207 'statement':242 'struct':174 'syntax':285 'templat':247,248,309 'thread':94,205 'thread-shar':204 'time':20,89 'tool':79,106,134,155,232 'topic-agent-skills' 'topic-agentic-coding' 'topic-zephyr-rtos' 'trigger':36 'understand':122 'use':64,195 'valid':159,188 'work':307 'workflow':58 'write':38,51 'zephyr':2,7,41,47,63,196 'zephyr-found':1 'zephyr_macros.md':76,269","prices":[{"id":"13075e65-bc0b-439a-b2bb-e816b0b9b12c","listingId":"cad1d380-7c19-4bea-9c74-57aabe993e45","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"beriberikix","category":"zephyr-agent-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T23:05:04.454Z"}],"sources":[{"listingId":"cad1d380-7c19-4bea-9c74-57aabe993e45","source":"github","sourceId":"beriberikix/zephyr-agent-skills/zephyr-foundations","sourceUrl":"https://github.com/beriberikix/zephyr-agent-skills/tree/main/skills/zephyr-foundations","isPrimary":false,"firstSeenAt":"2026-04-18T23:05:04.454Z","lastSeenAt":"2026-04-24T07:01:43.122Z"}],"details":{"listingId":"cad1d380-7c19-4bea-9c74-57aabe993e45","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"beriberikix","slug":"zephyr-foundations","github":{"repo":"beriberikix/zephyr-agent-skills","stars":25,"topics":["agent-skills","agentic-coding","zephyr-rtos"],"license":"apache-2.0","html_url":"https://github.com/beriberikix/zephyr-agent-skills","pushed_at":"2026-04-20T21:40:18Z","description":"A complete catalog of Agent Skills (agentskills.io) for Zephyr RTOS development.","skill_md_sha":"fb3d1c0ed603e052471c548c62d64a4fc7fe3324","skill_md_path":"skills/zephyr-foundations/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/beriberikix/zephyr-agent-skills/tree/main/skills/zephyr-foundations"},"layout":"multi","source":"github","category":"zephyr-agent-skills","frontmatter":{"name":"zephyr-foundations","description":"Foundational skills for Zephyr RTOS development. Covers essential Embedded C patterns (BIT, CONTAINER_OF), real-time concurrency primitives (mutexes, semaphores, spinlocks), hardware literacy (datasheet-to-DTS mapping), and defensive programming. Trigger when writing core application logic, drivers, or troubleshooting foundational behavior."},"skills_sh_url":"https://skills.sh/beriberikix/zephyr-agent-skills/zephyr-foundations"},"updatedAt":"2026-04-24T07:01:43.122Z"}}