refactor(cli): split cmd/pad/main.go by resource (TASK-2015)#866
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mechanically splits the 9,841-line
cmd/pad/main.gogod file into cohesive per-resource files, all inpackage mainundercmd/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.gonow holds onlymain(),newRootCmd(), and shared config/client wiring (9,841 → 265 lines). Group wiring stays in the existinggroups.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:
grepoffunc/type/var/constsignature lists before vs after is identical.--helpcommand/flag tree is byte-identical tomain(diffed a binary built at the base commit against the split build).cmdhelpand 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>.gofile andgroups.go.Gates
~/go/bin/golangci-lint run --timeout=5m ./...— 0 issuesgo test ./...— greengo build ./cmd/pad— okhttps://claude.ai/code/session_019knGmnHcx5rrgWXQ8V8DZS