From geant4-claude
Use when the user wants to compile/build their Geant4 source tree (a src/ dir with CMakeLists.txt) into a runnable executable. Builds via CMake inside the pinned apptainer image into ./build/. Requires geant4-init to have run.
How this skill is triggered — by the user, by Claude, or both
Slash command
/geant4-claude:geant4-buildThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Compile the user's Geant4 application from `src/` into `./build/` using CMake
Compile the user's Geant4 application from src/ into ./build/ using CMake
inside the pinned apptainer image. The single bridge from source to a runnable
executable — never call cmake, g++, or make on the host directly.
| Flag | Default | Meaning |
|---|---|---|
--src <dir> | src | Source dir; must contain a top-level CMakeLists.txt. |
--build <dir> | build | Build dir; created if missing. |
--clean | off | Delete <build> before configuring. |
Resolve the engine (every skill starts with this; written by geant4-init):
G4C="$PWD"; while [ "$G4C" != "/" ] && [ ! -d "$G4C/.g4c" ]; do G4C="$(dirname "$G4C")"; done
[ -f "$G4C/.g4c/env" ] && . "$G4C/.g4c/env"; G4RUN="${G4RUN:-$G4C/.g4c/g4run}"
If .g4c/ is missing, stop and tell the user to run the geant4-init skill
first.
Validate source:
test -f "${SRC}/CMakeLists.txt" || { echo "no ${SRC}/CMakeLists.txt"; exit 1; }
If missing, suggest the geant4-example skill (drops in a working sample) or
bringing your own and pointing --src at it.
Optional clean. If --clean: rm -rf "${BUILD}".
Build:
"${G4RUN}" build "${SRC}" "${BUILD}"
Both paths are passed to apptainer as canonical (symlink-resolved) paths and bound automatically — CWD-relative paths work.
Report. Show the build dir and the executables now under it
(find "${BUILD}" -maxdepth 3 -type f -executable -not -path '*CMakeFiles*'),
and point at the geant4-run skill. If the build wrote no executable, that's
a likely missing add_executable in the user's CMakeLists.txt.
<build>/ populated with CMake artifacts and the compiled binary(ies).| Symptom | Likely cause | Fix |
|---|---|---|
.g4c/ missing | Workspace not initialized. | Run the geant4-init skill first. |
no src/CMakeLists.txt | No source yet. | Use the geant4-example skill, or bring your own. |
Could not find a package configuration file provided by "Geant4" | find_package(Geant4 …) missing or misspelled. | Mirror ${GEANT4_CLAUDE_ROOT}/templates/example/src/CMakeLists.txt. |
error: 'FTFP_BERT.hh' file not found | Header not in include path. | The container's find_package(Geant4) brings includes in; check typos and include(${Geant4_USE_FILE}). |
| Build succeeds but no executable | No add_executable directive. | Add it to src/CMakeLists.txt and rebuild. |
Linker undefined references to ROOT::* | find_package(ROOT …) missing or wrong components. | Add find_package(ROOT REQUIRED COMPONENTS Tree RIO) and link ROOT::Core ROOT::RIO ROOT::Tree. |
./build/ is gitignored by the workspace .gitignore from the geant4-init step.--clean
for a from-scratch rebuild."${G4RUN}" shell to enter
the container and run cmake by hand — this skill stays minimal.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub zhaozhiwen/geant4_claude --plugin geant4-claude