Remote agentic workflow system for Claude Code with Discord integration.
- Thread-based parallel agent execution (each Discord thread = separate Claude CLI process)
- Direct Message (DM) support for private sessions
- Git worktree isolation for conflict-free parallel work
- Human-in-the-loop (HITL) approval workflow via Discord
- SQLite persistence for session state and audit logs
- Atomic commits per session
- Session lifecycle management
claude-agent-daemon/
├── daemon/ # Main binary
├── bot-interface/ # Discord bot
├── session-manager/ # Multi-session orchestration
├── claude-executor/ # Claude CLI wrapper
├── job-queue/ # Job management & persistence
├── repo-manager/ # Git operations
└── shared/ # Common types & errors
- Rust 1.75+
- Claude Code CLI installed and authenticated (
claudecommand available) - Git repository
- Discord bot token with correct permissions (see Bot Setup below)
-
Go to Discord Developer Portal
-
Create a new application or select your existing bot
-
Go to the "Bot" section and get your bot token
-
Enable the following Privileged Gateway Intents:
- ✅ Message Content Intent
-
Go to OAuth2 → URL Generator and select:
- Scopes:
bot - Bot Permissions:
- View Channels
- Send Messages
- Send Messages in Threads
- Create Public Threads
- Manage Threads
- Read Message History
- Embed Links
- Scopes:
-
Use this OAuth2 URL to invite your bot (replace
YOUR_CLIENT_ID):
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=326432598048&scope=bot
Permission Integer: 326432598048
git clone <repo>
cd claude-agent-daemon
cargo build --releaseBinary will be at target/release/claude-daemon
- Copy example config:
cp daemon.toml.example daemon.toml- Edit
daemon.toml:
[repository]
path = "/path/to/your/repo"
[discord]
bot_token = "your_bot_token"
guild_id = "your_guild_id"
authorized_users = ["discord_user_id_1", "discord_user_id_2"]- Set environment variable:
export DISCORD_BOT_TOKEN="your_token"- Ensure Claude Code CLI is authenticated:
claude --version
# Should work without asking for credentials./target/release/claude-daemon --config daemon.tomlOr with verbose logging:
./target/release/claude-daemon --config daemon.toml --verboseMain Channel:
/new-task <description>- Create new thread and spawn Claude session/list-tasks- Show all active sessions/help- Show available commands
In Thread or DM:
<message>- Send message to Claude CLI/status- Show session info and runtime/diff- Show git changes in this session/commit <message>- Commit changes atomically/cancel- Terminate session and cleanup
Direct Messages: You can also DM the bot directly! It will automatically create a private session for you.
Main Channel:
You: /new-task Fix authentication bug in login.rs
Bot: Created thread and session: Fix authentication bug in login.rs
Thread "Fix authentication bug in login.rs":
You: Find the auth bug
Bot: I found the issue in login.rs:45. The token validation is missing...
You: Fix it and add tests
Bot: Done. Fixed the bug and added 3 unit tests. All tests passing.
You: /diff
Bot: [shows git diff]
You: /commit "Fix token validation bug"
Bot: Committed to branch session-abc123. Commit: a1b2c3d
Create /etc/systemd/system/claude-daemon.service:
[Unit]
Description=Claude Agent Daemon
After=network.target
[Service]
Type=simple
User=youruser
WorkingDirectory=/opt/claude-agent-daemon
ExecStart=/opt/claude-agent-daemon/target/release/claude-daemon --config /opt/claude-agent-daemon/daemon.toml
Restart=on-failure
RestartSec=10
Environment="ANTHROPIC_API_KEY=sk-ant-..."
Environment="DISCORD_BOT_TOKEN=..."
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable claude-daemon
sudo systemctl start claude-daemon
sudo systemctl status claude-daemoncargo testRUST_LOG=debug cargo run -- --config daemon.tomlcargo clippy
cargo fmt --checkEach Discord thread creates:
- Separate Claude Code CLI process
- Isolated working directory (
/tmp/claude-sessions/{thread-id}/) - Git worktree with unique branch (
session-{uuid}) - Independent conversation context
Git worktrees enable true parallel work:
- Each session works on its own branch
- No merge conflicts between sessions
- Can commit/discard independently
- Automatic cleanup on session termination
Sessions persist to SQLite with states:
active- Running normallyawaiting_review- HITL checkpointcompleted- Successfully finishedfailed- Error occurredcancelled- User terminated
Ensure Claude Code CLI is installed and in PATH:
which claude
claude --versionCheck repository permissions and ensure user has write access:
ls -la /path/to/repoStop daemon and check for stale processes:
systemctl stop claude-daemon
ps aux | grep claude- Verify bot token in config
- Check bot has required permissions in Discord
- Ensure bot is added to your server
- Check logs:
tail -f logs/daemon.log
- Bot tokens stored in config (use environment variables)
- User whitelist enforced via
authorized_users - Audit log tracks all commands and commits
- Sessions isolated in separate directories
- No auto-push to remote (manual only)
- Supports 3+ concurrent sessions (configurable)
- Session creation: <5 seconds
- Message response: <3 seconds
- Minimal daemon overhead: ~50MB memory idle
- Slack integration (v1.1)
- Web dashboard (v2.0)
- Multi-repository support (v1.2)
- CI/CD integration (v1.3)
- Real-time output streaming (v1.5)
MIT
See PRD at claude-agent-daemon-prd.md