Claude-skill-registry internal-package-building
Guides adding and structuring internal Go packages: when to create a new package, import paths, cmd vs internal boundaries, and domain layout. Use when creating or refactoring code under internal/, adding a new domain, or when the user asks about internal package 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/internal-package-building" ~/.claude/skills/majiayu000-claude-skill-registry-internal-package-building && rm -rf "$T"
manifest:
skills/data/internal-package-building/SKILL.mdsource content
Internal Package Building Skill
Use this skill when creating or refactoring internal Go packages.
When to create a new package
- New domain → new directory under
(e.g. new feature area or bounded context).internal/ - Existing domain → add or edit files in the existing package; do not split without a clear boundary.
- Shared cross-cutting concern (DB, config, models) → use or extend existing shared packages (
,internal/db
,internal/models
) rather than creating a new one unless the concern is clearly separate.internal/env
Layout
- One package per directory; package name = directory name (e.g.
→internal/candidate_tree
).package candidate_tree - Entrypoints live only in cmd/ (e.g.
,cmd/api
,cmd/evaluator
). All shared logic lives in internal/.cmd/importer - internal/ must not import cmd/; cmd packages wire and call internal packages.
Imports
- Import internal packages by module path:
tarkov-build-optimiser/internal/<pkg> - Example:
import "tarkov-build-optimiser/internal/models"
Existing internal packages (use, don’t duplicate)
| Package | Role |
|---|---|
| Database connections and pool |
| Data types and SQL access (UpsertX, GetXById, etc.) |
| Environment/config |
| Shared pure helpers (e.g. maths) |
| Caching utilities |
| Build candidate tree logic |
| Build evaluation |
| Data import from external sources |
| HTTP routing and handlers |
| tarkov.dev API client |
Checklist for a new internal package
- Create
with at least oneinternal/<name>/
file; package name =.go
.<name> - Add only code that belongs to that domain; put shared DB/config in
orinternal/db
.internal/env - Import other internal packages via
.tarkov-build-optimiser/internal/... - Keep the package focused; if it grows into two clear domains, consider splitting into two packages only when the boundary is obvious.
- Add tests in the same package (
); use*_test.go
or*_unit_test.go
per project conventions.*_integration_test.go
Boundaries to respect
- No business logic in cmd/ — cmd only parses flags/env, opens DB, and calls internal packages.
- No circular imports — internal packages may depend on each other only acyclically; if you introduce a cycle, extract a shared type or helper into a lower-level package.
- Database access — use
for connections andinternal/db
for SQL and data types; do not add new ad-hoc DB packages.internal/models