Start with the ownership question

If users should remain inside the standard Autohand Code CLI, a CLI extension is usually the smallest coherent package. If you are building a product or service that owns agent lifecycle, UI, storage, or event handling, use the Code Agent SDK.

Do not choose based only on language preference. CLI Extension API v1 has a safe declarative layer and an explicitly trusted compiled runtime layer. The Agent SDK remains the right code-first surface when your application—not the CLI—must own execution, lifecycle, storage, and UI.

Compare the extension surfaces

SurfaceChoose it whenWhat it contributesPrimary owner
Declarative CLI extensionYou need a versioned capability without package-code executionShell-backed tools, focused agents, and Agent SkillsAutohand's existing registries and permission path
Trusted CLI runtime extensionYou need commands, terminal UI, shortcuts, flags, hooks, providers, or permission policy inside AutohandCompiled JavaScript registered through Extension API v1Autohand process after explicit --trust
Code Agent SDKYou are embedding or orchestrating an agent in an applicationProgrammatic agent sessions, events, approvals, and app toolsYour process
Meta-toolYou need one local shell-backed tool and do not need package lifecycleA persisted tool definitionUser or project tool registry
External agentYou need one or more local agent definitions from a configured directoryJSON or Markdown agentsAgent registry configuration
SkillYou need reusable instructions, references, and workflow guidance for the modelPrompt-time knowledge and proceduresSkills system
MCP serverTools must call a long-running service, API, database, or non-shell protocolRemote or local service-backed toolsExternal MCP process
HookBehavior must react to session, tool, file, or command lifecycle eventsEvent-triggered commandsHook configuration

Use a CLI extension to package existing features

Declarative extensions package durable meta-tool, agent, and Agent Skill contracts. This is useful when one capability consists of evidence collectors plus the specialist or workflow that knows how to use them. For example, a test-triage package can declare run_focused_test and a failure-triage agent, while a workspace-brief package can declare evidence tools and a reusable $workspace-brief skill.

  • One manifest supplies identity, version, description, and declared files.
  • One lifecycle covers validate, install, inspect, enable, disable, diagnose, and remove.
  • One provenance record shows which package owns each contribution.
  • One security path keeps handler safety, shell escaping, permission decisions, hooks, and events consistent.

Add a trusted runtime only when the observable result requires a native CLI surface. Runtime code is not sandboxed, so review emitted JavaScript and bundled dependencies, validate without execution, and install with --trust.

Use the Agent SDK for code and product behavior

Choose the SDK when the agent is one component in a larger system and your process must own its control plane. Typical signals include an application database, custom authentication, domain APIs, a non-terminal real-time UI, queued jobs, multi-tenant policy, isolated deployment, or the need to interpret streamed events in host code.

A good boundary is to keep local, repository-specific affordances in CLI extensions and place application-owned control flow in the SDK host. The two can share naming and operational concepts without trying to ship the same artifact.

Decision examples

RequirementRecommended surfaceReason
Every repository should expose the same release-range command and release plannerCLI extensionA portable tool-and-agent package fits the standard CLI
Developers should run /deploy and operate an Ink deployment menuTrusted CLI runtime extensionThe capability belongs inside the standard terminal experience
Port an existing Pi package with a SKILL.md and TypeScript UIDeclarative skill plus reviewed runtime adaptationThe skill is directly portable; runtime registrations must be mapped and compiled
A support dashboard should launch an agent and stream progress to a browserAgent SDKThe dashboard owns session lifecycle and UI events
A single developer wants a local formatter helperMeta-toolPackage metadata and distribution may be unnecessary
An agent needs read access to a hosted issue trackerMCP server or SDK toolA service boundary is safer than a shell template
Run lint after every file changeHookThe trigger is a lifecycle event, not a tool request
Teach the model a repeatable review rubricSkill, or an agent prompt inside an extensionChoose based on whether it is general guidance or a callable specialist

Prefer the smallest surface that preserves the contract. Start with one meta-tool or agent while exploring. Promote it into an extension when it needs versioning, distribution, ownership, coordinated install/removal, or multiple contributions.

For a migration workflow, continue to Adapt a Pi package.