/xmake-skills:xmake-policyfrom xmake-skills
Configures xmake build policies for feature toggles like sanitizers, LTO, warnings, C++ modules, and more. Use when setting set_policy in xmake.lua.
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.
Policies are named feature toggles xmake exposes via set_policy("<name>", <value>). They replace ad-hoc flags with a stable, versioned API — enabling a feature like "C++20 modules" or "address sanitizer" is a single call that works across compilers.
Policies live in xmake.lua and can be set at project or target scope.
-- project-wide
set_policy("build.warning", true)
target("app")
-- per-target
set_policy("build.optimization.lto", true)
set_policy("build.sanitizer.address", true)
xmake.lua) — applies to every target.target(...)) — only that target.Reading a policy from script:
on_load(function (target)
if target:policy("build.warning") then
...
end
end)
set_policy("build.warning", true) -- show compile warnings (default off)
set_policy("check.auto_ignore_flags", false) -- don't auto-filter unknown flags
set_policy("check.auto_map_flags", false) -- don't auto-map gcc→msvc flag names
set_policy("build.optimization.lto", true) -- enable LTO
set_policy("build.merge_archive", true) -- merge all static archives into one
set_policy("build.release.strip", true) -- strip release binaries (v3.0.8+)
set_policy("build.rpath", true) -- auto-emit rpath for shared deps
set_policy("install.rpath", true) -- same at install time
set_policy("build.intermediate_directory", true) -- use an intermediate dir per target
set_policy("build.sanitizer.address", true) -- -fsanitize=address
set_policy("build.sanitizer.thread", true) -- -fsanitize=thread
set_policy("build.sanitizer.memory", true) -- -fsanitize=memory
set_policy("build.sanitizer.leak", true) -- -fsanitize=leak
set_policy("build.sanitizer.undefined", true) -- -fsanitize=undefined
Mutually exclusive — enable one at a time. Usually gated by mode:
if is_mode("asan") then
set_policy("build.sanitizer.address", true)
end
set_policy("build.c++.modules", true) -- enable module build (required)
set_policy("build.c++.modules.std", true) -- enable `import std;`
set_policy("build.c++.modules.culling", true) -- drop unused modules
set_policy("build.c++.modules.reuse", true) -- reuse BMIs across targets
set_policy("build.c++.modules.reuse.strict", true)
set_policy("build.c++.modules.fallbackscanner", true) -- use fallback dep scanner
See xmake-cxx-modules.
set_policy("build.ccache", true) -- enable built-in cache
set_policy("build.ccache.global_storage", true) -- share cache across projects
set_policy("build.across_targets_in_parallel", true) -- build sibling targets in parallel
set_policy("build.fence", true) -- use fence barriers between phases
set_policy("build.distcc.remote_only", true) -- force all jobs to distcc server
set_policy("package.requires_lock", true) -- lockfile-based pinning
set_policy("package.precompiled", true) -- prefer binary packages
set_policy("package.fetch_only", true) -- fetch, don't install
set_policy("package.install_only", true) -- install, don't link
set_policy("package.install_always", true) -- reinstall each configure
set_policy("package.strict_compatibility", true) -- abi-strict pkg matching
set_policy("package.librarydeps.strict_compatibility", true)
set_policy("package.download.http_headers", {"Authorization: Bearer xyz"})
set_policy("preprocessor.linemarkers", true)
set_policy("preprocessor.gcc.directives_only", true) -- for ccache compatibility
set_policy("windows.manifest.uac", "invoker") -- asInvoker | highestAvailable | requireAdministrator
set_policy("windows.manifest.uac.ui", true)
set_policy("run.windows_error_dialog", false) -- disable popup on crash
set_policy("run.autobuild", true) -- auto-rebuild before xmake run
set_policy("build.cuda.devlink", true) -- CUDA device-link step
set_policy("build.c++.dynamic_debugging", true) -- enable dynamic debugging (v3.0.6+)
The full list lives in xmake's source:
xmake l core.base.policy.policies
Or browse xmake-docs: API → description → Built-in Policies has the canonical list with version badges (v2.3.4+, etc.). Use the badge to check minimum xmake version for a given policy.
Most policies can also be set transiently on xmake f:
xmake f --policies="build.sanitizer.address"
xmake f --policies="build.optimization.lto,build.warning"
Comma-separated list; booleans default to true. Useful for one-off CI runs without touching xmake.lua.
target("app")
if is_mode("release") then
set_policy("build.optimization.lto", true)
set_policy("build.release.strip", true)
elseif is_mode("debug") then
set_policy("build.warning", true)
elseif is_mode("asan") then
set_policy("build.sanitizer.address", true)
end
Don't enable LTO in debug — makes builds slower with no benefit.
on_config(function (target)
if target:policy("build.c++.modules") then
-- do module-specific config
end
end)
target:policy("name") returns the effective value (target policy overriding project policy).
You can register your own policies for use by custom rules:
-- at top of xmake.lua
import("core.base.policy")
policy.register("mycompany.enable_hardening", "boolean")
target("app")
set_policy("mycompany.enable_hardening", true)
rule("hardening")
on_config(function (target)
if target:policy("mycompany.enable_hardening") then
target:add("cxflags", "-fstack-protector-strong", "-D_FORTIFY_SOURCE=2")
end
end)
Types: "boolean", "string", "number", "table".
set_policy("build.optimization.lto", true) is portable; add_cxflags("-flto") is not — use the policy.set_xmakever("2.8.0") at the top of your xmake.lua if needed.set_policy replaces the project value entirely. If you want to merge, handle it in on_load.package.install_always. Reinstalls every configure — don't leave it on in shared config; kills iteration speed.build.warning default is off. Many users are surprised by this. Turn it on at the project level during dev, off in CI for stable outputs.xmake-targetsxmake-cxx-modulesxmake-build-optimizationxmake-packages, xmake-private-packagesxmake-rules, xmake-scriptingWhat 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`.Other plugins' skills for the same job