agentleFS
dzianisvdzianisv/opencode-plugins/slack-bridge/SKILL.md

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

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
  1. Very specific:

    Run this bridge beside opencode serve.

    line 8
  2. Very specific:

    Create a mode-600 env file at ~/.env.d/opencode-slack.env:

    line 20
  3. Very specific:

    Use tmux or a process manager for a persistent bridge.

    line 41

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.1 with 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_USERS set 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=0

Store 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 start

Use tmux or a process manager for a persistent bridge. Invite the bot into each channel with /invite @opencode.

Verify

  1. In a channel, send @opencode reply with exactly: PONG; expect PONG in a new thread.
  2. Reply in that thread without mentioning the bot; expect the same session to continue.
  3. DM the bot Reply with exactly: DMOK; expect DMOK.
  4. 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.asked and permission.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.updated events 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 test

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.