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'sinternal/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 deletedcmd/entirely, would this code still make sense?" — yes →pkg/.
Contract
- Directory:
internal/<name>/<name>.goorpkg/<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/golintexpect this). - Errors: return
error, wrap withfmt.Errorf("<context>: %w", err)— don'tlog.Fatal/os.Exitfrom library code; that's the caller's decision. - No global mutable state beyond what
internal/loggerandinternal/coloralready establish as this project's pattern (a package-level logger/config instance is fine if the package needs one, following their example).
Steps
- Create
<internal|pkg>/<name>/<name>.gowith the package and its exported API. - Create
<internal|pkg>/<name>/<name>_test.goin the same package (white-box access) using table-driven tests andtestify/assertfor assertions, matching the style ininternal/logger/logger_test.goorpkg/example/example_test.go.- Cover success and error paths.
- Mock/avoid real filesystem or network access — inject dependencies or use
bytes.Buffer/temp dirs witht.Cleanup(), asinternal/logger's tests do for captured output. - Aim for >80% coverage of the new package (
task coverage).
- If this package is meant to be used by a command, wire the call site into the
relevant
cmd/<name>.go(see theadd-commandskill if the command doesn't exist yet) and add/extend an integration test intests/integration_test.gothat exercises it end-to-end through the CLI. gofmt -l <internal|pkg>/<name>/andtask testbefore calling it done.
04 同仓库更多 Skills
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.
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.
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/.
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/.
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/.
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/.