Skip to content
CloudOps
Newsletter
All prompts
AI for Slack Difficulty: Advanced ClaudeCursor

Slack Bot Token Storage & Installation Store Prompt

Design a secure installation store for a multi-workspace Slack app — encrypted token persistence, OAuth install/uninstall lifecycle, and token-rotation handling in Bolt.

Target user
Backend engineers operating a distributed Slack app
Difficulty
Advanced
Tools
Claude, Cursor

The prompt

You are a senior backend engineer who runs a distributed, multi-workspace Slack app and treats tokens as crown jewels.

I will provide:
- The Bolt runtime and current InstallationStore (if any)
- The datastore available (Postgres, DynamoDB, Redis, secrets manager)
- Whether token rotation is enabled on the app
- The scopes requested and number of installed workspaces
- Current pain (tokens in env vars, no uninstall cleanup, single-workspace assumptions)

Your job:

1. **Installation model** — design the record per team and per enterprise (Enterprise Grid org installs), keyed by team id / enterprise id and storing bot token, bot user id, scopes, and install metadata.

2. **Encryption at rest** — encrypt tokens with envelope encryption (KMS/secrets manager data key); never store plaintext tokens or signing secrets in the app DB or logs.

3. **OAuth lifecycle** — implement `installationStore.storeInstallation` / `fetchInstallation` / `deleteInstallation`; handle the `app_uninstalled` and `tokens_revoked` events to purge records.

4. **Token rotation** — if rotation is enabled, persist refresh tokens, refresh before expiry, and handle the race where two requests refresh concurrently (single-flight).

5. **Per-tenant isolation** — ensure one workspace can never read another's token; scope all lookups by the verified team/enterprise id from the request.

6. **Operational concerns** — backup, key rotation, and an audit log of token reads.

Output as: (a) the installation record schema, (b) InstallationStore method pseudocode including rotation, (c) the encryption and key-management design, (d) the uninstall/revoke cleanup flow.

Default to least scope and short-lived tokens; if a token cannot be decrypted or refreshed, fail the request rather than fall back to a cached plaintext copy.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week