One Declaration Generates a CLI, Agent Skills, and Docs from Company APIs
Teams wiring internal APIs into AI coding agents hit the same wall: authentication, inconsistent output, and brittle error handling. This SDK standardizes those three layers so an Agent gets a predictable contract—fixed JSON shapes, typed exit codes, and token lifecycle management it never touches—without requiring a persistent MCP server.
`@renxqoo/agent-cli-sdk` generates a CLI command, a SKILL.md file for AI Agents, and syncs to Agent directories from one `defineCommand` call. Authentication is handled via OAuth 2.1 plugins that keep tokens on disk and away from the Agent, refreshing them silently and surfacing deterministic exit codes when re-login is needed. The SDK enforces a fixed JSON output contract for both success and failure, paired with nine typed error classes and a detailed exit-code table so Agents can branch reliably without parsing unpredictable text. A built-in Skill Factory lets an Agent itself generate the CLI wrapper from an API description, collapsing the write-command, write-docs, and Agent-adaptation steps into a single workflow. The project argues CLI is a better fit than MCP for Agent tooling because it avoids persistent server processes, constant context injection, and protocol overhead, while fitting naturally into Unix pipelines and subprocess calls from any language.
Choosing CLI over MCP is a bet on statelessness: no long-lived server process, no context pollution from unused tools, and direct compatibility with Unix pipes and subprocess calls from any language.
The exit-code table (0–10) and typed error classes turn Agent error recovery from a brittle string-parsing problem into a structured branching problem, which is far more reliable in automated loops.
Cloud-hosted Agents break the OAuth device flow because there is no terminal for human interaction; the suggested workaround—an internal gateway that injects tokens—shifts the security boundary but adds infrastructure cost.
Letting an Agent generate its own CLI tools via a Skill Factory inverts the typical build-then-integrate sequence, but it also means the generated code inherits whatever assumptions the Agent makes about the API.