Help us improve
Share bugs, ideas, or general feedback.
From xmake-skills
Creates, lists, and authors xmake project templates. Use when scaffolding new projects with `xmake create -t <template>` or distributing custom templates.
npx claudepluginhub xmake-io/xmake-skills --plugin xmake-skillsHow this skill is triggered — by the user, by Claude, or both
Slash command
/xmake-skills:xmake-templatesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A template is a directory tree with an `xmake.lua` and some starter source files. `xmake create` copies it into a new project directory, substituting a few placeholders. Templates come from three places, searched in this order:
Guides users through starting a new Xmake project: installation (brew, curl, scoop), creating projects from templates, and writing the minimal xmake.lua. Helpful for first-time Xmake users or scaffolding a new project.
Guides creating reusable angreal project templates for `angreal init`, covering angreal.toml config, Tera templating, variables, prompts, validation, and publishing.
Instantiates JSON project templates for webapps, APIs, ML pipelines, mobile, and infrastructure projects into customizable phases, epics, and stories.
Share bugs, ideas, or general feedback.
A template is a directory tree with an xmake.lua and some starter source files. xmake create copies it into a new project directory, substituting a few placeholders. Templates come from three places, searched in this order:
xmake repo --list), e.g. packages/templates from xmake-repo.~/.xmake/templates/.$(programdir)/repository/templates/.xmake create --list # all languages, all sources
xmake create --list -l c++ # only C++ templates
Output groups templates by source (repo / global / builtin) and by language, so you can see which names are available for -t.
xmake create hello # default: c++ console
xmake create -l c hello # C, default "console" template
xmake create -l c++ -t console myapp
xmake create -l c++ -t static mylib
xmake create -l c++ -t shared mydyn
xmake create -l c -t module mymod
xmake create -l rust hello
xmake create -l go -t console hello
Flags:
-l, --language — language (c, c++, rust, go, swift, objc, cuda, dlang, fortran, kotlin, nim, pascal, vala, zig, csharp).-t, --template — template id inside that language.-P <dir> — create into a specific directory instead of the current one.demo).Qt, SDL, Python bindings, Linux drivers, raylib, verilator, wxWidgets, etc. are shipped in xmake-repo/templates/. They live under nested template ids using . as separator:
xmake create -l c++ -t qt.widgetapp myqtapp
xmake create -l c++ -t qt.quickapp myquick
xmake create -l c++ -t wxwidgets mywx
xmake create -l c++ -t python.pybind11 mybind
xmake create -l c -t sdl mysdl
xmake create -l c -t raylib mygame
xmake create -l c -t linux.driver mydriver
qt.widgetapp resolves to <repo>/templates/c++/qt/widgetapp/. Each path segment between dots is a directory level.
xmake create -P myproj -l c++ -t console hello
cd myproj && xmake
A template is just:
<root>/<language>/<template-id-path>/
├── xmake.lua # with ${TARGET_NAME} / ${FAQ} placeholders
└── src/
└── main.cpp # or whatever source files the template needs
When you run xmake create, xmake copies the entire directory tree to the destination and substitutes placeholders in both filenames and file contents.
Verified from xmake/actions/create/template.lua:
| Placeholder | Value |
|---|---|
${TARGET_NAME} | The positional project/target name passed to xmake create |
${FAQ} | Contents of $(programdir)/scripts/faq.lua — a short FAQ block appended to the generated xmake.lua |
Example built-in c/console/xmake.lua:
add_rules("mode.debug", "mode.release")
target("${TARGET_NAME}")
set_kind("binary")
add_files("src/*.c")
${FAQ}
After xmake create -l c hello, the emitted xmake.lua has target("hello") and the FAQ block inlined.
Either of these is picked up automatically; no registration step needed:
~/.xmake/templates/<language>/<template-id>/ — personal, visible on your machine only.<repo>/templates/<language>/<template-id>/ — distributable to anyone who adds your repo.Template IDs can be nested: ~/.xmake/templates/c++/game/sdl2/ → -t game.sdl2.
~/.xmake/templates/c++/game/sdl2/
├── xmake.lua
├── src/
│ └── main.cpp
└── assets/
└── .gitkeep
Template xmake.lua:
add_rules("mode.debug", "mode.release")
set_languages("c++17")
add_requires("libsdl2")
target("${TARGET_NAME}")
set_kind("binary")
add_files("src/*.cpp")
add_packages("libsdl2")
${FAQ}
Template src/main.cpp:
#include <SDL2/SDL.h>
int main(int, char**) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
return 0;
}
xmake create --list -l c++ # your template should appear under "c++/game.sdl2"
xmake create -l c++ -t game.sdl2 myshooter
cd myshooter
xmake
${TARGET_NAME}.h becomes myshooter.h.${...} — they will be left as literal text in the output.Nothing special — just drop more files into the template tree. Globs in the template xmake.lua (add_files("src/*.cpp")) will pick up whatever the user adds later, so keep file lists glob-based rather than enumerated.
If you want other people to use your template:
xmake-repo.templates/<language>/<id...>/.Or, for a private template library, host your own repo:
xrepo add-repo my-templates https://github.com/me/my-xmake-templates
Once the repo is registered globally, its templates/ directory is picked up by xmake create --list and usable via -t.
. on the CLI (-t qt.widgetapp) — not /. xmake splits on . to walk the template tree.--list doesn't show my template. Either the directory is not at <root>/<language>/<id>/, or there is no xmake.lua in it. templatedir() requires both.${TARGET_NAME} and ${FAQ} are real. Anything else you write with ${...} is left verbatim.-l must exactly match the directory name under templates/. c++ not cpp; objc++ not objcxx.xmake create rejects ., .., /, \, :, or NUL in template ids and language names. Keep template ids to plain identifiers separated by dots.xmake create for scaffolding an existing project. It creates files in an otherwise empty directory; running it inside a populated directory will error out if files would be overwritten. Use a fresh directory or -P <new-dir>.xmake create flow as part of "getting started" → xmake-basicsxmake-packagesxmake.lua body that ends up in the template → xmake-targets, xmake-rules