Writing Slack Commands That Produce Useful Agent Output
How to write Slack commands that guide AI agents to produce mergeable code.

Slack Code, announced August 20, 2026, puts AI coding agents, including Claude Code, Devin, GitHub Copilot, and Vercel's agent, directly into dedicated team channels rather than leaving them in a private terminal window. Each task gets its own channel, and that channel becomes the place where the agent posts its plan, its diffs, and whatever feedback a human gives it along the way. What used to be a one-person conversation with a coding tool is now a record the whole team can open and read. That shift changes what the first message in the channel actually is: it is no longer a private prompt someone typed to get unstuck, but the opening line of a document the team will use to understand what got built and why. The gap this exposes is that writing a prompt for a local AI tool and writing a Slack command for a shared, inspectable channel are two different skills, and most engineering organizations have only practiced the first one. Getting an agent to write code that runs is rarely where teams get stuck anymore. What slows things down is getting the rest of the team comfortable trusting that code enough to ship it, and the command is the earliest point where that trust is either built or lost.
What the Slack Command Shapes Before the Agent Writes Code
Before an agent touches a repository, the command is what shapes the plan it posts to the channel, and that plan is cheap to fix while the implementation that follows is expensive to redo. A wrong assumption caught at the planning stage costs a short correction. The same assumption caught after the agent has already opened files, written functions, and run tests costs the whole run. That asymmetry means the command is read and acted on twice, once to produce the plan and once to execute it, so any vagueness in the original message doesn't just cause one error, it compounds across both passes.
Agents running in Claude Code inside Slack work from connected repositories, whatever permissions have been granted, and, where a team has set one up, a persistent context file like CLAUDE.md that loads automatically. None of that substitutes for naming the actual target. A command that doesn't say which repo, which file, or which function it concerns forces the agent to guess its starting point from whatever scraps of context it can pull from the surrounding channel.
The routing mode matters before writing a single command: Claude Code in Slack can run in "Code only" mode, where every message addressed to it kicks off a coding session, or in "Code + Chat" mode, where it decides per message whether code or conversation is called for. That mode is set up per user, not chosen message by message, so a team working in Code-only mode will get a code output every time, even when someone meant to just ask a question or think out loud. An underspecified command doesn't get caught by the routing system. It gets pushed through it and turned into code regardless of what the person actually wanted.
The four things a Slack command must give an agent to produce mergeable output
Output that can actually be merged depends on the command supplying four things: the scope of what to touch, the context of why the change matters, the shape the output should take, and the constraints on what the agent should leave alone.
Scope means naming the repository, the file or function, and the boundary of the change, so "fix the login timeout in auth/session.py, in the refresh_token function" gives an agent something concrete to act on, where "fix the login bug" does not.
Context means telling the agent why the change is needed, what broke, or what counts as done, so a command that links the ticket and adds "this started after a scheduled job changed time zones" gives the agent a reason to weigh its options, where a command with no reasoning behind it leaves the agent inventing one.
Output shape means telling the agent what form the result should take, so "open a draft PR with the diff" produces something a reviewer can act on immediately, where a command with no shape specified might come back as a paragraph of prose explaining what could be done.
Constraints mean naming what the agent must not touch and where it needs to stop and ask, so "don't touch anything outside /src/auth, and show me the plan before you run tests" sets a boundary the agent has to respect, where a command without constraints hands the agent the run of the whole repository.
Scope underspecification and throwaway output
A command that hands the agent a scope that is technically valid but far wider than intended is the most common reason an engineering team throws away agent output, since the agent followed the instruction as given, just not what anyone meant. A command like "fix the auth bug," pointed at a connected repository, gives the agent enough to start: it will read the codebase, form a hypothesis about what's broken, and produce a change. Which bug, in which service, under which edge case, is left entirely to its own inference, and there is no reason to expect that inference to match what the person writing the command had in mind.
This is why scope errors are the hardest failure mode to catch early: the agent doesn't fail visibly. It succeeds, confidently, at the wrong task. The plan-before-implementation step built into Slack Code catches some of this, since a reviewer who reads the plan before any code gets written has a chance to redirect the agent. But that safeguard only works if the original command was specific enough to produce a plan worth reading. A vague command produces a vague plan, and a vague plan is harder to evaluate than no plan at all, because it looks like progress while giving the reviewer nothing concrete to object to.
The fix is mechanical. Naming the exact file and function, linking the Linear ticket or GitHub issue, and stating the acceptance criterion in the command itself narrows the range of things the agent has to guess. That narrower scope produces a plan specific enough that someone who didn't write the command can still approve it with confidence.
Context embedded in the command versus context the agent finds alone
An agent working inside a connected repository can read the codebase, the pull request history, and whatever issues are linked to the task. What it cannot read is the conversation that happened in a stand-up two days earlier, the constraint the team agreed to out loud and never wrote down, or the reason a previous attempt at the same fix got abandoned. That information exists only in people's memory unless someone puts it in the command.
Part of the reason this matters structurally: language model APIs are stateless. Agent frameworks create the appearance of continuity by accumulating message history, but that history only contains what was actually typed into the channel. The command is the one piece of input the agent is guaranteed to have before it starts planning, so anything left out of it has to either already be in the codebase or simply be missing.
A command that skips the "why" forces the agent to infer motivation from code signals alone, and it will often produce something technically correct that still violates a constraint nobody ever wrote down, which sends the whole task back for a round of revision that erases whatever time the agent saved. The practical fix is narrow: include the ticket or issue link, one sentence describing what the previous state was and why it's wrong, and any constraint that isn't obvious from the code itself, such as a third-party API version the team is pinned to, a performance budget, or a team convention that isn't enforced by the linter. None of this is about writing longer commands for the sake of thoroughness. It's about recognizing which facts live only in people's heads and making sure those specific facts make it into the one message the agent is guaranteed to see.
Naming the output shape so the agent returns what a reviewer can act on
Telling the agent what to do is only half the command. Telling the agent what form the answer should take decides whether what comes back is a pull request a reviewer can approve, a diff they can scan, a plan they can redirect, or a block of prose that explains a change without actually making one. Only some of those forms are something a reviewer can act on without more back-and-forth.
The approval step built into Slack Code waits for a human to sign off before anything ships, but that gate only functions if what it's reviewing is in a form a person can evaluate quickly. A command that produces a written explanation when what was needed was an actual diff sends the task back to square one, no matter how accurate the explanation was. A handful of short, specific phrases solve most of this. Asking the agent to "open a draft PR" gets back a pull request with a description attached, and telling it to "show me the diff before applying" keeps the change inspectable before anything touches the codebase, which matters especially in Code + Chat mode, where the agent is already deciding for itself whether a message calls for code. Telling it to "write the tests first, then the implementation" sequences the output so a reviewer can judge the test coverage before judging the code that's supposed to pass it. And telling it to "give me a plan, I will approve before you code" invokes the plan step directly as a gate, regardless of how the channel happens to be configured. Each of these phrases does the same job: it tells the agent not just what to build, but what to hand back.
Writing constraints into the command so agents do not make high-stakes changes without a gate
A constraint in a Slack command draws an explicit line the agent would otherwise be free to cross, since anything within its connected repository and its granted permissions counts as fair game unless told otherwise. Leaving constraints out in an environment where the agent already has read access, write access, and the ability to open pull requests is close to handing a contractor the keys to an entire building when the job only called for painting one room.
Slack Code already requires a human to approve high-stakes steps, like pushing to production, before they happen, but that's a safeguard built into the workflow itself, not something tied to any individual command. A team that relies only on the workflow default to catch every risky action is trusting a general safety net instead of stating, task by task, which steps actually need a human to sign off. The command is where that intent belongs. Useful constraints to write directly into a command include boundaries on which files or directories the agent may touch, such as "do not touch anything outside /src/auth"; rules about which branch the work should land on, such as "target the feature branch, not main"; rules about dependencies, such as "do not add new packages without listing them for approval"; checkpoints that pause the agent before it proceeds, such as "pause and show me the plan before running any tests"; and limits on whether the agent should be changing anything at all, such as "read-only, report findings, do not modify files."
Teams that set clear boundaries before giving an agent access to a channel tend to run into fewer surprises later, but the channel's permission settings and the constraints written into a specific command are two different layers of control. The permission model sets the outer limit of what the agent could possibly do. The command sets what it should actually do on this particular run, and the two need to be set deliberately. Teams that find writing constraints into every command slows them down tend to solve it the same way they'd solve any repeated task: a shared library of constraint templates, one for each common type of work (a bug fix, a refactor, a new feature, an investigation), turns writing constraints into copying and adjusting a template.
Turning individual command craft into a team-wide standard through Slack Code channel structure
Because Slack Code puts agents into shared channels rather than private terminals, a poorly written command stops being one engineer's problem to live with. A vague command produces output that every reviewer in that channel now has to read, question, and untangle, and that review burden lands on the whole team rather than staying with whoever typed the original message. A command that skips scope, skips context, skips an output shape, or skips constraints doesn't just risk a wasted run for its author. It adds work for everyone downstream who has to figure out what went wrong and why.
The same channel structure that creates this exposure also makes it possible to fix at the team level. Because every command and every agent response lives in a channel the whole team can see, patterns become visible in a way they never were when agents ran in private terminal sessions. A team can look back across a week of channels and notice which commands produced plans worth reading on the first pass and which produced vague ones that needed rework, and it can turn the difference into a shared template rather than a lesson each engineer has to learn separately. The four-part structure, scope, context, output shape, and constraints, gives a team a shared vocabulary for writing commands and for reviewing them before the agent ever starts. What was once a private habit of prompting a tool well becomes a standard the team can write down, check new commands against, and hold every engineer to the same way it holds code itself to a review standard.


