2626
2727## Workflow
28281 . ** Kickoff / readiness checks:**
29- - Verify ` codegen ` CLI is installed (or provide installation: ` uv tool install codegen ` )
30- - Ensure authentication via ` codegen login --token $CODEGEN_API_TOKEN `
29+ - Verify ` codegen ` CLI is installed: ` which codegen ` (or provide installation: ` uv tool install codegen ` )
30+ - Check CLI version and handle first-run telemetry: ` codegen --version `
31+ - Verify authentication by listing organizations: ` codegen org --list `
32+ - If authentication fails, login: ` codegen login --token $CODEGEN_API_TOKEN `
33+ - Handle organization selection: ` codegen org --set-default <org-id> `
34+ - Set ` CODEGEN_ORG_ID ` environment variable if available to avoid interactive prompts
3135 - Confirm task specification exists with ID, description, and acceptance criteria
3236
33372 . ** Context gathering:**
98102
99103## Failure & Escalation
100104- ** CLI not installed:** Provide installation: ` uv tool install codegen `
101- - ** Not authenticated:** Run ` codegen login --token $CODEGEN_API_TOKEN ` (assumes token in environment)
105+ - ** Not authenticated:**
106+ - Run ` codegen login --token $CODEGEN_API_TOKEN ` (assumes token in environment)
107+ - Verify with ` codegen org --list `
108+ - If multiple orgs, set default: ` codegen org --set-default <org-id> `
109+ - See Troubleshooting section in CLI Reference for detailed steps
110+ - ** Organization selection issues:**
111+ - List available orgs: ` codegen org --list `
112+ - Set default org to avoid interactive prompts: ` codegen org --set-default <org-id> `
113+ - Or use ` --org-id ` flag in commands
114+ - Or set ` CODEGEN_ORG_ID ` environment variable
115+ - ** Interactive prompt failures (non-TTY):**
116+ - Pre-set ` CODEGEN_API_TOKEN ` and ` CODEGEN_ORG_ID ` environment variables
117+ - Use ` --json ` flag for structured output
118+ - Telemetry prompt will default to "no" if stdin unavailable
102119- ** Incomplete task context:** List missing pieces (research, specs, file hints) and request from #TaskPlanner or #ResearchAgent.
103120- ** Rate limiting (>10 req/min):** Wait and retry after 60 seconds; notify requester of delay.
104- - ** CLI errors:** Display error output, suggest checking authentication or CLI version (` codegen update ` )
121+ - ** CLI errors:** Display error output, suggest checking authentication ( ` codegen org --list ` ) or CLI version (` codegen update ` )
105122- ** Unclear acceptance criteria:** Request clarification before creating agent run; prompt quality depends on clear requirements.
106123
107124## Expected Output
@@ -139,12 +156,49 @@ codegen login --token $CODEGEN_API_TOKEN
139156
140157# Or interactive login
141158codegen login
159+
160+ # List available organizations
161+ codegen org --list
162+
163+ # Set default organization (example: lambda-curry is org 88)
164+ codegen org --set-default 88
165+
166+ # Verify authentication
167+ codegen org --list # Should succeed if authenticated
168+ ```
169+
170+ ** Environment Variables:**
171+ ``` bash
172+ # Required for authentication
173+ export CODEGEN_API_TOKEN=sk-...
174+
175+ # Optional: Set default org to avoid interactive prompts
176+ export CODEGEN_ORG_ID=88
142177```
143178
144179** Documentation:** https://docs.codegen.com/introduction/cli
145180
146181### Creating an Agent Run
147182
183+ ** Using the ` agent ` command (recommended):**
184+ ``` bash
185+ # Create agent run with prompt
186+ codegen agent --prompt " # Task: Implement authentication middleware
187+ ## Context
188+ ...
189+ ## Implementation Plan
190+ ..."
191+
192+ # For programmatic usage, add --json flag
193+ codegen agent --prompt " ..." --json
194+
195+ # Specify organization (if multiple orgs)
196+ codegen agent --prompt " ..." --org-id 88
197+
198+ # Specify repository context
199+ codegen agent --prompt " ..." --repo-id 123
200+ ```
201+
148202** From file:**
149203``` bash
150204# Save prompt to file
@@ -153,27 +207,33 @@ cat > /tmp/prompt.md << 'EOF'
153207...
154208EOF
155209
156- # Create agent run
157- codegen create /tmp/prompt.md
210+ # Create agent run from file
211+ codegen agent --prompt " $( cat /tmp/prompt.md) "
158212```
159213
160- ** From stdin:**
161- ``` bash
162- echo " # Task: Implement authentication middleware
163- ## Context
164- ...
165- ## Implementation Plan
166- ..." | codegen create -
214+ ** Output (formatted):**
167215```
168-
169- ** Output:**
216+ ╭─────────────────────────── 🤖 Agent Run Created ───────────────────────────╮
217+ │ │
218+ │ Agent Run ID: 105016 │
219+ │ Status: ACTIVE │
220+ │ Created: October 01, 2025 at 03:43 │
221+ │ Web URL: https://codegen.com/agent/trace/105016 │
222+ │ │
223+ ╰──────────────────────────────────────────────────────────────────────────────╯
224+
225+ 💡 Track progress with: codegen agents
226+ 🌐 View in browser: https://codegen.com/agent/trace/105016
170227```
171- ✓ Agent run created!
172- ID: 789
173- URL: https://app.codegen.com/runs/789
174-
175- Monitor with: codegen
176- Or visit: https://app.codegen.com/runs/789
228+
229+ ** Output (JSON):**
230+ ``` json
231+ {
232+ "agent_run_id" : 105016 ,
233+ "status" : " ACTIVE" ,
234+ "web_url" : " https://codegen.com/agent/trace/105016" ,
235+ "created_at" : " 2025-10-01T03:43:00Z"
236+ }
177237```
178238
179239
@@ -189,6 +249,59 @@ codegen update # Keep CLI up to date
189249
190250** Rate Limits:** 10 requests per minute
191251
252+ ### Troubleshooting
253+
254+ ** "Not authenticated" error:**
255+ ``` bash
256+ # Login with token
257+ codegen login --token $CODEGEN_API_TOKEN
258+
259+ # Verify authentication
260+ codegen org --list
261+
262+ # If multiple orgs, set default
263+ codegen org --set-default < org-id>
264+ ```
265+
266+ ** Multiple organizations (avoiding interactive prompts):**
267+ ``` bash
268+ # List all available organizations
269+ codegen org --list
270+
271+ # Set default organization (example: lambda-curry is org 88)
272+ codegen org --set-default 88
273+
274+ # Or use environment variable
275+ export CODEGEN_ORG_ID=88
276+
277+ # Or specify in command
278+ codegen agent --prompt " ..." --org-id 88
279+ ```
280+
281+ ** TTY/Interactive prompt issues:**
282+ - The CLI may show telemetry or organization selection prompts on first run
283+ - In non-TTY environments (automation, CI/CD), pre-set environment variables:
284+ - ` CODEGEN_API_TOKEN ` - Authentication token
285+ - ` CODEGEN_ORG_ID ` - Default organization ID
286+ - Use ` --json ` flag for structured output in scripts
287+ - For telemetry prompt, the CLI will default to "no" if stdin is not available
288+
289+ ** Checking CLI version:**
290+ ``` bash
291+ # First run may show telemetry prompt - just press Enter or 'n'
292+ codegen --version
293+
294+ # Update to latest version
295+ codegen update
296+ ```
297+
298+ ** Agent run fails to create:**
299+ 1 . Verify authentication: ` codegen org --list `
300+ 2 . Check organization is set: ` codegen org --list ` should show your orgs
301+ 3 . Verify token is valid: ` echo $CODEGEN_API_TOKEN `
302+ 4 . Check rate limits: Wait 60s if hitting 10 req/min limit
303+ 5 . Try with ` --json ` flag for detailed error messages
304+
192305### Prompt Template
193306
194307```
@@ -267,4 +380,3 @@ Next steps:
267380 - Or visit: https://app.codegen.com/runs/789
268381 - Pull results: codegen pull (when complete)
269382```
270-
0 commit comments