Show HN: Pgclaw – A "Clawdbot" in every row with 400 lines of Postgres SQL
Pgclaw introduces a 'claw' data type to embed AI agents directly into PostgreSQL rows, enabling a novel 'agent per row' paradigm. This audacious blend of LLMs and relational databases has Hacker News buzzing with excitement over its cleverness, even as some question the architectural implications of non-deterministic AI logic residing within a database.
The Lowdown
Pgclaw is an open-source PostgreSQL extension that allows developers to instantiate AI agents directly within database rows. This innovative approach, dubbed 'a Clawdbot in every row,' treats an AI agent as a column type, enabling data and AI logic to reside intimately together, offering a new way to build intelligent applications.
- Integrated Agents: Introduces a
clawdata type to embed simple LLM or stateful 'OpenClaw' agents directly in Postgres rows. - Broad LLM Support: Leverages
rigto support a wide array of LLM providers including Anthropic, OpenAI, Ollama, Gemini, Groq, and more. - Claude Code Workspaces: Enables agents with
workspacefields to utilize Claude Code for file operations, code execution, and tool use within their own filesystem directories. - Stateful & Event-Driven: Supports defining reusable agents with identity, instructions, and memory, and allows for channels, sessions, and heartbeats for multi-turn interactions.
- Postgres Benefits: Offers ACID compliance, point-in-time recovery, JOINs, and database-native integration for agents.
The system works by having a Postgres trigger enqueue row changes into a claw.queue table when claw_watch() is enabled on a table with a claw column. A background worker then processes this queue, building prompts, calling LLMs (via rig) or spawning Claude Code (via claude-agent-sdk), and parsing responses to update the original row. Conversation history is maintained in claw.history.
Pgclaw pushes the boundaries of database functionality, merging transactional data with dynamic AI computation, potentially streamlining the development of data-driven intelligent systems.
The Gossip
Ecstatic Endorsement & Ingenious Integration
Many commenters expressed immediate awe and enthusiasm for the project, hailing it as 'mind-bending' and 'fucking awesome.' They appreciated the cleverness of integrating AI agents directly into the database, drawing parallels to other popular Postgres extensions like pgvector, and seeing it as a fresh, powerful abstraction for building intelligent applications.
Architectural Apprehensions & Abstraction Arguments
While many were impressed, some raised concerns about the architectural implications, particularly questioning the separation of concerns and the introduction of non-determinism into the database layer—a place traditionally valued for its deterministic nature. The author, in response, engaged with this by likening it to pgvector's probabilistic aspects and musing on the transient nature of 'hype' around new abstractions like Langchain, suggesting a future convergence on minimal model-computer architectures.