Using the CLI
The bgagent CLI is the recommended way to interact with the platform. It authenticates via Cognito, manages token caching, and provides formatted output.
This repository builds the CLI under cli/; after compile, run the entrypoint as node lib/bin/bgagent.js from the cli directory (the path package.json exposes as bin). If you install a published package or link bgagent onto your PATH, you can call bgagent directly — the subcommands are the same.
cd clinpx projen build
# Configure with your stack outputs (run from cli/)node lib/bin/bgagent.js configure \ --api-url $API_URL \ --region us-east-1 \ --user-pool-id $USER_POOL_ID \ --client-id $APP_CLIENT_ID
# Log innode lib/bin/bgagent.js login --username user@example.comSubmitting a task
Section titled “Submitting a task”# From cli/ — from a GitHub issuenode lib/bin/bgagent.js submit --repo owner/repo --issue 42
# From a text descriptionnode lib/bin/bgagent.js submit --repo owner/repo --task "Add input validation to the /users POST endpoint"
# Submit and wait for completionnode lib/bin/bgagent.js submit --repo owner/repo --issue 42 --waitExample (default text output immediately after a successful submit — task is SUBMITTED, branch name reserved):
node lib/bin/bgagent.js submit --repo krokoko/agent-plugins --task "add codeowners field to RFC issue template"Task: 01KN37PZ77P1W19D71DTZ15X6XStatus: SUBMITTEDRepo: krokoko/agent-pluginsDescription: add codeowners field to RFC issue templateBranch: bgagent/01KN37PZ77P1W19D71DTZ15X6X/add-codeowners-field-to-rfc-issue-templateCreated: 2026-04-01T00:39:51.271ZOptions:
| Flag | Description |
|---|---|
--repo | GitHub repository (owner/repo). Required. |
--issue | GitHub issue number. |
--task | Task description text. |
--max-turns | Maximum agent turns (1–500). Overrides per-repo Blueprint default. Platform default: 100. |
--max-budget | Maximum cost budget in USD (0.01–100). Overrides per-repo Blueprint default. No default limit. |
--idempotency-key | Idempotency key for deduplication. |
--wait | Poll until the task reaches a terminal status. |
--output | Output format: text (default) or json. |
At least one of --issue or --task is required.
Checking task status
Section titled “Checking task status”Run these from the cli/ directory (same as in Setup).
Single task
Section titled “Single task”node lib/bin/bgagent.js status <TASK_ID>
# Poll until completionnode lib/bin/bgagent.js status <TASK_ID> --waitExample (default text output once the task has finished — COMPLETED, with session id, PR link, duration, and cost):
node lib/bin/bgagent.js status 01KN37PZ77P1W19D71DTZ15X6XTask: 01KN37PZ77P1W19D71DTZ15X6XStatus: COMPLETEDRepo: krokoko/agent-pluginsDescription: add codeowners field to RFC issue templateBranch: bgagent/01KN37PZ77P1W19D71DTZ15X6X/add-codeowners-field-to-rfc-issue-templateSession: 9891af91-bfc6-488f-bfe6-ce8f8c9a63cfPR: https://github.com/krokoko/agent-plugins/pull/60Created: 2026-04-01T00:39:51.271ZStarted: 2026-04-01T00:39:56.647ZCompleted: 2026-04-01T00:43:49ZDuration: 148.6sCost: $0.1751All tasks
Section titled “All tasks”node lib/bin/bgagent.js listnode lib/bin/bgagent.js list --status RUNNING,SUBMITTEDnode lib/bin/bgagent.js list --repo owner/repo --limit 10Viewing task events
Section titled “Viewing task events”node lib/bin/bgagent.js events <TASK_ID>node lib/bin/bgagent.js events <TASK_ID> --limit 20Cancelling a task
Section titled “Cancelling a task”node lib/bin/bgagent.js cancel <TASK_ID>