/xmake-skills:xmake-debug-package-sourcefrom xmake-skills
Debug xmake-repo packages that fail to build or misbehave by editing upstream source in place, iterating with `-d <dir>`, and extracting patches once fixed.
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.
Packages installed via add_requires / xrepo fail for many reasons — upstream bug on your toolchain, outdated patch, missing flag. This skill is about the iteration loop for fixing a broken package recipe or upstream source without losing work between attempts.
Default recipe flow:
add_requires("foo") → fetch tarball → apply patches → on_install → on_test
Each time the recipe runs, xmake blows away the extracted source and re-applies patches. That's fine for stable packages, terrible for debugging — every change you make to the unpacked source is lost on the next run.
-d <local-source-dir> with scripts/test.luaInside an xmake-repo clone (your own or the official one):
xmake l scripts/test.lua -vD --shallow -d /tmp/zlib-1.2.11 zlib
-d <dir> — tells the test script to use your local source directory instead of re-downloading and re-extracting. Your edits persist across runs.--shallow — don't rebuild transitive dependencies (see xmake-repo-testing).-vD — verbose + tracebacks.# 1. Download & unpack once
curl -LO https://zlib.net/zlib-1.2.11.tar.gz
tar xf zlib-1.2.11.tar.gz -C /tmp
cd xmake-repo
# 2. First run — sees what fails
xmake l scripts/test.lua -vD --shallow -d /tmp/zlib-1.2.11 zlib
# ... some configure step blows up ...
# 3. Edit /tmp/zlib-1.2.11/configure to fix it
vim /tmp/zlib-1.2.11/configure
# 4. Re-run — your edit is still there
xmake l scripts/test.lua -vD --shallow -d /tmp/zlib-1.2.11 zlib
# 5. Iterate until it builds + on_test passes
Without -d, step 4 would re-extract the tarball and wipe your edit. This is the difference between "debug in 5 minutes" and "debug in an afternoon".
Once you've fixed the bug locally, generate a patch for the recipe:
cd /tmp/zlib-1.2.11
tar xf ~/Downloads/zlib-1.2.11.tar.gz -C /tmp/zlib-1.2.11.orig --strip-components=1
diff -urN /tmp/zlib-1.2.11.orig /tmp/zlib-1.2.11 > /path/to/xmake-repo/packages/z/zlib/patches/my-fix.patch
Easier if the source directory is a git repo:
cd /tmp/zlib-1.2.11
git init && git add -A && git commit -m "upstream"
# make edits
git diff > /path/to/xmake-repo/packages/z/zlib/patches/1.2.11/fix.patch
Then reference it from the recipe:
-- packages/z/zlib/xmake.lua
package("zlib")
...
add_patches("1.2.11", path.join(os.scriptdir(), "patches/1.2.11/fix.patch"),
"<sha256-of-patch-file>")
Compute the sha256 with xmake l hash.sha256 path/to/patch.patch or shasum -a 256 patch.patch.
on_install itselfIf the failure is in the recipe's Lua logic (not the upstream source), sprinkle print / cprint:
on_install(function (package)
print("package install dir: %s", package:installdir())
print("current configs: %s", os.args(table.keys(package:configs() or {})))
print("build kind: %s", package:is_library() and "lib" or "bin")
import("package.tools.cmake").install(package, {
"-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"),
"-DBUILD_TESTING=OFF"
})
end)
With -vD, every os.exec the recipe runs shows up, and any Lua error prints a traceback pointing at the recipe line number.
package instance methodsInside on_install / on_test, the package object exposes:
package:name() -- "zlib"
package:version() -- version instance (package:version():shortstr() for a string)
package:plat() -- "macosx" | "linux" | ...
package:arch() -- "x86_64" | "arm64" | ...
package:is_plat("linux") -- convenience
package:is_cross() -- cross-compiling?
package:config("shared") -- recipe option value
package:configs() -- all configs
package:installdir() -- destination dir
package:installdir("lib") -- subdir inside it
package:sourcedir() -- unpacked source dir (after fetch)
package:buildhash() -- hash identifying this build
package:dep("zlib") -- another package the recipe depends on
package:has_cfuncs("foo", {includes = "foo.h"}) -- for on_test
After on_install succeeds, the installed tree lives under:
~/.xmake/packages/<a>/<name>/<version>/<hash>/
├── include/
├── lib/
├── bin/
└── xmake.lua (metadata)
Inspect it:
xmake require --info zlib
# -> installdir, cachedir, fetchinfo, etc.
ls ~/.xmake/packages/z/zlib/1.2.11/*/
nm ~/.xmake/packages/z/zlib/1.2.11/*/lib/libz.a | head
If the binary is wrong, you're back to step 1 — fix the source, re-run with -d.
Xmake aggressively caches package installs. If a recipe change seems to have no effect:
xmake require --force zlib # project context
xrepo install --force zlib # standalone
rm -rf ~/.xmake/packages/z/zlib # nuclear
--force re-runs on_install and its test.
Load the package in an xmake Lua REPL:
xmake l
> import("core.package.package")
> local pkg = package.load("zlib")
> print(pkg:installdir())
> print(pkg:version_str())
Or run a script fragment:
xmake l -c '
import("core.package.package")
local pkg = package.load("zlib")
for k, v in pairs(pkg:configs() or {}) do print(k, v) end
'
If the failure only reproduces on another platform (Linux on your Mac, Windows on Linux), use the remote service:
# on the remote machine:
xmake service # start server
# locally:
cd xmake-repo
xmake service --connect
xmake l scripts/test.lua -vD --shallow --remote -d /tmp/zlib-1.2.11 zlib
The -d directory is synced to the server, the build happens there, and output streams back to you. See xmake-remote-compilation.
xmake l scripts/test.lua still downloads fresh sourceForgot -d. The test script only reuses your local tree when explicitly told.
import("package.tools.cmake").install(package, {...}) and failsRead what cmake sees:
on_install(function (package)
import("package.tools.cmake").install(package, {
"-DCMAKE_VERBOSE_MAKEFILE=ON", -- see actual compile commands
"-DBUILD_TESTING=OFF"
})
end)
Or drop to raw os.vrunv for total control:
on_install(function (package)
os.cd(package:sourcedir())
os.vrunv("cmake", {"-B", "build", "-G", "Ninja", "-DBUILD_TESTING=OFF"})
os.vrunv("cmake", {"--build", "build", "--target", "install"})
os.cp("build/install/*", package:installdir())
end)
on_test fails but the lib seems fineRun the test compile manually:
find ~/.xmake/cache/packages -name "test.cpp" -path "*zlib*"
# look at what xmake tried to compile; run it by hand with the right -I / -L / -l
Or make on_test simpler to isolate:
on_test(function (package)
assert(os.isfile(path.join(package:installdir("lib"), "libz.a")))
end)
~/.xmake/packages/<pkg>/<hash>/ directly. That's the installed tree — xmake rebuilds it from source on any recipe/source change. Edits there are ephemeral. Work in the source dir you pointed -d at.--shallow. Without it, every dep is rebuilt from source on each iteration — glacial.add_patches, xmake applies them after extracting source. Either remove the patch while debugging or commit your edits to a git branch on top and regenerate the patch at the end.add_versions pins a sha256; changing the URL/version without updating the hash makes xmake refuse.on_install errors with upstream errors. An error from import("package.tools.cmake").install may come from cmake itself — read up the stack carefully.~/.xmake/packages after toolchain switch. A package built with gcc-11 won't re-run for gcc-12 automatically unless the hash changes. --force or delete the hash dir.xmake-repo-testingxmake-private-packagesxmake-packagesxmake-remote-compilationxmake-troubleshootingWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
58 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.npx claudepluginhub xmake-io/xmake-skills --plugin xmake-skillsOther plugins' skills for the same job