agentleFS
ninoverseninoverse/claude-mit-go-template/.claude/skills/new-package/SKILL.md

new-package

Skill0 starsChanged 45 days agoMITView on GitHub

Add a package to the module following the 9-step package workflow

5 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. LedgerHQ/ledger-live★ 628same name
    2. petarzarkov/dunx★ 93same name
    3. joi-fairshare/agentic-workflow★ 3same name
    4. jthorare/agentic-workflow★ 3same name
    5. RemiMyrset/roots★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow every step in order.

    line 11
  2. Distinctive:

    Before writing any code:

    line 19
  3. Distinctive:

    If it exists, report the finding and ask: skip / overwrite / modify.

    line 28
  4. Very specific:

    Create internal/<pkg>/<pkg>.go (or cmd/<binary>/main.go) with the matching package clause.

    line 52
  5. Very specific:

    Every exported identifier gets a doc comment starting with its own name (// New returns …).

    line 59
  6. Very specific:

    If .agents/new-package.local.md exists, follow it now, before the gate.

    line 108
  7. Distinctive:

    Every gate, zero findings, before committing.

    line 116
  8. Very specific:

    Every returned error is checked in non-test code — errcheck is on, and _ = does not satisfy it.

    line 146

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- language/go/tasks/new-unit.md · v1.0.1 -->

Adding a package

The exact procedure for adding or modifying a single package in this Go module. Follow every step in order; do not skip or reorder.

The package to add: $ARGUMENTS


Pre-flight

Before writing any code:

  1. Ask for confirmation. State which package you are about to add and what it will contain. Wait for explicit approval. Do not start on your own initiative.
  2. Check if the package already exists:
    ls internal/<pkg>/ 2>/dev/null && echo EXISTS || echo MISSING
    If it exists, report the finding and ask: skip / overwrite / modify. Never silently overwrite.

Decide the location before scaffolding: internal/<pkg>/ for a private package, cmd/<binary>/main.go for an executable, pkg/<pkg>/ only if it is genuinely meant for import from outside this module.


9-step checklist (one package)

Complete all nine steps before committing. Never commit a partial package.

1. Scaffold the package

mkdir -p internal/<pkg>          # use cmd/<binary> for an executable instead

Package directory and name are short and all-lowercase (e.g. internal/store, package store). A binary lives at cmd/<binary>/main.go with package main.

2. First file

Create internal/<pkg>/<pkg>.go (or cmd/<binary>/main.go) with the matching package clause. There is no per-package manifest — Go discovers the package from its directory.

3. Public API surface

  • Export only what callers need; keep the rest unexported (lowercase).
  • Every exported identifier gets a doc comment starting with its own name (// New returns …).
  • The package gets a // Package <pkg> … comment, in doc.go or atop the primary file.

4. File split

Any file growing past ~150 LOC, or holding a distinct concern, moves to its own lowercase .go file in the same package (e.g. repository.go, errors.go).

5. Unit tests

<file>_test.go beside the code, using table-driven subtests:

func TestDoThing(t *testing.T) {
    cases := []struct {
        name string
        in   int
        want int
    }{
        {"doubles", 2, 4},
    }
    for _, tc := range cases {
        t.Run(tc.name, func(t *testing.T) {
            if got := DoThing(tc.in); got != tc.want {
                t.Errorf("DoThing(%d) = %d, want %d", tc.in, got, tc.want)
            }
        })
    }
}

6. Examples + black-box tests

  • Example functions with an // Output: comment document and verify usage; they run under go test and appear in go doc.
  • For consumer-facing coverage, use package <pkg>_test files that import the package as an outside caller would.

7. Dependencies & wiring

Cross-package use is a plain import: import "<module-path>/internal/<other>", with the module path from go.mod. New third-party dependencies are added with go get <module> and land in go.mod/go.sum — run go mod tidy before committing.

8. Verification gate

If .agents/new-package.local.md exists, follow it now, before the gate. It holds the steps this repository adds to this checklist; it is written by hand, and agentcfg leaves it alone.

make ci

Every gate, zero findings, before committing. See Testing instructions for what it runs.

Two that catch people out on a new package specifically:

  • revive requires a package comment as well as a doc comment on every exported identifier, so a package is red until it has one.
  • goimports groups this module's own imports last. An import block gofmt accepts can still fail make fmt-check.

9. Commit, then hand the PR over

feat(<pkg>): add <pkg> package

One package per PR. Never batch multiple packages. Commit and hand the PR over as Git flow and PR instructions say.


Before committing

Points that are easy to get wrong, so verify each one:

  • A package comment (// Package <pkg> …) on one file, and a doc comment starting with the identifier's own name on every exported identifier. revive enforces both, so the package is red without them.
  • Imports of this module are grouped last by goimports. An import block that gofmt accepts can still fail make fmt-check.
  • Every returned error is checked in non-test code — errcheck is on, and _ = does not satisfy it. Errors are wrapped with %w as they propagate.
  • At least one test, table-driven with subtests where there are multiple cases.
  • make ci passes before you commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.