cmd-builder

Organize Go command entrypoints under cmd/ with thin main.go files.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Go developers organize and wire command-line entrypoints under the cmd/ directory, ensuring consistent layout and clean separation of concerns.

Core Features & Use Cases

  • Clear project structure: promotes one entrypoint per directory under cmd/ with main.go.
  • Wiring only, no business logic: cmd remains thin and delegates core behavior to internal packages.
  • Onboarding & refactoring: simplifies adding new executables or refactoring existing ones with standard patterns.
  • Use Case: when starting a new CLI tool, create cmd/<name>/main.go and wire to internal packages; when enhancing an existing tool, add flags and wiring without duplicating main.

Quick Start

Create a new directory cmd/<name>/ with main.go and wire it to internal packages, keeping business logic in internal/ and the cmd minimal.

Frequently Asked Questions about cmd-builder

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

FAQPage Schema
How do I structure a Go CLI project with multiple executables under cmd?

A Go CLI project structures multiple executables by placing one entrypoint per directory under cmd/<name>/main.go. This enforces a consistent layout where each subdirectory represents a distinct binary, keeping project organization predictable and clean.

Should I put business logic in main.go when building a Go CLI?

Business logic should not go in main.go when building a Go CLI. The cmd directory must remain thin, handling only flags and environment setup, while delegating core behavior and wiring to internal packages for clean separation of concerns.

What is the standard cmd directory layout for Go applications?

The standard cmd directory layout for Go applications enforces one entrypoint per subdirectory, named cmd/<name>/main.go. It handles wiring and environment setup exclusively, directing all business logic to the internal/ package directory to maintain thin executables.

How do I refactor an existing Go CLI to use the cmd and internal pattern?

Refactoring an existing Go CLI to use the cmd and internal pattern involves moving business logic to internal packages and keeping only flag parsing and environment setup in cmd/<name>/main.go. This ensures the entrypoint stays thin and wiring is cleanly delegated.

When do I need to create a new cmd entrypoint in a Go project?

You need to create a new cmd entrypoint in a Go project when adding a separate executable binary. Create a new directory cmd/<name>/ with a main.go file, wire it to existing internal packages, and ensure it only handles flags and environment setup without duplicating logic.

Can I have multiple main.go files in a single cmd directory in Go?

You should not place multiple main.go files in a single cmd directory in Go. The pattern enforces one entrypoint per directory under cmd/<name>/ to maintain a predictable project structure and prevent conflicting binary definitions within the same package.