{"id":"23470442-62c9-4bad-bc71-6bd6d99362f7","slug":"embedded-code-logic","kind":"skill","name":"embedded-code-logic","summary":"Claude Code skill for designing/reviewing embedded firmware control flow & concurrency (MCU bare-metal + FreeRTOS): state machines, ISR↔task cooperation, driver logic, race/deadlock/priority-inversion","owner":"ykz0716","repoUrl":"https://github.com/ykz0716/embedded-code-logic","license":"MIT","licenseTier":"permissive","trust":"community","stars":0,"match":null,"fewStars":true,"format":"skill","createdAt":"2026-06-23T11:29:24.000Z","addedAt":"2026-10-21T13:20:59.096Z","logoUrl":"https://avatars.githubusercontent.com/u/276585314?v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["developer-tools","productivity"],"tags":["claude-code","concurrency","embedded","firmware","freertos","stm32"],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-23T20:00:15.651Z","sample":false,"url":"https://conduits.dev/tools/embedded-code-logic","language":"","transports":["stdio"],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# embedded-code-logic\n\nA [Claude Code](https://docs.anthropic.com/en/docs/claude-code/skills) skill that helps\n**design and review the control flow and concurrency of embedded firmware** — state\nmachines, ISR↔task cooperation, driver logic, and the classic concurrency hazards (race\nconditions, deadlock, priority inversion, shared-resource protection, timeouts, watchdog\nintegration).\n\nIt targets **MCU bare-metal / register-level** code and **FreeRTOS**, and it is\ndeliberately about *logic* — not register config or datasheet lookups. When the question\nis \"which bit in `USART1->CR1`,\" that belongs to the chip's Reference Manual; when the\nquestion is \"this driver deadlocks sometimes\" or \"how should I structure this state\nmachine,\" that is this skill's territory.\n\n## Install\n\nCopy (or symlink) the folder into your Claude Code skills directory:\n\n```bash\n# macOS / Linux\ncp -r embedded-code-logic ~/.claude/skills/\n\n# Windows (Git Bash)\ncp -r embedded-code-logic ~/.claude/skills/\n```\n\nThe skill auto-triggers on natural language. Try:\n\n- \"帮我看看这段 ISR 写得对不对\" (+ paste interrupt code)\n- \"设计一个带重试和故障态的传感器状态机\"\n- \"TaskH 偶尔卡死几百毫秒，帮我诊断\"\n- \"review this FreeRTOS driver for race conditions\"\n\n## What it covers\n\nSix principles, each tied to the concrete failure mode it prevents rather than a list of\nMUSTs:\n\n1. **ISRs signal, they do not compute** — keep the handler tiny, defer to a task.\n2. **Shared data crossing the ISR↔task boundary must be protected** — `volatile` is not\n   atomic and not a memory barrier; pick ring buffer / queue / critical section.\n3. **Never block without a timeout** — every wait is finite and has a handler.\n4. **Prefer non-blocking state machines over delays** — poll-with-deadline, not `vTaskDelay`.\n5. **Concurrency hazards and the right fix for each** — race (mutual exclusion), deadlock\n   (lock ordering), priority inversion (mutex with inheritance, *not* a binary semaphore).\n6. **Driver control flow & single ownership** — one owning task per peripheral, checked\n   init sequence, errors propagated not swallowed.\n\nPlus a reviewer checklist that turns the principles into yes/no questions.\n\n## Structure\n\n```\nembedded-code-logic/\n├── SKILL.md                       # principles + reviewer checklist (main entry)\n└── references/                    # load-on-demand, with C examples\n    ├── isr-task-cooperation.md    # deferred-ISR pattern, FromISR APIs, SPSC ring buffer\n    ├── concurrency-protection.md  # race fixes, deadlock matrix, priority-inversion example\n    ├── state-machines.md          # enum+switch, transition table, hidden state, worked driver\n    └── timing-timeouts.md         # non-blocking delay, timeouts, watchdog, deadline scheduling\n```\n\n`SKILL.md` stays lean; the references are read only when a principle needs concrete code\n(progressive disclosure).\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n"}