internal-package-building

Organize Go package structures with cmd/internal boundaries and import path conventions.

1|1|Updated Dec 16, 2023
One-click install
npx skills add https://github.com/sjtw/tarkov-build-optimiser --skill internal-package-building
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: internal-package-building
Source: https://github.com/sjtw/tarkov-build-optimiser/tree/main/.cursor/skills/internal-package-building
Command: npx skills add https://github.com/sjtw/tarkov-build-optimiser --skill internal-package-building

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Organize internal Go package structures to enforce boundaries and clean import paths.

Core Features & Use Cases

  • Guidance on when to create a new internal package under internal/ (new domain) and when to extend an existing package.
  • Rules for package boundaries, cmd vs internal boundaries, and import path conventions.
  • Real-world example: organizing a monorepo into internal/db, internal/models, internal/candidate_tree, and internal/evaluator to keep boundaries clear and predictable.

Quick Start

Create a new directory under internal/ for the domain, add at least one Go file with a package name matching the directory, and route entry points through cmd/.

Frequently Asked Questions about internal-package-building

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure internal Go packages to enforce clean import paths?

Organize internal Go packages by creating dedicated directories under internal/ for each domain, ensuring package names match their directories and routing all entry points through cmd/ to enforce clean import paths. This prevents external modules from importing internal domain logic.

When should I create a new internal package versus extending an existing one in Go?

Create a new internal package when introducing a distinct domain boundary, and extend an existing package when adding features within the same domain. This keeps domain boundaries clear and predictable, preventing bloated packages and import path conflicts.

What is the difference between cmd and internal boundaries in a Go project layout?

The cmd directory serves as the entry point for executable binaries, while the internal directory restricts import access to the parent module. Routing through cmd/ ensures internal package boundaries remain unexposed to external import paths.

How do I organize a Go monorepo with multiple internal domains like db and models?

Structure a Go monorepo by placing shared logic into distinct internal/ directories such as internal/db, internal/models, and internal/evaluator. This enforces clear boundaries and predictable import paths across the repository.

Do I need any external dependencies to enforce internal package boundaries in Go?

No external dependencies are required to enforce internal package boundaries. Go's compiler natively restricts imports from the internal/ directory, allowing you to structure domains and route entry points through cmd/ using standard library features.