This is a build orchestrator for Keil MDK embedded projects that scans for .uvprojx files, enumerates targets, runs build/rebuild/clean operations, and parses the logs to extract artifact paths. It's designed to sit between your Keil toolchain and downstream flashers like jlink or openocd, giving you structured JSON output instead of raw UV4 console noise. The configuration cascades from environment to workspace to CLI args, and it refuses to guess when multiple projects or targets exist, which is the right call. One thing to know: it won't modify your project files and blocks flashing if the last build had errors. Useful if you're automating Keil workflows or just tired of hunting through build logs for the hex file path.
npx -y skills add zhinkgit/embeddedskills --skill keil --agent claude-codeInstalls into .claude/skills of the current project.
本 skill 提供 Keil MDK 工程的发现、Target 枚举、构建、重建、清理能力,并返回可供 jlink/openocd 继续使用的固件产物路径。flash 仅作为兼容入口保留。
skill 目录下的 config.json 包含环境级配置,首次使用前确认 uv4_exe 路径正确:
{
"uv4_exe": "C:\\Keil_v5\\UV4\\UV4.exe",
"operation_mode": 1
}
uv4_exe:UV4.exe 完整路径(必填)operation_mode:1 直接执行 / 2 输出风险摘要但不阻塞 / 3 执行前确认工程级共享配置统一保存在工作区的 .embeddedskills/config.json 中:
{
"keil": {
"project": "",
"target": "",
"log_dir": ".embeddedskills/build"
}
}
project:默认工程路径(相对 workspace),构建成功后会自动更新target:默认 Target 名称,构建成功后会自动更新log_dir:构建日志输出目录,默认 .embeddedskills/build参数解析顺序(从高到低):
.embeddedskills/state.json(上次构建记录)| 子命令 | 用途 | 风险 |
|---|---|---|
scan | 搜索当前目录下的 .uvprojx/.uvmpw 工程 | 低 |
targets | 枚举工程中的 Target | 低 |
build | 增量编译 | 中 |
rebuild | 全量重建 | 中 |
clean | 清理工程 | 高 |
flash | 通过 Keil 烧录固件(兼容入口,优先建议使用 jlink/openocd) | 高 |
config.json,确认 uv4_exe 路径有效scanscan 搜索工程build/rebuild/clean 按 operation_mode 决定是否需要确认build/rebuild 成功后,尽量从工程配置中解析 flash_file / debug_file 等产物路径flash 仅在最近一次构建成功时允许执行skill 目录下有两个 Python 脚本,使用标准库实现,无额外依赖。
# 扫描工程
python <skill-dir>/scripts/keil_project.py scan --root <搜索目录> --json
# 枚举 Target
python <skill-dir>/scripts/keil_project.py targets --project <工程路径> --json
python <skill-dir>/scripts/keil_build.py <build|rebuild|clean|flash> \
--uv4 <UV4路径> \
--project <工程路径> \
--target <TargetName> \
--log-dir <日志目录> \
--json
rebuild 额外支持 --clean-first 使用 -cr 而非 -r。
所有脚本以 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": "project.uvprojx",
"target": "Debug",
"log_file": ".build/project-Debug-build.log",
"flash_file": "Objects/project.hex",
"debug_file": "Objects/project.axf"
},
"metrics": { "errors": 0, "warnings": 2, "flash_bytes": 32768, "ram_bytes": 8192 }
}
错误示例:
{
"status": "error",
"action": "flash",
"error": { "code": "build_not_clean", "message": "最近一次构建存在错误,禁止继续烧录" }
}
flash_file / debug_file 与 jlink/openocd 串联flash 前必须确认最近一次构建成功(errors == 0)clean 不在自动流程中隐式执行遇到编译器相关问题时可查阅 references/compiler-notes.md。
juliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills