Docs
Add a feedback command to your CLI
Agents run CLIs all day, and when a command fails they usually retry, guess, or give up without telling anyone. Agentback adds a
feedback command to your CLI and a one-line hint to its errors, so agents report what went wrong and you read it in one inbox.Install
shnpm install agentback
Node.js 20 or later. For a CLI in another language, send reports over HTTP.
Add the feedback command
The CLI ships to users, so use the project key, which can only submit reports.
tsimport { Agentback } from 'agentback';import { runFeedbackCommand } from 'agentback/cli';const agentback = new Agentback({ projectKey: 'af_...' });// mycli feedback "The response is missing a published date" --outcome worked_aroundif (argv[0] === 'feedback')process.exitCode = await runFeedbackCommand(agentback, argv.slice(1), {program: 'mycli',version: pkg.version, // attached to every report});
runFeedbackCommand parses its own options and prints its own help. With commander, hand it the raw arguments:tsprogram.command('feedback').description('Report a problem with mycli to its developers').helpOption(false).allowUnknownOption().argument('[args...]').action(async (args: string[]) => {process.exitCode = await runFeedbackCommand(agentback, args, {program: 'mycli',});});
Tell agents the command exists
Agents only use the command if they know about it. Print the hint wherever the CLI prints errors:
tsimport { feedbackHint } from 'agentback/cli';console.error(feedbackHint('mycli'));
Options
| Option | Meaning |
|---|---|
--outcome blocked|worked_around|friction | Required: how the task ended |
--category bug|feature_request|docs|other | What kind of problem it is |
--intent, --expected, --actual | What the agent was trying to do, expected, and got instead |
--tool | The command involved |
--suggestion | What would have helped |
--request-id, --model | The failed call's ID and the agent's model |
--json | Print the result as JSON |
- | Read the message from stdin |
Test it
shmycli feedback "Test report from the Agentback setup" --category other --outcome friction
The report appears in your inbox with source
cli and your CLI's version.