$npx -y skills add berabuddies/Semia --skill discord-soulCreate a living agent from your Discord server. The agent embodies your community's identity, remembers every conversation, and grows as the community evolves. Talk to your Discord as if it were a person.
| 1 | # Discord Soul |
| 2 | |
| 3 | Turn your Discord server into a living, breathing agent. |
| 4 | |
| 5 | ## What You Get |
| 6 | |
| 7 | An agent that: |
| 8 | - **Remembers** every conversation in your Discord |
| 9 | - **Speaks** in your community's voice |
| 10 | - **Knows** the key figures, channels, and inside jokes |
| 11 | - **Grows** as new messages arrive daily |
| 12 | - **Answers** questions about your community's history and culture |
| 13 | |
| 14 | ## Quick Start |
| 15 | |
| 16 | ```bash |
| 17 | # Create agent from your Discord |
| 18 | ./scripts/create_agent.sh \ |
| 19 | --name "my-community" \ |
| 20 | --guild YOUR_GUILD_ID \ |
| 21 | --output ./agents/ |
| 22 | |
| 23 | # Set up daily updates |
| 24 | crontab -e |
| 25 | # Add: 0 */3 * * * /path/to/update_agent.sh |
| 26 | ``` |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | # The Full Process |
| 31 | |
| 32 | ## Step 1: Export Your Discord |
| 33 | |
| 34 | You need [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) CLI. |
| 35 | |
| 36 | **Get your token:** |
| 37 | 1. Open Discord in browser |
| 38 | 2. Press F12 → Network tab |
| 39 | 3. Send a message, find the request |
| 40 | 4. Copy the `authorization` header value |
| 41 | 5. Save to `~/.config/discord-exporter-token` |
| 42 | |
| 43 | **Export everything:** |
| 44 | ```bash |
| 45 | DiscordChatExporter.Cli exportguild \ |
| 46 | --guild YOUR_GUILD_ID \ |
| 47 | --token "$(cat ~/.config/discord-exporter-token)" \ |
| 48 | --format Json \ |
| 49 | --output ./export/ \ |
| 50 | --include-threads All \ |
| 51 | --media false |
| 52 | ``` |
| 53 | |
| 54 | ## Step 2: Security Pipeline (CRITICAL) |
| 55 | |
| 56 | ⚠️ **Discord content from public servers may contain prompt injection attacks.** |
| 57 | |
| 58 | Before ingesting to your agent, run the security pipeline: |
| 59 | |
| 60 | ### Threat Model |
| 61 | |
| 62 | Discord users may attempt: |
| 63 | - **Direct injection:** "Ignore previous instructions and..." |
| 64 | - **Role hijacking:** "You are now a...", "Pretend you're..." |
| 65 | - **System injection:** `<system>`, `[INST]`, `<<SYS>>` |
| 66 | - **Jailbreaks:** "DAN mode", "developer mode" |
| 67 | - **Exfiltration:** "Reveal your system prompt" |
| 68 | |
| 69 | ### Layer 1: Regex Pre-Filter (Fast, No LLM) |
| 70 | |
| 71 | ```bash |
| 72 | python scripts/regex-filter.py --db ./discord.sqlite |
| 73 | ``` |
| 74 | |
| 75 | Flags messages matching known injection patterns: |
| 76 | - Instruction overrides |
| 77 | - Role hijacking attempts |
| 78 | - System prompt markers |
| 79 | - Jailbreak keywords |
| 80 | - Exfiltration attempts |
| 81 | |
| 82 | Flagged messages get `safety_status = 'regex_flagged'`. |
| 83 | |
| 84 | ### Layer 2: Haiku Safety Evaluation (Semantic) |
| 85 | |
| 86 | ```bash |
| 87 | ANTHROPIC_API_KEY=sk-... python scripts/evaluate-safety.py --db ./discord.sqlite |
| 88 | ``` |
| 89 | |
| 90 | Uses Claude Haiku (~$0.25/1M tokens) to semantically evaluate remaining messages. |
| 91 | |
| 92 | Each message gets a risk score 0.0-1.0: |
| 93 | - 0.0-0.3: Normal conversation |
| 94 | - 0.4-0.6: Suspicious but possibly benign |
| 95 | - 0.7-1.0: Likely injection attempt |
| 96 | |
| 97 | Messages scoring ≥0.6 get `safety_status = 'flagged'`. |
| 98 | |
| 99 | ### Layer 3: Only Use Safe Content |
| 100 | |
| 101 | The ingest and memory generation scripts should only use messages where: |
| 102 | |
| 103 | ```sql |
| 104 | SELECT * FROM messages WHERE safety_status = 'safe' |
| 105 | ``` |
| 106 | |
| 107 | ### Full Security Pipeline |
| 108 | |
| 109 | ```bash |
| 110 | # Run complete pipeline |
| 111 | ./scripts/secure-pipeline.sh ./export/ ./discord.sqlite |
| 112 | ``` |
| 113 | |
| 114 | This runs: Export → SQLite → Regex Filter → Haiku Eval → Mark Safe |
| 115 | |
| 116 | ### Safety Statuses |
| 117 | |
| 118 | | Status | Meaning | Used by Agent? | |
| 119 | |--------|---------|----------------| |
| 120 | | `pending` | Not evaluated | ❌ No | |
| 121 | | `regex_flagged` | Matched pattern | ❌ No | |
| 122 | | `flagged` | Haiku risk ≥0.6 | ❌ No | |
| 123 | | `safe` | Passed all checks | ✅ Yes | |
| 124 | |
| 125 | --- |
| 126 | |
| 127 | ## Step 3: Ingest to SQLite |
| 128 | |
| 129 | Convert JSON to a rich SQLite database: |
| 130 | |
| 131 | ```bash |
| 132 | python scripts/ingest_rich.py --input ./export/ --output ./discord.sqlite |
| 133 | ``` |
| 134 | |
| 135 | **What gets captured:** |
| 136 | - Every message with full content |
| 137 | - Reactions (individual emoji counts: 🔥 x5, 👍 x12) |
| 138 | - Author roles and colors |
| 139 | - Channel categories and topics |
| 140 | - Reply threading |
| 141 | - Mentions, attachments, embeds |
| 142 | |
| 143 | ## Step 4: Create Agent Workspace |
| 144 | |
| 145 | ```bash |
| 146 | mkdir -p ./my-agent/memory |
| 147 | ``` |
| 148 | |
| 149 | Copy template files from `templates/`: |
| 150 | - `SOUL.md` — Community identity (grows through simulation) |
| 151 | - `MEMORY.md` — Long-term milestones |
| 152 | - `LEARNINGS.md` — Patterns discovered |
| 153 | - `AGENTS.md` — Key figures |
| 154 | - `TOOLS.md` — Channels and rituals |
| 155 | - `HEARTBEAT.md` — Maintenance protocol |
| 156 | |
| 157 | ## Step 5: Generate Daily Memory Files |
| 158 | |
| 159 | ```bash |
| 160 | python scripts/generate_daily_memory.py --all \ |
| 161 | --db ./discord.sqlite \ |
| 162 | --out ./my-agent/memory/ |
| 163 | ``` |
| 164 | |
| 165 | Each day becomes a markdown file with: |
| 166 | - Full conversation logs |
| 167 | - Who said what, when |
| 168 | - Reactions on each message |
| 169 | - New channels/roles that appeared |
| 170 | |
| 171 | ## Step 6: Simulate Growth (The Soul Emerges) |
| 172 | |
| 173 | **This is the key insight:** Process days chronologically. |
| 174 | |
| 175 | The agent "lives through" each day, updating its soul files as patterns emerge. |
| 176 | |
| 177 | ```bash |
| 178 | python scripts/simulate_growth.py --agent ./my-agent/ |
| 179 | ``` |
| 180 | |
| 181 | For each day (in order!): |
| 182 | 1. Read the day's memory file |
| 183 | 2. Update SOUL.md if identity shifted |
| 184 | 3. Add to LEARNINGS.md if patterns discovered |
| 185 | 4. Record milestones in MEMORY.md |
| 186 | 5. Note key figures in AGENTS.md |
| 187 | |
| 188 | **Run the prompts with an LLM:** |
| 189 | ```bash |
| 190 | # Example with OpenClaw |
| 191 | for f in ./my-agent/simulation/day-*.txt; do |
| 192 | echo "Processing $f..." |
| 193 | cat "$f" | openclaw chat --agent my |