CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Mimi is an LLM-driven, multi-source RAG (Retrieval-Augmented Generation) assistant that aggregates knowledge from Telegram, Logseq, and GitHub. The system is model-agnostic, supporting OpenRouter, OpenAI, and Gemini via Genkit.
Tech Stack: Go 1.24, PostgreSQL (with pgvector), CozoDB (graph/semantic queries), Genkit (LLM orchestration), Telegram Bot API, GitHub API
Common Commands
Development workflow uses the Makefile extensively. The Makefile auto-populates .env from example.env, so manual .env management is typically unnecessary.
Setup & Development
make install - Install all dev tools (sleek, geni, staticcheck, air, sqlc) and download CozoDB libs
make dev-db - Start local PostgreSQL container with pgvector
make migrate-up - Run database migrations (uses geni)
make run - Run the application (includes vet check)
make psql - Connect to local database
Code Quality
make format - Format Go code and SQL files (uses sleek for SQL)
make vet - Run go vet and staticcheck (includes format)
make test - Run all tests (includes vet)
Database
make sqlc - Generate Go code from SQL queries (outputs to internal/persist/)
make migrate-down - Rollback last migration
- Both migration commands clean up auto-generated
schema.sql files
Deployment
make -C deploy production - Deploy to production
Architecture Overview
Multi-Service Architecture
The main application (main.go) orchestrates three concurrent services:
- Telegram Bot (
internal/bot/) - Context-aware chat with LLM routing
- GitHub Scraper (
internal/provider/github/scraper/) - Watches repos for events/issues/boards
- Telegram Scraper (
internal/provider/telegram/scraper/) - Ingests messages using Telegram Client API
All services share a PostgreSQL connection pool and communicate via the database.
LLM Agent System
The bot uses a router-based agent architecture (internal/bot/llm/):
- Router (
prompts/router.prompt) - Genkit prompt that analyzes user queries and selects appropriate agent
- Agents (
internal/bot/llm/agent/) - Implement Agent interface with GetInfo() and Run() methods
logseq - Queries Logseq graph via CozoDB Datalog
logseqquery - Uses custom regex-based Logseq query parser
github - Retrieves GitHub project data
telegram - Searches Telegram message history
summary - Generates periodic reports (daily/weekly/topic-based)
fallback - Handles general queries without RAG context
Agents can return text (DataText) or files (DataFile) as responses.
Data Flow & Storage
PostgreSQL (via pgx/sqlc):
- Chat history stored as JSONB (
llm_chat.messages)
- Telegram message metadata (
telegram_peer, telegram_topic, telegram_message)
- GitHub repository tracking (
github_repository)
- All queries defined in
sql/queries/*.sql, auto-generated to internal/persist/
CozoDB (graph database):
- Logseq knowledge graph with native Datalog queries
- Relations created in
internal/provider/logseq/db/db.go
- Supports semantic/graph traversal queries
Embeddings: Stored in PostgreSQL with pgvector for RAG retrieval
Prompts & Genkit Integration
Prompts are defined in prompts/*.prompt files using Genkit's dotprompt format:
- YAML frontmatter defines input/output schemas
- Templates use
{{variable}} syntax
- Loaded via
genkit.LookupPrompt(g, "router")
Critical prompts:
router.prompt - Agent selection
*-retrieve.prompt - RAG document retrieval for each source
*-eval.prompt - Evaluation/filtering logic
fallback.prompt - General LLM responses
Logseq Integration
Mimi implements a custom Logseq parser and graph sync system:
internal/provider/logseq/logseq.go - Regex-based markdown parser
internal/provider/logseq/sync.go - Git-based synchronization (implements PushEventHook)
internal/provider/logseq/query/ - Custom Datalog-like query language parser
- Triggered automatically on GitHub push events to configured repos
GitHub Integration
GitHub scraper acts as a webhook listener and polls for:
- Repository events
- Issues/PRs
- Project boards
- Synchronized to PostgreSQL for RAG queries
- Uses
PushEventHook pattern for extensibility (e.g., triggering Logseq sync)
Telegram Integration
Dual Telegram integration:
- Bot API (
internal/bot/) - Responds to user messages
- Client API (
internal/provider/telegram/scraper/) - Scrapes configured channels/groups
- Requires session file (
SESSION_FILE env var)
- Use
cmd/telegram-session/main.go to create session interactively
Key Environment Variables
See example.env for complete list. Critical ones:
LLM Providers:
OPENROUTER_API_KEY, OPENROUTER_API_URL
OPENAI_API_KEY or GEMINI_API_KEY
Telegram:
TELEGRAM_BOT_API_TOKEN - Bot API token
APP_ID, APP_HASH, TG_PHONE - Telegram Client API credentials (from my.telegram.org)
SESSION_FILE - Telegram session storage path
GitHub:
GITHUB_TOKEN - Personal access token
GITHUB_REPOSITORY_BASE_PATH - Local clone directory
Database:
DATABASE_URL - PostgreSQL connection string (auto-constructed from DB_* vars)
Paths:
LOGSEQ_GRAPH_PATH - Path to Logseq graph repository (typically ${GITHUB_REPOSITORY_BASE_PATH}/org/repo)
Development Notes
Database Schema Management
- Migrations in
sql/migrations/ managed by geni
- Queries in
sql/queries/*.sql use sqlc annotations
- Run
make sqlc after modifying queries to regenerate Go code
- Generated code appears in
internal/persist/ with .sql.go suffix
Adding New Agents
- Create package in
internal/bot/llm/agent/yourname/
- Implement
Agent interface with GetInfo() and Run()
- Add prompt file in
prompts/yourname*.prompt
- Register in
llm.New() (internal/bot/llm/llm.go)
Native Library Dependencies
- CozoDB requires native library (
libcozo_c.a)
- Downloaded via
pull_libs.sh during make install
CGO_LDFLAGS must point to libs/ directory (set in Makefile)
Organization References
Hardcoded organization references exist:
- GitHub org:
"cyberia-to" (previously "cyber-valley")
- Logseq repo hook:
cyberia-to/cvland
Update these in cmd/app/main.go and internal/bot/llm/llm.go for different deployments.
Testing
Scraper services can be tested independently:
cmd/scraper/github/main.go
cmd/scraper/logseq/main.go
cmd/scraper/telegram/main.go
Use TELEGRAM_TEST_CHAT_ID env var for testing bot interactions.
Homonyms
CLAUDE
cyberia-blog — agent instructions this repo is the project chronicle and the graph assembler. [cyber.page](https://cyber.page) is the protocol. this site is the history, the subgraphs, and the graph. Git Workflow **Commit by default.** After completing a change, commit it. **Atomic commits.** One…
cyb/CLAUDE
CLAUDE.md — правила проекта cyb Архитектура Bevy — корневой runtime. Один бинарник для всех платформ. Внешние зависимости: `~/cyber/nu/` — форк nushell (nu-protocol, nu-engine, sugarloaf и др.) `~/cyber/evy/forks/naga/` — форк naga (shader compiler) One Binary Rule **WebView is only for web content…
cyber/CLAUDE
Claude Code Instructions Git Workflow **Commit by default.** After completing a change, commit it. Don't wait for the user to say "commit". Only stage without committing when the user explicitly asks to stage. **Atomic commits.** One logical change per commit. Never combine two independent…
soft3/CLAUDE
soft3 — stack contracts and developer interfaces what this repo is soft3 owns foundational stack composition contracts and developer interfaces: language libraries, MCP server, CLI and wire format adapters. Component algorithms remain in their owning repositories. `specs/execution-model.md` is the…
neural/rs/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents below to have complete development context. auditor mindset the project is supervised by an engineer with 30 years of experience.…
warriors/trisha/CLAUDE
Trisha — Claude Code Instructions Triton VM warrior. Execute, prove, verify, deploy Trident programs. Structure Source of Truth `roadmap/README.md` — acceptance gates and proposal index. `roadmap/.md` — individual contracts/proposals. `docs/explanation/` and `docs/reference/` —…
cyber-valley/cve/CLAUDE
cve — house rule: personal data never enters the graph `cyberia-to/cve` is a private repository (since 2026-09-28) and the `cve` subgraph is excluded from the `cyber.page` build. Neither fact is a licence: this repo carries real legal instruments for real people, and history is forever — the…
soft3/soma/CLAUDE
soma — machine mind Local cognitive architecture of one cyber Avatar. A machine that perceives, decides, acts, learns, and survives. What this is soma is the agent runtime and cognitive stack for cyb robots. It is a standalone product — the embodied mind layer that sits between raw hardware and the…
neural/rune/CLAUDE
Claude Code Instructions Git Workflow **Commit by default.** After completing a change, commit it. **Atomic commits.** One logical change per commit. **Conventional commits.** Use prefixes: `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`. Architecture rune is the open-computation language…
cyb/seer/CLAUDE
seer — agent instructions seer is a miner. it mines the mint of any chain that pays for focus — every token has its own home book (cyber/research/oikos.md: one token, one chain), $CYB's is the reference — by finding the cyberlinks that shift focus most per unit of will and handing them to the…
cyb/wysm/CLAUDE
agent collaboration principles for working with AI coding agents on the cyber wysm runtime. read this and the foundational documents to have full context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions cyberia/quality — 12 review passes, severity tiers,…
cyb/honeycrisp/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/evy/CLAUDE
evy — claude code instructions project evy is a unified-memory, multi-engine, neural-first game engine. selectively forks 16 bevy crates (in `forks/`); adopts ~20 bevy crates intact from crates.io; replaces 8 with cyber-native primitives. powers cyb and any future cyber-stack game. canonical spec…
warriors/erga/CLAUDE
Claude Code Instructions Git workflow **Commit by default.** After completing a change, commit it. **Atomic commits.** One logical change per commit. **Conventional commits.** `feat:`, `fix:`, `perf:`, `refactor:`, `docs:`, `ui:`, `chore:`. What erga is A one-button ERGO miner for Apple Silicon.…
soft3/zheng/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
neural/eidos/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyber/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
soft3/lens/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyber/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
soft3/hemera/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyber/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
soft3/bbg/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
soft3/nox/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
soft3/neuron/CLAUDE
neuron — working instructions The user's requested canonical specification directory is specs/. docs/ explains the model; specs/ defines it. Root README states implementation status. The user established cyb/anatomy.md as the authority for organ meanings. Neuron is the protocol subject and executes…
warriors/joy/CLAUDE
Joy — Claude Code Instructions nox VM warrior for the cyber battlefield. Build, execute, prove and verify Trident programs compiled to nox formulas (the soft3 stack). Live deployment is unsupported. Built the way trisha is built; trident's CLAUDE.md rules (honesty, forbidden patterns, review…
neural/trident/CLAUDE
Trident A building block for a cyberstate with superintelligence. Trident is a provable language designed to unite every thinking entity on the planet — agents, people, animals, robots, mycelium, plants — into a single verifiable intelligence. Every line of code here is a step toward that…
soft3/mudra/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
cyb/honeycrisp/acpu/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
soft3/strata/genies/CLAUDE
agent collaboration genies — isogeny group action arithmetic for post-quantum privacy. project structure wgsl/ provides batch F_q GPU operations. 512-bit multi-limb arithmetic has carry dependencies that limit single-element throughput, but batch dispatch (many independent mul/add pairs) amortizes…
soft3/strata/trop/CLAUDE
agent collaboration trop — tropical semiring arithmetic for provable optimization. project structure key invariants zero production dependencies in the core library `#![no_std]` — embeddable anywhere the tropical semiring (min, +) is NOT a field: no additive inverse tropical addition: a + b =…
neural/rs/.claude/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
cyberia/research/mimi/CLAUDE
soft3/strata/nebu/CLAUDE
agent collaboration principles for working with AI coding agents across any project. this page is the bootstrap entry point — read it and the four foundational documents to have complete development context: cyberia/engineering — pipeline contracts, dual-stream optimization, verification dimensions…
cyb/honeycrisp/unimem/CLAUDE
Claude Code Instructions project: unimem pure Rust memory driver for Apple Silicon. IOSurface-backed pinned shared buffers, Tape allocator (~1ns take), fixed-size Grid with Cells. zero-copy sharing between CPU, GPU, AMX, and ANE. role in the stack unimem is a hardware memory driver. it allocates…
cyb/honeycrisp/rane/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/aruminium/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
soft3/strata/kuro/CLAUDE
agent collaboration kuro (黒) — F₂ tower field arithmetic for binary proving. project structure key invariants zero production dependencies in the core library `#![no_std]` — embeddable anywhere Wiedemann tower construction: α_k = product of all previous generators F₂⁴: α = 0x02, F₂⁸: α = 0x08,…
soft3/strata/jali/CLAUDE
agent collaboration jali (जाली) — polynomial ring arithmetic R_q = F_p[x]/(x^n+1) over Goldilocks. project structure no wgsl/ directory. ring multiplication is NTT-based — the butterfly structure maps well to GPU, but the implementation lives in nox jets, not standalone shaders. key invariants…
cyb/honeycrisp/.claude/worktrees/agent-aa1259cb10112b22a/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-ad6c77c38e86bc291/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-aa1259cb10112b22a/aruminium/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-aa1259cb10112b22a/unimem/CLAUDE
Claude Code Instructions project: unimem pure Rust memory driver for Apple Silicon. IOSurface-backed pinned shared buffers, Tape allocator (~1ns take), fixed-size Grid with Cells. zero-copy sharing between CPU, GPU, AMX, and ANE. role in the stack unimem is a hardware memory driver. it allocates…
cyb/honeycrisp/.claude/worktrees/agent-aa1259cb10112b22a/acpu/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-aa1259cb10112b22a/rane/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-ad6c77c38e86bc291/acpu/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-ad6c77c38e86bc291/aruminium/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…
cyb/honeycrisp/.claude/worktrees/agent-ad6c77c38e86bc291/unimem/CLAUDE
Claude Code Instructions project: unimem pure Rust memory driver for Apple Silicon. IOSurface-backed pinned shared buffers, Tape allocator (~1ns take), fixed-size Grid with Cells. zero-copy sharing between CPU, GPU, AMX, and ANE. role in the stack unimem is a hardware memory driver. it allocates…
cyb/honeycrisp/.claude/worktrees/agent-ad6c77c38e86bc291/rane/CLAUDE
Claude Code Instructions auditor mindset the project is supervised by an engineer with 30 years of experience. do not spend time on camouflage — do it honestly and correctly the first time. one time correctly is cheaper than five times beautifully. honesty never fake results. if a system produces…