Deploy Locally
Your CLI Assistant
From Project to Product
You've built API calls, tool use, email triage, research, and memory. Now you package everything into a CLI assistant you'll actually run every day. This is where engineering meets UX.
Code Organization
A well-structured assistant separates concerns:
| File | Responsibility |
|---|---|
| `src/assistant.ts` | Main loop, message handling, streaming |
| `src/tools.ts` | Tool definitions and execution handlers |
| `src/memory.ts` | Conversation history, summarization, persistence |
| `src/config.ts` | User preferences, contacts, settings |
| `src/cli.ts` | Input parsing, command routing, output formatting |
Each file has a single job. When you need to fix email triage, you know to look in tools.ts. When streaming breaks, it's in assistant.ts.
Slash Commands
A CLI assistant needs more than freeform chat. Slash commands give users quick access to common actions:
| Command | Action |
|---|---|
| `/email` | Show unread email summary with triage |
| `/calendar` | Show today's schedule |
| `/tasks` | List active tasks by priority |
| `/research [topic]` | Search bookmarks and generate a brief |
| `/prefs` | Show or update user preferences |
| `/help` | List available commands |
Commands should be fast — they call specific tools directly instead of going through the full AI reasoning loop.
Startup Briefing
The first thing your assistant does on launch matters. A startup briefing answers: "What do I need to know right now?"
The pattern:
> Good morning, Alex. You have 4 unread emails (1 critical: production alert). Your day starts with a 10am meeting with Sarah Chen. You have 2 overdue tasks on the infrastructure project. Type /email to triage or just ask me anything.
This makes the assistant immediately useful — no "how can I help you?" required.
Error Handling
Production-quality error handling covers five scenarios:
| Error | How to Handle |
|---|---|
| API key missing/invalid | Clear message: "Set ANTHROPIC_API_KEY in your environment" |
| Rate limited (429) | Wait and retry with backoff, show "Thinking..." |
| Network timeout | Retry once, then suggest checking connection |
| Data file missing | Skip that tool gracefully, tell the user |
| Malformed tool response | Log the error, ask Claude to try again |
Never crash on a recoverable error. Never show a raw stack trace to the user.
Output Formatting
Terminal output should be easy to scan:
Testing Your Assistant
Before you call it "done," test these scenarios:
What You've Built
By the end of this course, you have a fully functional AI assistant that:
This is the same architecture that powers production AI assistants — the difference is scale, not pattern.
Key Takeaways
This is chapter 6 of Build Your AI Assistant with Claude.
Get the full hands-on course — free during early access. Build the complete system. Your projects become your portfolio.
View course details