Skip to content

refactor(cli): split cmd/pad/main.go by resource (TASK-2015)#866

Merged
xarmian merged 1 commit into
mainfrom
refactor/split-main-go
Jul 8, 2026
Merged

refactor(cli): split cmd/pad/main.go by resource (TASK-2015)#866
xarmian merged 1 commit into
mainfrom
refactor/split-main-go

Conversation

@xarmian

@xarmian xarmian commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

Mechanically splits the 9,841-line cmd/pad/main.go god file into cohesive per-resource files, all in package main under cmd/pad/:

cmd_item.go, cmd_collection.go, cmd_workspace.go, cmd_auth.go, cmd_project.go, cmd_playbook.go, cmd_role.go, cmd_tag.go, cmd_github.go, cmd_webhook.go, cmd_agent.go, cmd_server.go, cmd_attachment.go, cmd_db.go, cmd_library.go, cmd_bootstrap.go.

main.go now holds only main(), newRootCmd(), and shared config/client wiring (9,841 → 265 lines). Group wiring stays in the existing groups.go.

Why

TASK-2015: one file held all 91 Cobra commands and CLAUDE.md steered contributors to keep adding to it — a merge-conflict magnet for the parallel-agent workflow.

Zero behavior change

Pure move of command constructors + helpers. Verified mechanically:

  • All 169 top-level declarations preserved verbatimgrep of func/type/var/const signature lists before vs after is identical.
  • The recursive --help command/flag tree is byte-identical to main (diffed a binary built at the base commit against the split build).
  • cmdhelp and the MCP catalog read command schemas at runtime, so they are unaffected.

Segments were extracted by AST byte-range (preserving exact source text, doc comments, and formatting); per-file imports pruned with goimports.

Docs

Updates the CLAUDE.md "Add a new CLI command" recipe to point contributors at the appropriate cmd_<resource>.go file and groups.go.

Gates

  • ~/go/bin/golangci-lint run --timeout=5m ./... — 0 issues
  • go test ./... — green
  • go build ./cmd/pad — ok
  • Codex review — CLEAN

https://claude.ai/code/session_019knGmnHcx5rrgWXQ8V8DZS

Mechanically split the 9,841-line cmd/pad/main.go god file into
cohesive per-resource files (all package main): cmd_item.go,
cmd_collection.go, cmd_workspace.go, cmd_auth.go, cmd_project.go,
cmd_playbook.go, cmd_role.go, cmd_tag.go, cmd_github.go,
cmd_webhook.go, cmd_agent.go, cmd_server.go, cmd_attachment.go,
cmd_db.go, cmd_library.go, cmd_bootstrap.go. main.go now holds only
main(), newRootCmd(), and shared config/client wiring (265 lines).

Zero behavior change — a pure move of command constructors + helpers.
All 169 top-level declarations preserved verbatim; the recursive
--help command/flag tree is byte-identical to main. cmdhelp and the
MCP catalog read command schemas at runtime, so they are unaffected.

Updates the CLAUDE.md "Add a new CLI command" recipe to point
contributors at the appropriate cmd_<resource>.go file and groups.go,
so the file stops being a merge-conflict magnet for parallel agents.

Claude-Session: https://claude.ai/code/session_019knGmnHcx5rrgWXQ8V8DZS
@xarmian xarmian merged commit ac6e05d into main Jul 8, 2026
4 checks passed
@xarmian xarmian deleted the refactor/split-main-go branch July 8, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant