AI Coding Agents
Sp00ky ships first-class support for AI coding agents (Claude, Cursor, Windsurf, etc.). Drop an agent into a sp00ky-backed project and it learns the framework, your schema, and the safe edit loop without prompt engineering.
How it works
Three artifacts give an agent everything it needs:
AGENTS.md— a project-rooted guide tailored to your schema. Generated byspky agents init.- Per-package guides shipped inside
@spooky-sync/*tarballs. Always available vianode_modules/@spooky-sync/<pkg>/AGENTS.md. - A devtools MCP server that exposes the running app’s live state (active queries, schema, auth) and lets the agent execute SurrealQL against it.
Agents that follow the AGENTS.md convention discover the project guide automatically. Cursor’s .cursorrules, Claude Code’s CLAUDE.md, and Aider’s repo-level rules all read it as fallback.
Generate AGENTS.md
Run once per project:
This parses your .surql schema, finds every CRDT field and parent relationship, and writes an AGENTS.md at the project root with:
- The sp00ky mental model (schema → codegen → reactive hooks → SSP → SurrealDB)
- Your tables, marked with
@crdtand@parentannotations - Common gotchas (record-ID format,
useCrdtFieldvsuseQuery, debounced writes) - The agent feedback loop (
spky generate→spky doctor) - A list of available cookbook recipes
Re-run after schema changes to refresh the table list:
Per-package guides
Every @spooky-sync/* package ships an AGENTS.md documenting its public API surface. Once installed, an agent can enumerate them:
You’ll find guides for core (sync engine), client-solid (useDb, useQuery, useCrdtField), query-builder (DSL), cli (spky subcommands), devtools-mcp (live introspection), and ssp-wasm (browser stream processor).
Cookbook recipes
spky scaffold emits framework-level patterns parameterized by your schema. Run with no arguments to list available recipes:
Render a recipe to stdout:
Or write directly to a file:
Agents typically pipe spky scaffold output into a file edit, then the project’s AGENTS.md tells them to run spky doctor to verify the result.
Live introspection via MCP
The devtools MCP server gives agents direct access to a running sp00ky app’s local cache, active live queries, auth state, and event history — plus it can execute SurrealQL against either the local replica or the remote DB.
Wire it into your agent’s MCP configuration:
The server connects to the Sp00ky DevTools browser extension (when an app tab is open) or directly to a SurrealDB instance via SURREAL_URL / SURREAL_USER / SURREAL_PASS.
Tools an agent gets
| Tool | What it does |
|---|---|
describe_schema | Stitched schema view: tables, columns, types, plus @crdt / @parent annotations when the extension is connected |
lint_query | Validate SurrealQL without executing — runs EXPLAIN and reports parse errors with line/column |
run_query | Execute SurrealQL against local or remote |
list_tables, get_table_data | Read-only schema and data inspection |
update_table_row, delete_table_row | Direct mutations (bypass the local mutation queue) |
get_active_queries, get_events, get_auth_state | Inspect the running tab’s live state |
Mutations through MCP go straight to SurrealDB and don’t enter the local queue. Use them for fixtures and debugging; for in-app behavior, drive mutations through your UI.
Generated docs in schema.gen.ts
Every regenerated schema.gen.ts carries JSDoc on each table and column. Tables list their relationships and a useQuery example; columns marked @crdt get a “use useCrdtField and { debounced: true }” hint inline; @parent columns get a “auto-populated server-side, do not write” hint.
Both your IDE’s hover-docs and an agent’s read of the file pick this up automatically. Nothing to wire up.
The feedback loop
The standard pattern an agent should follow after any schema edit:
- Edit
schema.surql spky generate— refreshschema.gen.tsspky doctor --json— confirm nothing else drifted (codegen freshness, migration state, config validity)- Make code edits using the typed
schema.gen.ts - Re-run
spky doctorto double-check
AGENTS.md documents this loop verbatim so the agent doesn’t have to re-derive it.