agentforge
CLAUDE.md4 starsChanged 9 months agoApache-2.0Archived repositoryView on GitHub
Read this file completely before starting any work. All rules are mandatory. For deep technical reference on Convex + Mastra integration patterns, read: docs/reference/TECH-REFERENCE.md A self-hosted AI agent framework: central daemon (like OpenClaw) + local dashboard. Built on Mastra + Convex. Architecture: - packages/runtime/ — Mastra daemon (persistent Node.js process, channels: HTTP/Discord/Telegram) - packages/cli/ — CLI: scaffold, manage, start, chat - packages/core/ — shared types + utilities - packages/cli/dist/default/ / packages/cli/templates/default/ — what agentforge create scaffolds Auth, billing, and cloud…
In this repository62 other files it gives its agents.
- llms.txtllms.txt
- agentforge-a2aSkill
- agentforge-browser-toolingSkill
- agentforge-channel-adaptersSkill
- agentforge-cliSkill
- agentforge-convexSkill
- agentforge-dashboardSkill
- agentforge-mcp-integrationSkill
- agentforge-research-orchestratorSkill
- agentforge-runtime-daemonSkill
- agentforge-sandbox-executionSkill
- agentforgeSkill
- agentforge-skills-marketplaceSkill
- agentforge-template-syncSkill
- agentforge-testingSkill
- convex-advisorSkill
- convex-auth-setupSkill
- convex-best-practicesSkill
- convex-component-authoringSkill
- convex-components-guideSkill
- convex-cron-jobsSkill
- convex-file-storageSkill
- convex-function-creatorSkill
- convex-helpers-guideSkill
- convex-http-actionsSkill
- convex-mcp-setupSkill
- convex-migration-helperSkill
- convex-quickstartSkill
- convex-realtimeSkill
- convex-reviewerSkill
- convex-schema-builderSkill
- convex-security-auditSkill
- convex-security-checkSkill
- convexSkill
- mastraSkill
- specsafe-agentforgeSkill
- specsafeSkill
- specSkill
- validateSkill
- working-with-sqliteSkill
- agentforge-convexSkill
- gh-workflowSkill
- spec-createSkill
- specsafe-agentforgeSkill
- specsafe-doneSkill
- specsafe-exploreSkill
- specsafe-newSkill
- specsafeSkill
- specsafe-specSkill
- specsafe-test-applySkill
- specsafe-test-createSkill
- specsafe-verifySkill
- specSkill
- template-sync-checkSkill
- validateSkill
- working-with-sqliteSkill
- agentforge-convexSkill
- browser-automationSkill
- example-skillSkill
- skill-creatorSkill
- The first 60 shown.
The file
We split this CLAUDE.md into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Before writing any code: search the codebase, look for existing implementations.
- Distinctive: line 119
Every Convex template file must be kept identical in these 3 git-tracked locations:
- Very specific: line 126
Use pnpm sync-templates after any template change.
- Distinctive: line 176
All 7 specs implementing the daemon architecture have been merged (SPEC-020 through SPEC-026).
- Distinctive: line 199
All sensitive Convex functions internalized with thin public wrappers
- Very specific: line 221
Use agentforge status to check connection
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md — AgentForge Development Context
Read this file completely before starting any work. All rules are mandatory. For deep technical reference on Convex + Mastra integration patterns, read:
docs/reference/TECH-REFERENCE.md
What is AgentForge?
A self-hosted AI agent framework: central daemon (like OpenClaw) + local dashboard. Built on Mastra + Convex.
Architecture:
packages/runtime/— Mastra daemon (persistent Node.js process, channels: HTTP/Discord/Telegram)packages/cli/— CLI: scaffold, manage, start, chatpackages/core/— shared types + utilitiespackages/cli/dist/default//packages/cli/templates/default/— whatagentforge createscaffolds
Auth, billing, and cloud hosting are future concerns. Do not implement them now.
🚨 RULES — Non-Negotiable
1 · Audit Before Implementing
Before writing any code: search the codebase, look for existing implementations. Does it exist? Is it broken? Is it a stub? Document what you find first.
2 · SpecSafe-First Workflow
1. Write tests (watch them FAIL — proves tests are real)
2. Implement
3. pnpm test — must be GREEN
4. Fix any failures NOW before moving on3 · Read docs/reference/TECH-REFERENCE.md Before Every Sprint
Critical rules are documented there. APIs change constantly. Key links:
- Mastra: https://mastra.ai/docs
- Convex: https://docs.convex.dev
- @mastra/convex (storage): https://mastra.ai/reference/storage/convex
- get-convex/mastra (component, NOT used here): https://github.com/get-convex/mastra
4 · CLI First → Dashboard Second
agentforge <command>— implement and test via CLI- Dashboard view — comes after CLI works
5 · Architecture Rules
Mastra belongs in packages/runtime/ — NEVER in Convex actions
Running Mastra inside Convex Node.js actions produces 10-15s cold starts, no real streaming, and broken crypto. The daemon runs as a persistent process.
✅ packages/runtime/ → Mastra agent runtime
✅ convex/ → data layer only (agents config, apiKeys, logs, threads display)
❌ convex/chat.ts → DELETED (never put LLM calls in Convex)
❌ convex/lib/agent.ts → DELETED
❌ convex/mastraIntegration.ts → DELETEDMemory: use ConvexStore (not LibSQL)
// ✅ packages/runtime — use @mastra/convex for memory
import { ConvexStore } from '@mastra/convex'
import { ConvexVector } from '@mastra/convex'
// ❌ Wrong for daemon — LibSQL creates a local SQLite file per project
import { LibSQLStore } from '@mastra/libsql'Convex runtime boundaries
// "use node" files → ONLY action / internalAction (NEVER query/mutation)
// Default V8 files → query, mutation, internalQuery, internalMutation
// ✅ Call internal functions correctly
await ctx.runQuery(internal.apiKeys.getDecryptedForProvider, { provider })
// ❌ Wrong — api.* is public (client-accessible)
await ctx.runQuery(api.apiKeys.getDecryptedForProvider, { provider })API key encryption — Node.js only
// ✅ "use node" internalAction with node:crypto
import * as crypto from 'node:crypto'
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv)
// ❌ Never — crypto.subtle in V8 runtime → 10-19s latency
await crypto.subtle.deriveBits(...) // too slow for per-request useAgent model format
// ✅ Mastra model router format
model: 'openai/gpt-5.1'
model: 'anthropic/claude-opus-4-6'
model: 'moonshotai/kimi-k2.5' // default daemon model
// ❌ Old BYOK pattern — no longer needed
model: { providerId, modelId, apiKey, url }Tools — createTool, not magic strings
// ✅ Always use createTool from @mastra/core/tools
import { createTool } from '@mastra/core/tools'
export const myTool = createTool({
id: 'my-tool',
execute: async ({ query }) => { /* inputData directly, NOT { context } */ }
})Streaming
// ✅ Always stream for channels
const stream = await agent.stream(messages, { threadId, resourceId })
for await (const chunk of stream.fullStream) { ... }6 · Template Sync (3 git-tracked locations)
Every Convex template file must be kept identical in these 3 git-tracked locations:
packages/cli/templates/default/convex/ ← CANONICAL SOURCE
templates/default/convex/
convex/packages/cli/dist/default/convex/ is gitignored — pnpm sync-templates handles it at build time.
Use pnpm sync-templates after any template change.
7 · File Storage
// ✅ Real Convex file storage
const uploadUrl = await ctx.storage.generateUploadUrl()
// ❌ Never fake it
url: 'pending-upload'8 · QA + Security After Every PR
pnpm test— all greentsc --noEmit— 0 errorspnpm audit— 0 high/critical vulnerabilities- Manual CLI test:
agentforge start,agentforge chat,agentforge status - No hardcoded secrets
Security Patterns — Convex Function Visibility
Sensitive functions MUST be internal
// ✅ Sensitive operations → internalMutation / internalAction
export const censorMessage = internalMutation({ ... }) // pattern detection
export const create = internalAction({ ... }) // API key encryption
// ✅ Public wrappers → strip sensitive fields
export const censorText = mutation({ // returns only { censoredText, secretsDetected }
handler: async (ctx, args) => {
const result = await ctx.runMutation(internal.vault.censorMessage, ...)
return { censoredText: result.censoredText, secretsDetected: result.secretsDetected }
}
})
// ❌ Never expose pattern names, storedSecrets, or encryption internals to clientsPublic wrapper naming convention
| Internal function | Public wrapper | Purpose |
vault.censorMessage | vault.censorText | Strips pattern names |
apiKeys.create | apiKeys.createKey | Delegates to encryption |
apiKeys.update | apiKeys.updateKey | Delegates to encryption |
Current Status (v0.12.24, March 2026)
Architecture Redesign Complete
All 7 specs implementing the daemon architecture have been merged (SPEC-020 through SPEC-026).
Sprint 3 (v0.12.24) — Public Launch Prep
- #253: Security hardening + community readiness (PR merged)
censorMessage→internalMutation+censorTextpublic wrapper (#239)apiKeys.create/update→internalAction+createKey/updateKeywrappers- HTTP auth bypass documented with startup warning (#248)
- Dependencies patched: undici ≥7.24.0, hono ≥4.12.7, fast-xml-parser ≥5.5.6 (#232)
- SECURITY.md, issue/PR templates added
- Git history scrubbed of hardcoded API key via
git-filter-repo - Internal dev files removed (TASK.md, PROJECT_STATE.md, AGENTS.md → docs/development.md)
- CONTRIBUTING.md updated: XOR → AES-256-GCM encryption docs
What Works (v0.12.24)
- Full daemon model:
agentforge start→ persistent Mastra runtime agentforge create / status / agents / models / keys / tokens / threads / logs / skills / dashboard / chat- HTTP channel with OpenAI-compatible POST /api/chat + GET /api/agents
- Discord and Telegram channel adapters
- Dynamic model fetching from all 8 provider APIs
- Usage token tracking per request
- AES-256-GCM API key encryption (Node.js only, never crypto.subtle)
- SHA-256 token hashing — plaintext returned once at creation, validated by hash
- Chat-scoped model override — per-thread model selection, config cascade
- All sensitive Convex functions internalized with thin public wrappers
pnpm audit→ 0 vulnerabilities- SECURITY.md, issue templates, PR template for community contributions
Key Architectural Decisions
- Central daemon model (like OpenClaw, not per-project)
- Channels v1: HTTP + Discord + Telegram
- Memory: ConvexStore (not LibSQL) — dashboard visibility
- Mastra runs in
packages/runtime/— never in Convex actions - Model override: per-thread (not per-agent) — creates temporary agent, never mutates cached agent
- Sensitive Convex functions: always
internal*, with thin public wrappers that strip sensitive data
Known Technical Debt (from multi-model audit)
- 429
anycasts in CLI commands (use typedFunctionReferenceinstead) - 72 unreferenced exports (audit: public API surface vs dead code)
- 81 untested public exports (priority:
createStandardAgent, model registry, streaming utils) - ~50 silent catch blocks (add structured debug logging)
Live Test Deployments
hallowed-stork-858— main test project at/tmp/af-npm-test/test-proj- Use
agentforge statusto check connection
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

