Claude-skill-registry cmd-builder
Guides adding and structuring Go command entrypoints under cmd/: when to create a new cmd, layout, wiring only (no business logic), and use of internal packages. Use when creating or refactoring code under cmd/, adding a new executable, or when the user asks about cmd or entrypoint structure.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/cmd-builder" ~/.claude/skills/majiayu000-claude-skill-registry-cmd-builder && rm -rf "$T"
manifest:
skills/data/cmd-builder/SKILL.mdsource content
Cmd Builder Skill
Use this skill when creating or modifying command entrypoints under
cmd/.
When to create a new cmd
- New executable (new binary, distinct from api/evaluator/importer/migrations) → new directory under
withcmd/<name>/
.main.go - Existing executable → add flags or wiring in that cmd; do not add a second main for the same concern.
- Shared orchestration or workflow → implement in
and call from cmd; keep cmd thin.internal/
Layout
- One entrypoint per directory:
,cmd/<name>/main.go
.package main - Each cmd builds to a single binary; the directory name is the conventional binary name (e.g.
→cmd/api
).api - All logic lives in internal/; cmd only parses flags/env, opens resources (DB, etc.), and calls internal packages.
What cmd does (and does not)
- Does: Parse flags (e.g.
) or env (internal/cli
); create DB client (internal/env
); wire and call internal packages; log and exit on startup failure (internal/db
or zerolog).log.Fatal - Does not: Contain business logic, algorithms, or domain rules; those live in
. If a cmd grows a large loop or workflow, consider moving it into aninternal/
package so it can be tested and reused.internal/
Existing cmd apps (use as reference)
| Cmd | Role |
|---|---|
| Load env, create DB client, start HTTP router (). |
| Load env and CLI flags, create DB and cache, run evaluation workflow via and . |
| Load env, create DB and tarkov.dev client, run and purge/import. |
| Parse args, open DB, run goose migrations. |
Imports
- Cmd imports internal by module path:
.tarkov-build-optimiser/internal/<pkg> - Example:
.import "tarkov-build-optimiser/internal/env" - internal/ must not import cmd/.
Checklist for a new cmd
- Create
withcmd/<name>/main.go
and apackage main
that exits on error (e.g.main()
).log.Fatal - Parse config: use
for env vars and optionallyinternal/env
for flags.internal/cli - Open resources (e.g.
); defer or otherwise ensure cleanup where appropriate.internal/db - Construct and call internal packages only; no business logic in main.
- If the workflow is more than a few calls, consider an orchestration function in
and call it from main.internal/
Boundaries to respect
- No business logic in cmd/ — cmd wires and invokes; all domain and workflow logic stays in
.internal/ - One main per binary — one
per distinct executable.cmd/<name>/main.go - internal does not import cmd — dependency flow is cmd → internal only.