As TokenCap expanded from a simple repository snapshot generator to a full intelligence engine with graphs, memory loops, and security scanners, our CLI sprawled out of control. We had 21 distinct commands in a single 2,455-line bin/tokencap.js file.
To fix this, we completed a major CLI refactoring around 7 core verbs.
The 7 Core Verbs Hierarchy
-
make(src/cli/make.js): Snapshot generation, watch mode, custom budgeting profiles. -
ask(src/cli/ask.js): Spatial queries (ask impact,ask dead-code,ask adr). -
analyze(src/cli/analyze.js): Repo audits (analyze health,analyze debt,analyze security). -
serve(src/cli/serve.js): Background daemons (serve --daemon,serve --mcp). -
update(src/cli/update.js): In-place upgrades. -
help&version: System introspection.
The Silent Alias Strategy
To guarantee that existing scripts and CI workflows did not break:
// bin/tokencap.js excerpt
const ALIASES = {
graph: ["ask", "impact"],
capsule: ["make"],
security: ["analyze", "security"],
health: ["analyze", "health"],
mcp: ["serve", "--mcp"]
};
const normalizedArgs = resolveAliases(process.argv.slice(2));
The dispatcher shrank from 2,455 lines down to 234 lines of clean routing logic, with handlers decoupled into modular, testable files in src/cli/.
Inspect the CLI architecture at tokencap.vansharora.app
Top comments (0)