Skip to content

fix(telegram,discord): respect STATE_DIR env vars in skill prompts#977

Open
snemesh wants to merge 2 commits intoanthropics:mainfrom
snemesh:fix/telegram-skills-respect-state-dir
Open

fix(telegram,discord): respect STATE_DIR env vars in skill prompts#977
snemesh wants to merge 2 commits intoanthropics:mainfrom
snemesh:fix/telegram-skills-respect-state-dir

Conversation

@snemesh
Copy link
Copy Markdown

@snemesh snemesh commented Mar 25, 2026

Problem

PR #792 added TELEGRAM_STATE_DIR support to server.ts, and Discord's server.ts similarly supports DISCORD_STATE_DIR. But the skill files for both channels were not updated — they hardcode ~/.claude/channels/{telegram,discord}/ paths.

When running multiple bots (e.g. per-project), the server writes state to the correct directory via the env var, but the skills always read/write the default path. This means:

  • /access pair <code> looks up the code in the wrong access.json
  • /configure <token> saves the token to the wrong .env
  • /access status shows the wrong allowlist

Fix

Both Telegram and Discord skills now resolve $STATE_DIR from their respective env vars before any file operations, falling back to the default path when unset.

No behavior change for single-channel setups (env var is unset → same default path).

Changes

Telegram (commit 1):

  • skills/access/SKILL.md — replaced 6 hardcoded paths, added state dir resolution block
  • skills/configure/SKILL.md — replaced 5 hardcoded paths, added state dir resolution block

Discord (commit 2, reported by @gtapps):

  • skills/access/SKILL.md — replaced 6 hardcoded paths, added state dir resolution block
  • skills/configure/SKILL.md — replaced 5 hardcoded paths, added state dir resolution block

Test plan

  • Grep confirms zero remaining hardcoded paths outside fallback definitions
  • Pattern matches existing Telegram fix exactly

The /telegram:access and /telegram:configure skills hardcode
~/.claude/channels/telegram/ in 12 places. When TELEGRAM_STATE_DIR
is set (multi-project setups), the skills read/write the wrong
directory — pairing codes are not found, tokens are saved to the
wrong .env, and allowlists don't match the running server.

Both skills now resolve $STATE_DIR from the environment variable
before any file operations, falling back to the default path when
unset. No behavior change for single-channel setups.

Fixes anthropics#931
@gtapps
Copy link
Copy Markdown

gtapps commented Mar 28, 2026

The same issue is happening with DISCORD_STATE_DIR ;)

Same fix as Telegram: replace 11 hardcoded ~/.claude/channels/discord/
paths in access and configure skills with $STATE_DIR resolved from
DISCORD_STATE_DIR env var (fallback to default when unset).

Fixes multi-bot setups where pairing codes, tokens, and allowlists
were written to/read from the wrong directory.

Reported by @gtapps in PR review.
@snemesh snemesh changed the title fix(telegram): respect TELEGRAM_STATE_DIR in skill prompts fix(telegram,discord): respect STATE_DIR env vars in skill prompts Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants