This is a CMake-based ARM embedded toolchain wrapper that scans your workspace for projects, lists CMake presets, and runs configure/build/rebuild/clean operations with arm-none-eabi-gcc. It automatically parses build logs for errors and warnings, runs size analysis on your ELF files to show flash and RAM usage, and can compare builds. The skill maintains state in .embeddedskills/config.json so it remembers your last project and preset, but it won't guess when there's ambiguity. It only works with CMake projects, not raw Makefiles. Useful if you're jumping between embedded projects and want Claude to handle the build plumbing without you typing out cmake commands with the right presets and paths every time.
npx -y skills add zhinkgit/embeddedskills --skill gcc --agent claude-codeInstalls into .claude/skills of the current project.
本 skill 提供基于 CMake + arm-none-eabi-gcc 的嵌入式工程发现、preset 枚举、配置生成、增量编译、全量重建、清理和 ELF 大小分析能力。
范围说明:当前仅支持 CMake 型 GCC 嵌入式工程,不覆盖纯 Makefile 工程。
skill 目录下的 config.json 包含环境级配置,首次使用前确认 cmake_exe 路径正确:
{
"cmake_exe": "cmake",
"toolchain_prefix": "arm-none-eabi-",
"toolchain_path": "",
"operation_mode": 1
}
cmake_exe:cmake 可执行文件路径,默认从 PATH 查找toolchain_prefix:工具链前缀,默认 arm-none-eabi-,用于定位 size 等工具toolchain_path:工具链 bin 目录,为空时从 PATH 查找operation_mode:1 直接执行 / 2 输出风险摘要但不阻塞 / 3 执行前确认工程级共享配置统一保存在工作区的 .embeddedskills/config.json 中:
{
"gcc": {
"project": "",
"preset": "",
"log_dir": ".embeddedskills/build"
}
}
project:默认工程路径(相对 workspace),构建成功后会自动更新preset:默认 CMake preset 名称,构建成功后会自动更新log_dir:构建日志输出目录,默认 .embeddedskills/build参数解析顺序(从高到低):
冲突解决规则:同一参数存在多个来源时,以序号最小的来源为准;高序号来源仅在低序号来源未提供该参数时生效。例如:CLI 已指定 --preset Debug,则忽略 state.json 中记录的上次 preset。
| 子命令 | 用途 | 风险 |
|---|---|---|
scan | 搜索当前目录下的 CMake 嵌入式工程 | 低 |
presets | 列出 CMakePresets.json 中的 configure/build preset | 低 |
configure | 执行 cmake --preset 生成构建系统 | 中 |
build | 增量编译 cmake --build | 中 |
rebuild | 清理后全量重建 | 中 |
clean | 清理构建目录 | 高 |
size | 分析 ELF 文件大小(text/data/bss 和内存使用) | 低 |
config.json,确认 cmake_exe 路径有效scanscan 搜索工程configure/build/rebuild/clean 按 operation_mode 决定是否需要确认build 前自动检测是否已 configure,未配置时提示先执行 configurebuild/rebuild 成功后返回 elf_file,供 jlink/openocd 继续使用size 默认分析最近一次构建产物的 .elf 文件skill 目录下有三个 Python 脚本,使用标准库实现,无额外依赖。
# 扫描工程
python <skill-dir>/scripts/gcc_project.py scan --root <搜索目录> --json
# 列出 preset
python <skill-dir>/scripts/gcc_project.py presets --project <工程目录> --json
python <skill-dir>/scripts/gcc_build.py <configure|build|rebuild|clean> \
--cmake <cmake路径> \
--project <工程根目录> \
--preset <preset名称> \
--log-dir <日志目录> \
--json
# 基本分析
python <skill-dir>/scripts/gcc_size.py analyze \
--elf <elf文件路径> \
--toolchain-prefix arm-none-eabi- \
--linker-script <链接脚本路径> \
--json
# 对比分析
python <skill-dir>/scripts/gcc_size.py compare \
--elf <elf文件1> \
--compare <elf文件2> \
--toolchain-prefix arm-none-eabi- \
--json
所有脚本以 JSON 格式返回,基础字段为 status(ok/error)、action、summary、details,并可能附带 context、artifacts、metrics、state、next_actions、timing。
成功示例:
{
"status": "ok",
"action": "build",
"summary": "build 成功,errors=0 warnings=2",
"details": { "project": "...", "preset": "Debug", "build_dir": "...", "elf_file": "...", "log_file": "..." },
"metrics": { "errors": 0, "warnings": 2, "flash_bytes": 99328, "ram_bytes": 46080 }
}
错误示例:
{
"status": "error",
"action": "build",
"error": { "code": "not_configured", "message": "构建目录不存在,请先执行 configure" }
}
.embeddedskills/state.json > 搜索/询问clean 不在自动流程中隐式执行elf_filejuliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills