Imported from shahargv/Chobo (
ChoboCli/AGENTS.md). Install upstream withnpx skills add shahargv/Chobo --skill ChoboCli. Copyright stays with the author.
ChoboCli Architecture
ChoboCli uses a small registration-based command architecture.
Architecture Map
ChoboCli is a thin command-line adapter over the Chobo API. It should parse user intent, call ChoboApiClient, and let the server own business rules, validation, auditing, and persistence.
Program.csis the composition root. It createsCommandRegistry, registers command subjects, wiresChoboApiClientFactory,ProfileStore, andJsonOutputWriter, then runsCliApplication.Cli/is the tiny command framework: parsing, option bags, command context, subject/verb registration, dispatch, and app lifecycle.Commands/contains one subject class per CLI area. Start here when adding or changing user-facing CLI behavior for server, users, clusters, targets, policies, schedules, dashboard, metrics, garbage collection, settings, queue, backups, schema, restores, logs, audit, import/export, or test hooks.Commands/CommandHelpers.csholds reusable parsing/formatting helpers used by multiple subjects. Keep single-command helpers private to their subject class.Infrastructure/ChoboApiClient.csowns HTTP calls, API version checks, JSON serialization, and typed request/response handling. All server calls should flow through it.Infrastructure/ChoboApiClientFactory.csbuilds clients from profiles and command options.Infrastructure/ProfileStore.csandCliProfile.csown local server profile persistence.Infrastructure/JsonOutputWriter.csis the output boundary. Commands should return plain objects rather than writing ad hoc JSON.COMMANDS.mdis the user-facing command inventory. Update it when adding or changing commands.
Shape
Program.csis composition only. It registers subjects and startsCliApplication.Cli/contains the command framework:CliSubjectgroups commands by subject, such aslogsorclusters.- each subject registers verbs in its constructor with
Verb("name", "description", MethodAsync). ParsedCommandandOptionBagparse command-line arguments.CommandRegistryresolves<subject> <verb>.
Commands/contains one class per subject:LogCommandsAuditCommandsClusterCommands- etc.
Infrastructure/contains cross-cutting adapters:- profile storage
- API client and API-version check
- JSON output
Rules
- Do not add subject/verb logic to
Program.cs. - Do not create a giant command class. Add one subject class per CLI subject.
- Keep one method per verb. If a verb needs helpers, keep them private in the subject class or move reusable behavior to
CommandHelpers. - All server calls must go through
ChoboApiClientso API version checks and JSON handling stay consistent. - Subject commands should return plain objects.
JsonOutputWriterowns rendering. - Keep CLI commands fast: avoid extra API calls beyond the shared server-version check and the command’s actual operation.
- CLI request/response behavior should mirror
Chobo.Contractsand server routes. If a contract shape changes, updateChoboApiClient, affected command subjects, andCOMMANDS.mdtogether. - Install, profile selection, server URL resolution, and shared API-version checking live in
CliApplication,ProfileStore,ChoboApiClientFactory, andChoboApiClient; check those before adding per-command setup logic.
Adding A Command
- Add or open a subject class in
Commands/. - Register the verb in the constructor.
- Implement a private
VerbNameAsync(CommandContext context)method. - Register a new subject in
Program.csonly if the subject itself is new. - Update
COMMANDS.mdwith a sample.