News for hackers. Stuff that matters.

Show HN: Pgclaw – A "Clawdbot" in every row with 400 lines of Postgres SQL

https://github.com/calebwin/pgclaw

Hi HN,

Been hacking on a simple way to run agents entirely inside of a Postgres database, "an agent per row".

Things you could build with this: * Your own agent orchestrator * A personal assistant with time travel * (more things I can't think of yet)

Not quite there yet but thought I'd share it in its current state.

( 34 comments | 37 points | on HN )
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by maxbond on Thursday February 12, 2026 @02:32PM (#46993841)
What's the advantage in putting agents in the persistence layer rather than the application layer? This seems to me strictly less flexible, scalable, secure, easy to work with... I am having a hard time imagining why I would want to integrate with APIs or write an agentic harness in the database rather than in application code?

Maybe I'm behind the times but I don't understand.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by 4ndrewl on Thursday February 12, 2026 @02:52PM (#46994129)
It's similar to when we wrote all our business logic in eg pl/sql, stored procedures etc. Seems attractive at first, but it breaks separation of concerns, becomes difficult to test etc.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by thatwasunusual on Thursday February 12, 2026 @04:00PM (#46995077)
> It's similar to when we wrote all our business logic in eg pl/sql [...]

What do you mean with "when"? /s

I dread companies who still have logic in their databases when it's not necessary. <insert sad face>

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by SOLAR_FIELDS on Thursday February 12, 2026 @09:45PM (#46998335)
The real fun begins when you encounter a system where someone thought it was a good idea to store source code in the database rows.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by tibbar on Thursday February 12, 2026 @01:58PM (#46993344)
This is mind-bending. I can't imagine that it performs well enough to be particularly fit for production just yet but..... wow.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by swyx on Thursday February 12, 2026 @02:39PM (#46993959)
how exactly is adding a stored procedure as an agent mind bending
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by tibbar on Thursday February 12, 2026 @03:42PM (#46994849)
I can only speak for my own mind ;) but the most advanced thing I'd seen prior in this regard was Google Sheets' =AI function, which is pretty convenient (if awkward) when you want to map values to LLM output.

What I specifically found "mind-bending" about this is that I don't have a clear concept of the limits of what an agent can do. In the limit case, it's basically like an independent employee, right?. So the concept of having a dedicated person sitting on each row of my database and transactionally performing any task I can describe is ... well, it IS a bit boggling to me.

Another way to look at it is: this is an extremely powerful construct for managing fleets of agents. I trust Postgres to execute all the stored procedures I ask it to. So with this tool I can easily spin up arbitrarily many agents. And state management is very simple, because they can directly edit their associated row!

IDK, the more I think about it the more fascinated I am. I'm sure there is some open source SAAS or something that has similar semantics and can do all this more efficiently, but now I know that this is a category of thing one could potentially build/use. Pretty nifty!

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by swyx on Thursday February 12, 2026 @04:09PM (#46995200)
ok nice reply. i think i was where you were in 2021 around doing stuff in sprocs. i think pple generally follow a cycle of going overexcited about throwing everything in the database and then going "actually the database is a pretty bad production compute environment" and re-separating concerns back to different levels.

use sprocs lightly for simple fast stateless things. every other attempt at stuffing a lot of compute into the database that i'm aware of has basically failed to gain adoption (the personal awesomeness/happiness of the guy who created it aside)

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by tibbar on Friday February 13, 2026 @10:06AM (#47003544)
Oh, like, I wouldn't actually use this specific implementation. I used to work at a shop with thousands of lines of Oracle triggers that you had to edit inline in the web browser with no version control and I shudder to think of returning again.

I'm more interested in the data flow. exa.ai got famous for promising search with massively parallel execution of LLMs on candidate results. In practice, it's never worked that well for me, but the model is very cool and has worked for me e.g. in open source work, searching for bugs across files.

Mapping N items to "N agents with state" feels like an absurdly powerful construct to me. Maybe this is just a well-known pattern that everyone has seen already, but given how much better agents have gotten in the past year, crossing the threshold from "toy" to "arguably superhuman" on many tasks, I think it just hits different.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by swyx on Friday February 13, 2026 @12:30PM (#47005281)
ok gotcha. yeah i guess my background with temporal.io got me used to "every workflow instance can have a shit ton of long running state that gets persisted and rehydrated at will". check those out if you like N:N+state, whether or not it includes agents is an impl detail
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by tibbar on Friday February 13, 2026 @04:37PM (#47008176)
Haha, I guess we see this in reverse: I see the specific framework as the implementation detail (I use, and enjoy, temporal!) I think it's the part about automatically launching a metric ton of agents that is (to use the term again) mind-bending to me.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by renato_shira on Thursday February 12, 2026 @05:26PM (#46996171)
the "agent per row" framing is what makes this click for me too. most agent frameworks think in terms of orchestration graphs or message queues, but modeling it as "each row has a little worker that can act on its own state" is a surprisingly intuitive primitive.

it also maps well to how a lot of real world problems actually work: you have N entities, each with their own context, and you want something watching each one independently. the traditional way to do that is a job queue polling the database, but if the database is the compute layer, you skip a whole class of sync/consistency problems.

probably not production ready for anything serious, but i've seen this pattern before where "weird" database experiments end up influencing real tools later. json columns were an antipattern until jsonb became a legitimate design choice. triggers were considered dangerous until supabase made realtime features out of them. the boundary keeps shifting.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by wwweston on Thursday February 12, 2026 @02:09PM (#46993514)
This... does not seem like separation of concerns.

Not to mention that the data layer seems like the one where you want to keep things most deterministic.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by noupdates on Thursday February 12, 2026 @02:34PM (#46993879)
To decouple this the person would have to broadcast nearly every event and rebuild the observer layers elsewhere.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by thatwasunusual on Thursday February 12, 2026 @04:05PM (#46995148)
And IMO that's what should be done.

Don't get me wrong, I like the idea and all that, but this is another pgsql "solution" that is tied to the database layer, when it should be in the application layer.

I like to be database agnostic, and while I prefer PostgreSQL on production, I prefer SQLite on the dev layer. You should never have to HAVE TO use a specific database to make your APPLICATION work.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by nkmnz on Thursday February 12, 2026 @04:22PM (#46995393)
You could replicate and separate your llm-postgres from the system-of-record-postgres.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by nkmnz on Thursday February 12, 2026 @04:21PM (#46995371)
If you really want to run an agent on each created row, you could run this in a replica and stream the replies back to your system of record.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by debugnik on Thursday February 12, 2026 @03:20PM (#46994550)
I don't understand why claw is a data type for columns in these examples, it doesn't seem to store any actual per-row state. Is it not possible to hook extensions onto "with" clauses or something similar?
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by xnx on Thursday February 12, 2026 @02:23PM (#46993716)
It feels like we're a week away from the Claw hype supplanting AI hype. Companies will start renaming things ClawX to get on the hype bandwagon.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by maxbond on Thursday February 12, 2026 @02:36PM (#46993908)
I think "claw" isn't appealing enough to be genericized and that "agent" will continue to be the generic term, but we'll see.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by calebhwin on Thursday February 12, 2026 @02:28PM (#46993777)
It's just an abstraction people are excited about at the moment. Langchain was an exciting abstraction at one point.

My bet is we converge on a super minimal model<>computer architecture.

Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by ef2k on Thursday February 12, 2026 @03:56PM (#46995041)
Nice. These are the kind of boundary pushing projects I like to see. It challenges assumptions of where application logic should live. The implications around cost, latency, and recovery are going to be interesting.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by rel_ic on Thursday February 12, 2026 @04:00PM (#46995083)
We need your help! Can you please use your creativity to build resilience to climate change in your community instead of experimenting with more ways to spend computing power?
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by brunoqc on Thursday February 12, 2026 @04:26PM (#46995440)
The solution is to tax the rich. But we won't.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by worldsavior on Thursday February 12, 2026 @06:30PM (#46996783)
Until YOU get rich.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by readme on Thursday February 12, 2026 @02:01PM (#46993389)
i love postgres and pgvector... this is exactly to my tastes
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by calebhwin on Thursday February 12, 2026 @02:07PM (#46993487)
Same, it's in a similar vein as pgvector - probably not as performant as turbopuffer or chroma but you get the benefits of being in a really nice ecosystem.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by tibbar on Thursday February 12, 2026 @02:10PM (#46993525)
Is it? pgvector is primarily about indexing, I think? This feels more similar =AI in Google Sheets.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by calebhwin on Thursday February 12, 2026 @02:26PM (#46993754)
True though pgvector is not deterministic in a strict sense since HNSW is probabilistic.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by cpursley on Thursday February 12, 2026 @03:36PM (#46994764)
Yes, and I imagine pgclaw would pair well with pgmq and pg_cron for scheduled work. Postgres really is enough: https://postgresisenough.dev
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by maxbond on Thursday February 12, 2026 @04:47PM (#46995722)
Interesting to hear you say that, I was thinking (but hadn't said) that using WalEx to dispatch to some workers where the agent lived would be a better solution. The worker would then update the row (or more likely insert a new one in a different table with more constraints/different columns). I would be curious to hear what advantage you see in a `claw` type/`agent` column? I can't make heads or tails of it but I regard you as knowing a lot more about Postgres than me.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by cpursley on Thursday February 12, 2026 @07:44PM (#46997436)
You could probably use listen/subscribe trigger to accomplish that.
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by danr4 on Thursday February 12, 2026 @02:17PM (#46993622)
this is fucking awesome
Re:Show HN: Pgclaw – A "Clawdbot" in every row with 400 line... by jmaw on Friday February 13, 2026 @11:42AM (#47004701)
What does it mean to put an agent inside of a PG DB? Is PG doing the actual computing/inference (does it tie to GPU), or is PG just storing the state of the agents neural net (is that a thing, it seems like it would be).

Maybe I'm strictly too stupid to even parse the concept, but I don't understand what I'm looking at one bit.