/xmake-skills:xmake-rulesfrom xmake-skills
Applies built-in Xmake rules (mode.debug, mode.release, qt.widgetapp, c++.unity_build) and helps write custom rules for new file extensions or codegen steps.
Ships in xmake-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Rules are reusable bundles of build logic. You apply them with add_rules(...) at project or target scope, or define your own with rule(...).
Build modes (at project scope):
add_rules("mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel")
This enables xmake f -m debug|release|... and sets the corresponding flags.
Target-level built-ins:
target("app")
add_rules("c++.unity_build", {batchsize = 8}) -- unity builds
add_rules("c.unity_build")
add_rules("win.sdk.application") -- Windows GUI entry
add_rules("qt.widgetapp") -- Qt widgets app
add_rules("xcode.application") -- iOS/macOS app bundle
add_rules("plugin.compile_commands.autoupdate", {outputdir = "."})
plugin.compile_commands.autoupdate automatically regenerates compile_commands.json on every build — great for clangd/LSP.
These attach to individual files through add_files(..., {rules = ...}):
-- embed a binary file as a c array (foo.bin -> foo.bin.h)
add_files("res/foo.bin", {rules = "utils.bin2c"})
-- embed it as an object file instead, no header generated
add_files("res/foo.bin", {rules = "utils.bin2obj"})
-- patch a source file while building, without touching the file on disk
add_files("src/foo.c", {rules = "utils.replace",
replaces = {{"RDKCONST%);", "VDKREG);"}}})
add_files("src/foo.c", {rules = "utils.replace",
replaces = {{"RDKCONST);", "VDKREG);"}}, replace_plain = true})
add_files("src/foo.c", {rules = "utils.replace", replaces = function (content)
return (content:gsub("old", "new"))
end})
The generated header holds only the byte list, and the rule adds its directory to the target's includedirs itself, so the consumer is:
static const unsigned char g_foo[] = {
#include "foo.bin.h"
};
utils.replace (v3.0.9+) is the clean way to carry a small vendor patch: the transform runs
in the build directory, the repository stays unmodified. utils.bin2c / utils.bin2obj
(v3.1.0 gained lua-file transforms and ppc/mips support) embed resources without a
generator step.
Use a rule to teach Xmake how to handle a new file extension.
rule("protobuf")
set_extensions(".proto")
on_load(function (target)
target:add("includedirs", "$(buildir)/proto")
end)
before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
local outputdir = path.join(target:autogendir(), "proto")
local sourcefile_cx = path.join(outputdir, path.basename(sourcefile) .. ".pb.cc")
batchcmds:mkdir(outputdir)
batchcmds:vrunv("protoc", {"--cpp_out=" .. outputdir, sourcefile})
target:add("files", sourcefile_cx)
batchcmds:add_depfiles(sourcefile)
batchcmds:set_depmtime(os.mtime(sourcefile_cx))
batchcmds:set_depcache(target:dependfile(sourcefile_cx))
end)
rule_end()
target("app")
add_rules("protobuf")
add_files("proto/*.proto", "src/*.cpp")
on_load, on_config, before_build, on_build_file, on_buildcmd_file, before_link, after_build, on_clean, etc. Use the *cmd* variants when you want to emit commands into the batch runner (with dependency tracking); use plain hooks for arbitrary Lua logic.
add_rules("mode.debug", "mode.release") -- global: applies to all targets
target("app")
add_rules("c++.unity_build") -- only to this target
xmake-targetsxmake-toolchainsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub xmake-io/xmake-skills --plugin xmake-skills58 skills in this plugin
/xmake-addon-developmentUse when writing an Xmake addon — the `addon.lua` manifest, the payload layout (plugins/rules/toolchains/modules/includes/templates), `@self` references, shipping package definitions with an addon, `add_globalmodules`, testing it locally, and publishing it to xmake-repo as an `addon` kind package./xmake-addonsUse when installing or using an Xmake addon — `xmake addon --install/--list/--remove/--upgrade/--search`, declaring `add_addons(...)` in a project, and referencing addon payloads with `@addon/<name>/<rule>`, `@addon.<name>.<module>` or `@self`. For writing and publishing one, see xmake-addon-development./xmake-async-jobsUse when running parallel / async work inside xmake scripts — `async.runjobs` for parallel job execution, `async.jobgraph` (DAG) for dependency-ordered jobs, `async.jobpool` (tree structure), `core.base.scheduler` coroutine scheduling, semaphores, and `on_build_files(..., {jobgraph = true})` in rules. For running external compile jobs faster, see `xmake-build-optimization`./xmake-basicsUse when the user is starting a new Xmake project, installing Xmake, or needs the minimal xmake.lua structure. Covers installation, `xmake create`, the project layout, and the smallest valid xmake.lua./xmake-build-cacheUse when configuring or debugging xmake's local build cache (built-in, replaces ccache) or the remote compile cache service (shared across machines via `xmake service --ccache`). Covers enabling/disabling, fallbacks to external ccache, remote cache server/client setup, and cache cleaning./xmake-build-optimizationUse when a project builds slowly and you want to make it faster — parallel jobs, unity build, precompiled headers, build cache, LTO, link-time improvements, binary package cache, and profiling with `XMAKE_PROFILE=perf:*`. Covers idiomatic xmake speedups and the order to try them.Other plugins' skills for the same job