|
1 | 1 | # Coding Agent for Slack (Bolt for Python and Claude Agent SDK) |
2 | 2 |
|
3 | | -A sample Slack agent that showcases [Slack Code](https://docs.slack.dev/ai/slack-code/) built with [Bolt for Python](https://docs.slack.dev/tools/bolt-python/) and the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) using models from [Anthropic](https://www.anthropic.com). Mention it in a channel with a task and a project repo, and it decides whether to answer in place or create a dedicated **code channel** for the work. In a code channel a temporary workspace is created to clone the repo and make changes with necessary approval while keeping the channel's plan, context bar, and code tab current as it goes. |
| 3 | +A sample Slack agent that showcases [Slack Code](https://docs.slack.dev/ai/slack-code/) built with [Bolt for Python](https://docs.slack.dev/tools/bolt-python/) and the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) using models from [Anthropic](https://www.anthropic.com). Mention it in a channel with a task and a project repo, and it decides whether to answer in place or create a dedicated **code channel** for the work. In a code channel it clones the repo into a temporary workspace and makes changes with the necessary approvals, keeping the channel's plan, context bar, and code tab current as it goes. |
4 | 4 |
|
5 | 5 | > [!WARNING] |
6 | 6 | > **This agent runs commands generated by a language model on the machine running the app.** Only run it against trusted repositories on a machine you're comfortable letting it operate. Refer to [Command approvals](#command-approvals) for how command approvals work. |
@@ -56,7 +56,7 @@ Every tool call the coding agent makes goes through a Claude Agent SDK `PreToolU |
56 | 56 |
|
57 | 57 | - **Read-only** commands and **local git changes** run with no prompt. A path outside the clone always asks. Commands run without a shell, so they can't chain a second command, and what the approval check reads is exactly what runs. |
58 | 58 | - **File edits** don't go through approvals. `write_file` and `edit_file` only write inside the clone. |
59 | | -- **Anything else** shows **Approve** and **Deny** buttons in the code channel, and the command runs only if you approve it. |
| 59 | +- **Anything else** shows **Approve** and **Deny** buttons in the code channel, and the command runs only if someone in the channel approves it. |
60 | 60 |
|
61 | 61 | The agent gets only these tools. Claude Code's built-in tools, like its own `Bash` and `Edit`, are turned off, and so are the settings, `CLAUDE.md` files, and MCP servers configured on the machine running the app. |
62 | 62 |
|
@@ -323,14 +323,14 @@ Every incoming request is routed to a "listener". This directory groups each lis |
323 | 323 |
|
324 | 324 | ### `/agent` |
325 | 325 |
|
326 | | -- `agent.py` - defines the routing agent and the coding agent with their tools, and starts and resumes their runs. Along with `guardrails.py` and `tools`, it's the only code that uses the Claude Agent SDK. |
327 | | -- `prompts.py` - holds both agents' prompts. |
328 | | -- `turns.py` - runs each turn for the listeners: it answers requests, sets the session status, runs the agent, and posts the outcome or the Approve / Deny buttons. It also queues messages that arrive mid-turn and handles approvals and the stop button. |
329 | | -- `outcome.py` - defines the `RunOutcome` that `agent.py` returns and `turns.py` reads. |
330 | | -- `context.py` - reads the thread or direct message a request came from, so the agent can follow the conversation. |
331 | | -- `guardrails.py` - holds the SDK hooks around tool calls: the approval check for `run_command`, which defers a command that needs approval, and the check that skips every tool call once the session is stopped. |
332 | | -- `sessions.py` - keeps each code channel's session in memory: its working directory, plan canvas, conversation history, and messages waiting for the next turn. It also defines the `AgentDeps` and `RequestDeps` dataclasses passed to the agents at runtime, providing access to the Slack client and the session or request. |
333 | | -- `approvals.py` - decides which commands need approval and holds runs paused on one. |
334 | | -- `runtime.py` - holds what the tools and hooks share during a run: its deps, which the SDK can't pass to a tool, and the shape of a tool's reply. |
335 | | -- `workspace.py` - runs commands in the clone without the app's secrets, and keeps file tools inside it. |
336 | | -- `tools` - contains one file per tool the agents can call. |
| 326 | +- `agent.py` — Defines the routing agent and the coding agent with their tools, and starts and resumes their runs. Along with `guardrails.py` and `tools`, it's the only code that uses the Claude Agent SDK. |
| 327 | +- `prompts.py` — Holds both agents' prompts. |
| 328 | +- `turns.py` — Runs each turn for the listeners: it answers requests, sets the session status, runs the agent, and posts the outcome or the Approve / Deny buttons. It also queues messages that arrive mid-turn and handles approvals and the stop button. |
| 329 | +- `outcome.py` — Defines the `RunOutcome` that `agent.py` returns and `turns.py` reads. |
| 330 | +- `context.py` — Reads the thread or direct message a request came from, so the agent can follow the conversation. |
| 331 | +- `guardrails.py` — Holds the SDK hooks around tool calls: the approval check for `run_command`, which defers a command that needs approval, and the check that skips every tool call once the session is stopped. |
| 332 | +- `sessions.py` — Keeps each code channel's session in memory: its working directory, plan canvas, conversation history, and messages waiting for the next turn. It also defines the `AgentDeps` and `RequestDeps` dataclasses passed to the agents at runtime, providing access to the Slack client and the session or request. |
| 333 | +- `approvals.py` — Decides which commands need approval and holds runs paused on one. |
| 334 | +- `runtime.py` — Holds what the tools and hooks share during a run: its deps, which the SDK can't pass to a tool, and the shape of a tool's reply. |
| 335 | +- `workspace.py` — Runs commands in the clone without the app's secrets, and keeps file tools inside it. |
| 336 | +- `tools` — Contains one file per tool the agents can call. |
0 commit comments