feat: Discord bot — per-session rules, user identity, and DISCORD_CLAUDE.md

- Add DISCORD_CLAUDE.md as the Discord bot's dedicated system prompt,
  replacing the main CLAUDE.md for bot sessions. Covers: no-interactive
  rules, Discord user authorization, vault/remediation guidance, /save
  after every task, and formatting rules for Discord.

- config.py: add discord_system_prompt field (default: projects/discord-bot/
  DISCORD_CLAUDE.md, overridable via env var).

- client.py: _load_system_prompt() now loads discord_system_prompt path
  with fallback to CLAUDE.md if file is missing.

- message_handler.py: inject [DISCORD_CONTEXT] header into every agent
  message containing Discord username, display name, user ID, channel,
  and guild so the agent always knows who is asking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 10:11:36 -07:00
parent 377ab3a63f
commit 020ae0cc1c
4 changed files with 206 additions and 6 deletions

View File

@@ -20,8 +20,14 @@ logger = logging.getLogger(__name__)
def _load_system_prompt() -> str:
claude_md = settings.claudetools_root / ".claude" / "CLAUDE.md"
return claude_md.read_text(encoding="utf-8")
prompt_path = settings.claudetools_root / settings.discord_system_prompt
if prompt_path.exists():
return prompt_path.read_text(encoding="utf-8")
logger.warning(
"[WARNING] Discord system prompt not found at %s — falling back to CLAUDE.md",
prompt_path,
)
return (settings.claudetools_root / ".claude" / "CLAUDE.md").read_text(encoding="utf-8")
class ThreadAgent: