agentcli-go

agentcli-go framework reference for building Go CLI tools. Use when working on agentcli-go itself, scaffolding new CLI projects, adding commands, integrating the library, or debugging framework behavior. Triggers on: agentcli-go, scaffold new CLI, add command, cobrax, configx, AppContext, RunLifecycle, agentcli.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "agentcli-go" with this command: npx skills add gh-xj/agentcli-go

agentcli-go

Shared Go CLI helpers and framework modules.

Module: github.com/gh-xj/agentcli-go Repo: github.com/gh-xj/agentcli-go | Versioning: v0.x.y (pre-1.0)


API Surface

FileExported Symbols
log.goInitLogger() — zerolog setup, respects -v/--verbose
args.goParseArgs(args), RequireArg(args, name), GetArg(args, name), HasFlag(args, name)
exec.goRunCommand(name, args...), RunOsascript(script), Which(bin), CheckDependency(bin)
fs.goFileExists(path), EnsureDir(path), GetBaseName(path)
core_context.goAppContext{Meta, Values}, NewAppContext(ctx)
lifecycle.goHook interface (Preflight, Postflight), RunLifecycle(app, hook, run)
errors.goCLIError, ResolveExitCode(err), ExitSuccess, ExitUsage
scaffold.goScaffoldNew(baseDir, name, module), ScaffoldAddCommand(rootDir, name, desc, preset), Doctor(rootDir) DoctorReport
cobrax/cobrax.goExecute(RootSpec, args) int, NewRoot(RootSpec) *cobra.Command, CommandSpec, RootSpec
configx/configx.goLoad(Options) map[string]any, Decode[T](raw), NormalizeEnv(prefix, environ)

Scaffold Workflows

New project

agentcli new --name my-tool --module github.com/me/my-tool
# or programmatically:
agentcli.ScaffoldNew(".", "my-tool", "github.com/me/my-tool")

Generates: main.go, cmd/root.go, internal/app/, internal/config/, internal/io/, internal/tools/smokecheck/, pkg/version/, test/, Taskfile.yml, README.md

Add command

agentcli add command --name sync --preset file-sync
agentcli add command --name deploy --desc "run deploy checks"

Presets: file-sync, http-client, deploy-helper

Doctor check

agentcli doctor [--dir ./my-tool]
# returns DoctorReport JSON with findings

Golden Project Layout

my-tool/
├── main.go                          # os.Exit(cmd.Execute(os.Args[1:]))
├── cmd/
│   ├── root.go                      # cobrax.Execute(RootSpec{...})
│   └── <command>.go                 # func <Name>Command() command
├── internal/
│   ├── app/{bootstrap,lifecycle,errors}.go
│   ├── config/{schema,load}.go
│   ├── io/output.go
│   └── tools/smokecheck/main.go
├── pkg/version/version.go
├── test/
│   ├── e2e/cli_test.go
│   └── smoke/version.schema.json
└── Taskfile.yml

cobrax Pattern

// cmd/root.go
return cobrax.Execute(cobrax.RootSpec{
    Use:   "my-tool",
    Short: "my-tool CLI",
    Meta:  agentcli.AppMeta{Name: "my-tool", Version: version.Version},
    Commands: []cobrax.CommandSpec{
        {Use: "sync", Short: "sync files", Run: SyncCommand().Run},
    },
}, args)

Persistent flags auto-wired: --verbose/-v, --config, --json, --no-color Values accessible via app.Values["json"], app.Values["config"], etc.


configx Pattern

raw, err := configx.Load(configx.Options{
    Defaults: map[string]any{"env": "default"},
    FilePath: configPath,   // optional JSON file
    Env:      configx.NormalizeEnv("MYTOOL_", os.Environ()),
    Flags:    map[string]string{"env": flagVal},
})
cfg, err := configx.Decode[config.Config](raw)
// Precedence: Defaults < File < Env < Flags

Taskfile Tasks

TaskPurpose
task ciCanonical CI: preflight + lint + test + build + smoke + schema checks
task verifyLocal aggregate (wraps ci)
task lintgo vet + golangci-lint
task smokeDeterministic smoke tests (subset of unit tests)
task schema:checkValidate JSON contracts against schemas
task docs:checkEnsure skill docs match CLI help signatures
task fmtFormat all Go files

Rules

  • Flat package — everything in package agentcli, no sub-packages (except cobrax, configx)
  • Exported only — all functions PascalCase; this is a library
  • No business logic — generic utilities only; must be reused across 2+ projects to qualify
  • log.Fatal allowed in RequireArg, CheckDependency (CLI-oriented helpers)
  • Minimal deps — zerolog, lo, cobra only; justify new additions

Out of Scope

  • Project-specific logic (put that in consuming projects)
  • Adding functions used by only one project

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

TickTick CLI (ttg)

Manage TickTick tasks and projects via the `ttg` CLI (github.com/dhruvkelawala/ticktick-go). Full CRUD, checklists/subtasks with progress display, reminders,...

Registry SourceRecently Updated
1260Profile unavailable
Coding

CLI Scaffold Generator

生成专业 CLI 脚手架,支持 Commander.js, yargs, oclif 等主流 CLI 框架,一键生成完整项目结构。

Registry SourceRecently Updated
1930Profile unavailable
Coding

Skill Scaffold

AI agent skill scaffolding CLI. Create skills for OpenClaw, Moltbot, Claude, Cursor, ChatGPT, Copilot instantly. Vibe-coding ready. MCP compatible.

Registry SourceRecently Updated
3K1Profile unavailable
Coding

CLI Design Framework

Use when designing a new CLI, reviewing an existing CLI, or resolving uncertainty about a CLI's role, user type, interaction form, statefulness, risk profile...

Registry SourceRecently Updated
691Profile unavailable