AGENT SKILL

add-package

Scaffold a new internal/ or pkg/ package (with unit tests) in a starterpack-go-cli project. Use when adding CLI-specific support code (a new internal/ helper) or a reusable library others could import (a new pkg/ package).

License 许可
MIT
最近更新
2026-10-07
Stars
★ 0
Forks
0

01 前言 Front Matter

name
add-package
description
Scaffold a new internal/ or pkg/ package (with unit tests) in a starterpack-go-cli project. Use when adding CLI-specific support code (a new internal/ helper) or a reusable library others could import (a new pkg/ package).

03 SKILL.md 正文

Add an internal/ or pkg/ package

Outcome

A new internal/<name>/ or pkg/<name>/ directory with a package file, a _test.go file covering it, and (if it's meant to be used from cmd/) at least one call site wired in.

Choosing internal/ vs pkg/

  • internal/ — code that only makes sense inside this CLI: talks to Cobra types, formats terminal output, reads global flags, etc. Go's internal/ mechanism also enforces this isn't importable from outside the module, which is a feature here, not a limitation.
  • pkg/ — code with no CLI dependency that a different program could import (business logic, data transforms, a client for some API). If you're unsure, ask: "if I deleted cmd/ entirely, would this code still make sense?" — yes → pkg/.

Contract

  • Directory: internal/<name>/<name>.go or pkg/<name>/<name>.go, package <name> (lowercase, single word, matching the directory).
  • File layout: package → imports (stdlib, then external, then this module's own packages) → constants → types → init() (rare) → constructors → methods → helpers.
  • Exported identifiers get a doc comment starting with the identifier's name (standard Go convention — go vet/golint expect this).
  • Errors: return error, wrap with fmt.Errorf("<context>: %w", err) — don't log.Fatal/os.Exit from library code; that's the caller's decision.
  • No global mutable state beyond what internal/logger and internal/color already establish as this project's pattern (a package-level logger/config instance is fine if the package needs one, following their example).

Steps

  1. Create <internal|pkg>/<name>/<name>.go with the package and its exported API.
  2. Create <internal|pkg>/<name>/<name>_test.go in the same package (white-box access) using table-driven tests and testify/assert for assertions, matching the style in internal/logger/logger_test.go or pkg/example/example_test.go.
    • Cover success and error paths.
    • Mock/avoid real filesystem or network access — inject dependencies or use bytes.Buffer/temp dirs with t.Cleanup(), as internal/logger's tests do for captured output.
    • Aim for >80% coverage of the new package (task coverage).
  3. If this package is meant to be used by a command, wire the call site into the relevant cmd/<name>.go (see the add-command skill if the command doesn't exist yet) and add/extend an integration test in tests/integration_test.go that exercises it end-to-end through the CLI.
  4. gofmt -l <internal|pkg>/<name>/ and task test before calling it done.

04 同仓库更多 Skills

mtfuller
mtfuller/agentworks

agentworks-evals

How to write and run behavior-eval cases for a skill or agent in this AgentWorks project: the evals/*.yaml format, text, tool-call, and activation assertions, trigger cases, rubrics and a judge, runner protocols (text and json), repeated runs, and agentworks eval. Use when asked to test, evaluate, or regression-check how a skill or agent responds, or whether its description makes a model choose it.

★ 0
mtfuller
mtfuller/agentworks

agentworks-cli

How to scaffold, validate, build, test, run, export, import, and publish this project's agents, skills, MCP servers, and hooks with the agentworks CLI. Use whenever asked to add, change, check, ship, or import an artifact in this project.

★ 0
mtfuller
mtfuller/agentworks

agentworks-author-skill

How to write or edit a skill in this AgentWorks project: skill.md frontmatter, the description that decides when it triggers, entrypoint/scripts/tests layout, and build/test commands. Use when creating or changing anything under skills/.

★ 0
mtfuller
mtfuller/agentworks

agentworks-author-mcp

How to write or edit an MCP server in this AgentWorks project: mcp.md frontmatter, local (stdio) versus remote (http/sse) servers, command, args, env and auth, source and tests layout, and the build, test, doctor, and run loop. Use when creating or changing anything under mcp/.

★ 0
mtfuller
mtfuller/agentworks

agentworks-author-hook

How to write or edit a lifecycle hook in this AgentWorks project: hook.md frontmatter, choosing vendor-specific event names, matchers and timeouts, the command it runs, and safety review. Use when creating or changing anything under hooks/.

★ 0
mtfuller
mtfuller/agentworks

agentworks-author-agent

How to write or edit an agent (subagent) in this AgentWorks project: agent.md frontmatter, portable tools and model settings, writing the instructions, and resources. Use when creating or changing anything under agents/.

★ 0