opencode-slack-integration
Skill11 starsChanged 12 days agoMITView on GitHub
Connect a local opencode server to Slack over Socket Mode so channel threads and DMs continue opencode sessions, including permission approvals. Use when asked to connect opencode to Slack, run an opencode Slack bot, or debug Slack bridge sessions and permissions.
- Reads credentials
- Installs packages
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-evaluationSkill
- feature-workflowSkill
- opencode-session-dbSkill
- plugin-testingSkill
- readiness-checkSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Run this bridge beside opencode serve.
- Very specific: line 20
Create a mode-600 env file at ~/.env.d/opencode-slack.env:
- Very specific: line 41
Use tmux or a process manager for a persistent bridge.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
opencode Slack integration
Run this bridge beside opencode serve. Each channel thread gets one opencode session; each DM channel gets one persistent session. Permission approval is limited to explicitly allowlisted Slack users.
Requirements
- Node 22 (
>=22 <23). Node 26 breaks Bolt Socket Mode. opencode serve --port 4096 --hostname 127.0.0.1with a usable model.- A Slack app created from
manifest.json, installed in the target workspace, with Socket Mode enabled. - Both DMs and “Allow users to send messages from the Messages tab” enabled under App Home.
SLACK_ALLOWED_USERSset to one or more trusted Slack user IDs. Empty means no users are allowed.
Configure and run
Create a mode-600 env file at ~/.env.d/opencode-slack.env:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...
SLACK_ALLOWED_USERS=U123,U456
OPENCODE_URL=http://127.0.0.1:4096
OPENCODE_DIRECTORY=/absolute/path/to/project
OPENCODE_MODEL=provider/model
SLACK_AUTO_APPROVE=0Store Slack credentials in Bitwarden. Never commit or print tokens. Set OPENCODE_MODEL to an existing provider/model; a free model can reject prompts after its quota is exhausted.
cd slack-bridge
npm install
npm test
npm startUse tmux or a process manager for a persistent bridge. Invite the bot into each channel with /invite @opencode.
Verify
- In a channel, send
@opencode reply with exactly: PONG; expectPONGin a new thread. - Reply in that thread without mentioning the bot; expect the same session to continue.
- DM the bot
Reply with exactly: DMOK; expectDMOK. - Request access to an external file. Expect Allow once / Always / Reject buttons. Click Allow once and confirm the pending permission clears and the answer appears.
Behavior and safeguards
- Streaming placeholders update from opencode events; final text is fetched at
session.idle. finish: "tool-calls"keeps the session active until idle.- Permission events handle
permission.askedandpermission.updated. - Permission buttons require an allowlisted actor and the exact active Slack message/session mapping. API errors preserve the buttons and return an ephemeral retry notice.
- Pending permission mappings persist in
~/.local/state/opencode-slack/permissions.json, so buttons remain usable across bridge restarts. - Active placeholder mappings persist in
~/.local/state/opencode-slack/active.json, so an in-flight response can finalize after restart. - DM sessions are checked against opencode on every new message; a deleted session is cleared and recreated.
- Concurrent first messages in a DM share one session creation. Temporary opencode lookup errors preserve the existing session mapping.
- On startup, completed work with a persisted placeholder is finalized; still-running work remains locked until
session.idle. - Channel messages containing a bot mention are handled only by the mention event, including when the mention is not at the start of the text.
- Repeated
permission.asked/permission.updatedevents for the same request reuse one Slack action message. - A message received while its session is busy is not queued; Slack receives a notice to resend it after the current reply.
- Session IDs persist in
~/.local/state/opencode-slack/sessions.json.
Checks
node --check bridge.mjs
npm testDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

