<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Herbert Tzekian</title>
    <description>The latest articles on DEV Community by Herbert Tzekian (@herbze).</description>
    <link>https://dev.to/herbze</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3994159%2Fbc81abd7-7e30-4076-9943-74ac34dc700a.png</url>
      <title>DEV Community: Herbert Tzekian</title>
      <link>https://dev.to/herbze</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/herbze"/>
    <language>en</language>
    <item>
      <title>Agent Identity Is Two Different Problems</title>
      <dc:creator>Herbert Tzekian</dc:creator>
      <pubDate>Wed, 25 Nov 2026 18:55:13 +0000</pubDate>
      <link>https://dev.to/herbze/agent-identity-is-two-different-problems-1onj</link>
      <guid>https://dev.to/herbze/agent-identity-is-two-different-problems-1onj</guid>
      <description>&lt;p&gt;Enterprise identity already has a solid playbook for an agent acting like an employee: bind it to the directory, assign a human owner, attach policy, mint short-lived tokens, and kill access when the person leaves. Okta, Microsoft, and a wave of newer vendors built this stack. Inside the firewall, it works.&lt;/p&gt;

&lt;p&gt;Then the agent walks out the front door.&lt;/p&gt;

&lt;p&gt;The moment an agent hits a public SaaS signup page, that entire stack breaks. Your product isn't in the agent's directory. The agent isn't on your payroll. The account doesn't exist yet, and the Terms of Service belong to a company that has never heard of the user's IdP.&lt;/p&gt;

&lt;p&gt;Right now, the market calls both of these "agent identity." That's a mistake. They have different buyers, different trust boundaries, and completely different failure modes. Treating them as one category leads to architectures that look great on a whiteboard and software purchases that solve the wrong half of the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same buzzword, two different events
&lt;/h2&gt;

&lt;p&gt;Start inside the org, where the patterns are mature. An employee tells a coding agent to fix a bug. The agent reads a Jira ticket, hits an internal MCP server, queries a warehouse table, and opens a PR. Here, the security questions all point back to the employee: who kicked off this run, what is it allowed to touch, what got logged, and what happens to its tokens when that engineer quits? The buyers are IT and Security. The failure mode is an over-privileged agent—or a ghost process that survives offboarding because nobody owned it.&lt;/p&gt;

&lt;p&gt;Now look at the PLG funnel. An agent lands on your public signup page on behalf of a user you've never met. It parses your docs, fills out the form, waits for a verification email, clicks accept on your terms, and requests an API key.&lt;/p&gt;

&lt;p&gt;For a growth or platform engineer, the questions flip completely: Is there a real, reachable human behind this? Which version of our terms did they actually agree to? Where does the verification email go? Who holds the credential after signup? And how do we rate-limit or kill one rogue agent without nuking the entire customer account?&lt;/p&gt;

&lt;p&gt;The buyer here isn't corporate IT—it's a founder, growth lead, or platform engineer trying to open up self-serve acquisition to agents without turning their product into an abuse magnet.&lt;/p&gt;

&lt;p&gt;Same buzzword, different event. Let's call the first &lt;strong&gt;workforce agent identity&lt;/strong&gt; and the second &lt;strong&gt;customer agent identity&lt;/strong&gt;. Boring labels, maybe, but they stop teams from talking past each other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inside the perimeter, the directory is the anchor
&lt;/h2&gt;

&lt;p&gt;Workforce identity works because the company already controls the two things a directory needs: the humans and the resources. Because the agent acts as a delegate of a known employee, the IdP has an anchor for ownership, a place to attach policy, an active SSO session, and an audit trail tied to a real person. Security teams file this under "non-human identity," which is technically true and practically misleading. The identity is non-human; the accountability isn't.&lt;/p&gt;

&lt;p&gt;Microsoft's &lt;a href="https://learn.microsoft.com/en-us/entra/agent-id/what-is-microsoft-entra-agent-id" rel="noopener noreferrer"&gt;Entra Agent ID&lt;/a&gt; treats the agent as a service principal with a blueprint, an owner, and Conditional Access. &lt;a href="https://www.okta.com/newsroom/press-releases/okta-brings-first-class-identity-to-ai-agents-with-agent-sso/" rel="noopener noreferrer"&gt;Okta's agent SSO&lt;/a&gt; drops agents into the Universal Directory and issues short-lived tokens. Speakeasy scopes agents to an org with a single human owner and enforces task-level credentials at an MCP gateway. Cross App Access (XAA) standardizes how an enterprise IdP authorizes an agent to hit a resource app.&lt;/p&gt;

&lt;p&gt;The plumbing varies, but the core assumption is identical: the human, the agent, and the resource all live inside a perimeter the organization controls. That's why the model works—and why it stops dead at the edge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why your IAM stack can't open a self-serve account
&lt;/h2&gt;

&lt;p&gt;A public signup breaks every assumption in that stack at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No pre-existing trust:&lt;/strong&gt; Your SaaS isn't in the agent's directory, so the IdP has nowhere to assert identity. Even if you support SAML or OIDC, enterprise federation assumes a contract, an admin, and an existing tenant. Self-serve has none of those.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No HR trigger:&lt;/strong&gt; The agent isn't your employee. There's no seat to assign and no HR offboarding event to trigger a deprovision webhook.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing to attach policy to:&lt;/strong&gt; Until the signup completes, the account doesn't exist. You can't bind an IAM policy to a record you haven't created yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unowned legal terms:&lt;/strong&gt; An enterprise IdP can certify that an employee is allowed to run an agent. It cannot certify that the employee agreed to your specific Terms of Service or DPA.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get around this, developers hack together "borrowed authority." The agent hijacks a human's active browser session. Verification codes route to a shared inbox. API keys get copy-pasted straight into system prompts. A headless script clicks "I Agree" on the terms, leaving a screenshot as the only audit log. Every workaround gets the agent through the funnel, and every one of them leaves you blind to who actually owns the account.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't buy a signup broker to solve an IAM problem
&lt;/h2&gt;

&lt;p&gt;The confusion cuts both ways. A customer-signup broker is not an IAM suite, and it shouldn't pretend to be one.&lt;/p&gt;

&lt;p&gt;A tool that verifies a human owner and logs accepted terms does one narrow job at your front door. It doesn't manage your workforce, secure your internal MCP servers, or enforce service-to-service policies. It won't give your employees SSO, check device posture, or kill a rogue session inside your VPC. If your problem is an agent with too much access to internal prod databases, a signup broker won't save you. Buy a directory product.&lt;/p&gt;

&lt;p&gt;Conversely, directory products shouldn't try to become public signup protocols. The two worlds touch, but they don't merge. Keeping them separate is how each stays honest about what it actually verifies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The handoff is two records, not one mega-protocol
&lt;/h2&gt;

&lt;p&gt;The most interesting edge case crosses the boundary: an employee's agent leaves the corporate network and signs up for an external SaaS tool. Both layers are in play, and neither can do the other's job.&lt;/p&gt;

&lt;p&gt;The employer's IAM knows which employee spun up the agent, what it was allowed to do internally, and when that employee's badge stops working. The SaaS vendor needs a completely different record: which human owns this new customer account, what terms were accepted, and which agent holds the API key. A brokered signup handles that second record, but it has zero visibility into what the agent does once it brings that API key back inside the company.&lt;/p&gt;

&lt;p&gt;Making this handoff work doesn't require deep vendor integrations. It just requires two distinct records maintained by different keepers. The employer holds the employment and policy record; the SaaS vendor holds the customer account and credential. If the employee leaves, the employer cuts internal access, and someone still has to close or transfer the external SaaS account. That gap is an operational policy problem, not a protocol bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 2x2 for agent identity
&lt;/h2&gt;

&lt;p&gt;If you want to cut through vendor pitches, map everything against two axes: where the trust boundary sits, and whether the account already exists. Everything else is implementation detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inside the trust boundary&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Account already exists — Workforce IAM for agents&lt;/strong&gt; &lt;em&gt;(Okta Agent SSO, Entra Agent ID, Speakeasy, XAA)&lt;/em&gt;: Proves the agent is a directory-bound principal with a named owner, policy, short-lived tokens, and an employee audit trail. You already govern the target app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No account yet — New workload principal&lt;/strong&gt; &lt;em&gt;(SPIFFE/SPIRE, cloud workload IAM)&lt;/em&gt;: Proves the workload belongs to your trust domain and holds a credential you minted. Creates zero customer relationship or legal terms record.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Outside the trust boundary&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Account already exists — Delegated access to a customer account&lt;/strong&gt; &lt;em&gt;(OAuth 2.1 and OIDC with scopes)&lt;/em&gt;: Proves a human granted this client scoped access to an existing account. Revoking the grant kills the token, not the underlying account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No account yet — Customer signup &amp;amp; claim-later flows&lt;/strong&gt; &lt;em&gt;(auth.md, AgentID, Agent Identity Protocol, Neon Claimable, Stripe Projects)&lt;/em&gt;: Proves an account can be provisioned headlessly. How much you learn about the human owner and accepted terms depends entirely on the flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Categories bleed together in production, and the tools listed are examples, not a buying guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solving the self-serve front door
&lt;/h2&gt;

&lt;p&gt;The bottom-right quadrant—outside the boundary, no account yet—is where things get messy. Spinning up a new customer account requires a verifiable owner and a legal terms record, not just a keypair. "Claim-later" flows (like Neon Claimable) work great for ephemeral sandboxes a human might adopt later, but they fall short when an agent needs a real, production account from minute one.&lt;/p&gt;

&lt;p&gt;One clean pattern for &lt;a href="https://agentregistrar.dev/topics/agentic-signup" rel="noopener noreferrer"&gt;brokered signup at the customer front door&lt;/a&gt; is Agent Registrar. The SaaS provider publishes a small discovery file, verifies a short-lived signed assertion against the broker's public keys, and provisions the account natively in its own database. Meanwhile, the broker hashes the exact bytes of the Terms of Service the agent accepted and emails a receipt to the human owner.&lt;/p&gt;

&lt;p&gt;It isn't an enterprise IAM suite, it isn't KYC, and it doesn't replace OAuth. Email verification isn't a passport check, revocation happens broker-side without deleting the vendor's account, and the SaaS provider still owns rate limits, abuse prevention, and billing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five questions for your next vendor demo
&lt;/h2&gt;

&lt;p&gt;Vendors on both sides of the fence are using the exact same vocabulary right now. Ask these five questions to force them to pick a lane:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Who is the accountable human, and what artifact proves it?&lt;/strong&gt; A directory owner, a verified email, and a claim code carry completely different weight when fraud or legal comes knocking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What are you actually verifying?&lt;/strong&gt; Directory membership, a cryptographic assertion, an inbox, and a credit card are not interchangeable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where does the credential live post-signup?&lt;/strong&gt; In our database, in the broker's vault, or plaintext in the agent's config? Whoever holds it controls the blast radius.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What does "revocation" actually execute?&lt;/strong&gt; Does it kill an active session, block future assertions, suspend the account, or do nothing? Get the exact state change in writing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do we keep full control of our signup flow?&lt;/strong&gt; If adopting their standard means giving up our onboarding UX, pricing tiers, or user database, that's a platform lock-in decision wearing an identity badge.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On your next call, ask the vendor which half of the problem their product &lt;em&gt;doesn't&lt;/em&gt; touch. Then ask them straight up: which side of the front door are you actually selling me?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>saas</category>
    </item>
    <item>
      <title>Your Free Tier Wasn't Built for AI Agents</title>
      <dc:creator>Herbert Tzekian</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:51:15 +0000</pubDate>
      <link>https://dev.to/herbze/your-free-tier-wasnt-built-for-ai-agents-1dgj</link>
      <guid>https://dev.to/herbze/your-free-tier-wasnt-built-for-ai-agents-1dgj</guid>
      <description>&lt;p&gt;A free tier is a loan with no credit check. You hand out storage, API calls, or compute before knowing if an account will ever pay you back.&lt;/p&gt;

&lt;p&gt;For years, the loan application was a standard signup form: an email, a CAPTCHA, maybe a credit card. Each field acted as a proxy for risk. In traditional product-led growth (PLG), those proxies held up because creating and using an account cost roughly one unit of human attention.&lt;/p&gt;

&lt;p&gt;AI agents break that unit economics equation.&lt;/p&gt;

&lt;p&gt;Most agents aren't attackers. They're doing exactly what a developer asked: spin up a sandbox, run a job, close the tab. But they can read email, they act on behalf of a real buyer, and one engineer can spin up fifty of them before lunch.&lt;/p&gt;

&lt;p&gt;Suddenly, the free-tier question isn't "human or bot?" It’s three operational questions: Who is accountable? What is the quota unit? And how fast can you cut off a single actor?&lt;/p&gt;

&lt;p&gt;Answering those changes your signup form, your quotas, your alerts, and your revocation path.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the old signup form was actually buying
&lt;/h2&gt;

&lt;p&gt;In a human-only PLG funnel, every field on the signup form had a specific job:&lt;/p&gt;

&lt;p&gt;⚬ An email address bought a channel for receipts and password resets, plus a weak uniqueness check. It never proved a person was real—a throwaway inbox passed it, and a shared team inbox passed it even better.&lt;br&gt;
⚬ A CAPTCHA bought proof that a human was sitting at a browser at that exact second. It raised the cost of crude scripts, though it never tied that human to the account's future behavior.&lt;br&gt;
⚬ A credit card bought friction against bulk creation and a direct payment rail, at the steep conversion cost of filtering out developers who just wanted to test your API first.&lt;br&gt;
⚬ Manual review supplied human judgment, at a cost that completely breaks self-serve margins.&lt;/p&gt;

&lt;p&gt;None of these controls answered the question that actually matters when a free account starts burning compute: Who is answerable for this usage, and how do I stop it without collateral damage? They only policed the moment of creation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why agents break the PLG model
&lt;/h2&gt;

&lt;p&gt;An agent can complete an email verification loop using its own inbox or an OTP code forwarded by its human. To your auth service, that looks like a verified user. In reality, it proves control of an inbox, not accountability for the bill.&lt;/p&gt;

&lt;p&gt;More importantly, an agent can be your highest-intent buyer. A platform team sending an agent to evaluate your sandbox isn't a fraud ring. If your WAF blocks that agent, you just churned an enterprise deal before it entered your funnel. Security teams often miss this because they treat agents purely as a risk surface. As growth engineers, we have to treat them as a customer segment with different controls.&lt;/p&gt;

&lt;p&gt;The bot filter is the wrong layer.&lt;/p&gt;

&lt;p&gt;In the old model, one account equaled one actor. Now, one human runs many agents, and one agent can spawn many accounts. The cost shows up in the aggregate. A better bot detector won't give you a record of who is accountable, nor will it give you a way to stop one runaway process without nuking the entire customer org.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three shapes of free-tier agent abuse
&lt;/h2&gt;

&lt;p&gt;Agent abuse in self-serve SaaS usually takes one of three shapes. They overlap, but each breaks a different traditional control:&lt;/p&gt;

&lt;p&gt;⚬ One agent, many accounts: An agent loops through your signup endpoint, rotates email aliases, and provisions multiple free tiers under the same owner. Per-IP rate limits catch lazy scripts, but miss agents running in cloud environments with rotating egress. The fix: Account resolution keyed to an agent identity, paired with a strict per-owner limit on active free workspaces. Route excess requests to a review queue, not a CAPTCHA.&lt;br&gt;
⚬ Many agents, one owner: A team runs ten agents in parallel. Each stays neatly under your per-account limit, so every dashboard looks like healthy PLG adoption—while the aggregate blows right through your COGS envelope. The fix: Owner-level quotas, an owner-level spend cap, and telemetry that rolls usage up to the parent entity.&lt;br&gt;
⚬ The compromised or runaway agent: A credential leaks, a retry loop goes infinite, or an agent hallucinates a bad tool call and provisions 500 databases. The owner is legitimate; the behavior isn't. Account-wide suspension is too coarse—it punishes the human and breaks every other healthy agent they run. The fix: Short-lived, per-agent credentials, hard resource caps, and a kill switch that isolates one agent instantly.&lt;/p&gt;

&lt;p&gt;Most teams ship one control and call it a policy. A CAPTCHA helps with the first shape. A per-owner quota catches the second. A kill switch stops the third. None of them covers the other two.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the primitives compose
&lt;/h2&gt;

&lt;p&gt;To support agent-led growth without bleeding infrastructure budget, you need five primitives working as a stack:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Per-agent identity: Give every agent a stable ID and its own credential. Without this, every agent is just "the human's session," and you can't revoke one without breaking the others.&lt;/li&gt;
&lt;li&gt;A verified owner: Email OTP is the floor, not identity proofing. If your free tier gives away expensive compute or egress, raise assurance before raising limits—require a verified company domain or a payment method. "Verified email" and "verified business" are completely different claims.&lt;/li&gt;
&lt;li&gt;Owner-level hard caps: Count active agents and total consumption at the owner level. Put a hard stop on your most expensive unit (GPU minutes, tokens, storage). Alert at 80% and cut off at 100%. A soft warning with no enforcement isn't a control; it's just observability.&lt;/li&gt;
&lt;li&gt;Delayed privilege: Start every new actor in a constrained sandbox. Unlock higher quotas after an ownership claim, a payment method, or a clean usage history. Abuse becomes unprofitable when an attacker has to keep minting new verified owners.&lt;/li&gt;
&lt;li&gt;Fast revocation &amp;amp; audit trails: Write down what your kill switch actually does. Does it block new signups, invalidate the agent's token, or tear down active resources? Who can pull it at 2:00 AM? If the only way to stop an agent is a support ticket, you don't have a control—you have a promise. Pair this with a clear terms record (which human delegated which agent, and a hash of the terms accepted) and a monitored abuse@ contact with an actual SLA.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Building per-agent discovery, sub-identities, delegation records, and kill switches from scratch is heavy lifting, though you don't have to invent the plumbing yourself:&lt;/p&gt;

&lt;p&gt;Open registration protocols: Instead of forcing agents through a browser signup form, you can publish a machine-readable manifest, such as &lt;a href="https://workos.com/auth-md" rel="noopener noreferrer"&gt;WorkOS's auth.md protocol&lt;/a&gt; or support the open &lt;a href="https://github.com/agentregistrar/spec" rel="noopener noreferrer"&gt;Agent Identity Protocol&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hosted identity brokers: If you want to offload sub-identity issuance and delegation records, a broker like &lt;a href="https://agentregistrar.dev" rel="noopener noreferrer"&gt;Agent Registrar&lt;/a&gt; (built on the Agent Identity Protocol) gives each agent a distinct sub-identity under a verified human owner, signs the accepted terms into an assertion you verify locally, and exposes a per-agent kill switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four anti-patterns to avoid
&lt;/h2&gt;

&lt;p&gt;⚬ Blanket blocking: The tempting first move, and a classic growth killer. You'll block the platform team evaluating your tool, and you'll train developers to hand their browser cookies over to their agents—making legitimate and automated traffic completely indistinguishable.&lt;br&gt;
⚬ Silent shadowbanning: Dropping requests without telling the owner why leaves no audit trail, poisons your funnel metrics by hiding false positives, and gives legitimate users zero path to appeal. If you wouldn't put the reason in a support reply, don't put it in a background job.&lt;br&gt;
⚬ CAPTCHA arms races: Treating a policy problem like a detection problem. An agent that solves a CAPTCHA is just good at browser automation; it tells you nothing about who owns the bill. Meanwhile, you're taxing every human developer in your funnel with extra friction.&lt;br&gt;
⚬ "We'll just monitor it": Watching is not a control. If stopping a runaway agent requires a Slack thread and a manual database update, your mean time to stop is already too slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  A sample policy ladder for a freemium dev tool
&lt;/h2&gt;

&lt;p&gt;The cleanest way to balance PLG velocity with risk is a tiered policy ladder, where each rung upgrades identity, quota, stop path, and audit record together:&lt;/p&gt;

&lt;h2&gt;
  
  
  A sample policy ladder for a freemium dev tool
&lt;/h2&gt;

&lt;p&gt;The cleanest way to balance PLG velocity with risk is a tiered policy ladder, where each rung upgrades identity, quota, stop path, and audit record together:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Anonymous Sandbox
Identity &amp;amp; assurance: Unverified agent; no human attached yet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Quota &amp;amp; limits: One short-lived sandbox with hard resource caps (for example, Neon's claimable projects expire after 72 hours with 100 MB storage and 1 GB transfer limits).&lt;/p&gt;

&lt;p&gt;Stop path: Automatic TTL expiry.&lt;/p&gt;

&lt;p&gt;Audit record: Creation event and any presented agent ID.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Claimed Account
Identity &amp;amp; assurance: A human claims the sandbox via email OTP; the agent becomes a sub-identity rather than forking a second account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Quota &amp;amp; limits: Rolled up to the owner—a small cap on active sandboxes with slightly higher compute limits.&lt;/p&gt;

&lt;p&gt;Stop path: Per-agent token revocation, leaving the human's other agents running.&lt;/p&gt;

&lt;p&gt;Audit record: Owner ID, accepted terms URL and hash, and claim timestamp.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Verified Owner
Identity &amp;amp; assurance: Domain verification or a credit card on file.
Quota &amp;amp; limits: Multiple agents allowed under a shared, higher owner-level spend cap.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Stop path: Per-agent kill switch, plus owner-level suspension if abuse is systemic.&lt;/p&gt;

&lt;p&gt;Audit record: Delegation chain, terms version, and a monitored abuse contact.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Paid Tier
Identity &amp;amp; assurance: Executed contract and active billing. Agent identities stay separate because the buyer signing the contract is rarely the engineer debugging an agent at midnight.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Quota &amp;amp; limits: Plan-based quotas and contractual overages.&lt;/p&gt;

&lt;p&gt;Stop path: The same per-agent revocation path for fast incident response.&lt;/p&gt;

&lt;p&gt;Audit record: Full contract, terms, and enterprise audit trail.&lt;br&gt;
You can stop at Rung 2 if your unit costs are cheap—just never hand out expensive compute on Rung 1. Every rung simply trades a bit of onboarding friction for stronger accountability.&lt;/p&gt;

&lt;p&gt;Before you touch your signup form, make one architectural decision: What is the core unit of your free tier? An account, an agent, or an owner?&lt;/p&gt;

&lt;p&gt;That single choice dictates your database schema, your quota enforcement, and your revocation path. Once you pick it, write down the fastest way to shut off one unit. If the answer involves a support ticket and a production SQL console, you aren't ready to welcome AI agents to your free tier. If it's an API call that kills one rogue agent without waking up the human who owns it, you have a growth model you can actually defend.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>saas</category>
      <category>agents</category>
      <category>mcp</category>
    </item>
    <item>
      <title>When pandas runs out of RAM, I change one import line</title>
      <dc:creator>Herbert Tzekian</dc:creator>
      <pubDate>Wed, 24 Jun 2026 15:01:00 +0000</pubDate>
      <link>https://dev.to/herbze/when-pandas-runs-out-of-ram-i-change-one-import-line-35k0</link>
      <guid>https://dev.to/herbze/when-pandas-runs-out-of-ram-i-change-one-import-line-35k0</guid>
      <description>&lt;p&gt;You know the moment. You've got a Parquet file or a fat CSV, you write the obvious &lt;code&gt;pd.read_parquet(...)&lt;/code&gt;, and Python sits there. Then either it finishes in its own sweet time, or you get the message everyone who's done data work in Python has seen at least once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MemoryError: Unable to allocate ... for an array
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file is bigger than your RAM, pandas wants the whole thing in memory at once, and your laptop says no.&lt;/p&gt;

&lt;p&gt;I used to solve this by chunking, or by giving up and rewriting the whole notebook in SQL against some database just to run one &lt;code&gt;GROUP BY&lt;/code&gt;. Both are annoying, and the second one means I now maintain two versions of the same analysis. What I do now is change one import line and keep writing the exact same pandas I already had. No server, no connection string, and crucially no SQL, because I never leave the DataFrame API.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-line change
&lt;/h2&gt;

&lt;p&gt;The library is &lt;strong&gt;chDB&lt;/strong&gt;. It's ClickHouse compiled as an in-process engine you &lt;code&gt;pip install&lt;/code&gt;, basically the ClickHouse query engine as a Python library, with nothing to run in Docker and nothing to connect to. If you want the internals, it's &lt;a href="https://clickhouse.com/resources/engineering/what-is-chdb" rel="noopener noreferrer"&gt;ClickHouse compiled as an in-process engine&lt;/a&gt;, but the part that changed my day-to-day is its &lt;code&gt;datastore&lt;/code&gt; module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;chdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Change this:
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="c1"&gt;# To this:
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;chdb.datastore&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="c1"&gt;# Everything else stays the same.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Your existing pandas code keeps working, with the same method names, the same arguments, and the same DataFrames coming back. The one thing that changes is how you point at a file too big to open: instead of &lt;code&gt;pd.read_parquet&lt;/code&gt;, you hand the file to a &lt;code&gt;DataStore&lt;/code&gt;, which streams it instead of loading it whole. From there it's the pandas API you already know. The difference underneath is that operations are lazy and compile down to the ClickHouse engine, so nothing executes until you actually need a result (a &lt;code&gt;print()&lt;/code&gt;, a &lt;code&gt;len()&lt;/code&gt;, plotting). The giant file never gets slurped into RAM in one go.&lt;/p&gt;

&lt;h2&gt;
  
  
  The query I'd otherwise have crashed on
&lt;/h2&gt;

&lt;p&gt;Here's a real example. Events Parquet, I want the top user actions in the last 30 days. This is the textbook &lt;code&gt;read_parquet&lt;/code&gt; (boom) followed by a filter and a groupby. Written as plain pandas, except it doesn't fall over:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;chdb.datastore&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;events.parquet&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;event_date&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2026-05-21&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;top&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recent&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;action&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;size&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ascending&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the same code I'd have written against pandas. I didn't drop into SQL, I didn't chunk anything, I didn't think about memory. Because it's lazy and columnar underneath, reading three columns out of forty doesn't pay for the other thirty-seven, and the filter gets pushed down into the file scan so rows I don't want never get decoded. That's the difference between "loads 12 GB" and "reads the slice you asked for."&lt;/p&gt;

&lt;h2&gt;
  
  
  It's the same pandas all the way through
&lt;/h2&gt;

&lt;p&gt;You don't get a cut-down subset that handles &lt;code&gt;groupby&lt;/code&gt; and bails on everything else. The whole DataFrame API is here: filtering, column selection, computed columns, the string and datetime accessors, joins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;chdb.datastore&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="n"&gt;reqs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;requests.parquet&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;reqs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hour&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;reqs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;h&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;# datetime accessor, computed column
&lt;/span&gt;&lt;span class="n"&gt;hourly&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reqs&lt;/span&gt;
          &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hour&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;latency_ms&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
          &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
          &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_index&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="n"&gt;hourly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;   &lt;span class="c1"&gt;# tiny result now, plots like any pandas Series
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The big file got crunched down to a few hundred rows before anything had to fit in memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Joining across files (and databases) without leaving pandas
&lt;/h2&gt;

&lt;p&gt;The bit I didn't expect to use as much as I do: the same DataFrame can be backed by a file &lt;em&gt;or&lt;/em&gt; a remote source, and you join them with a normal &lt;code&gt;.join()&lt;/code&gt;. So a Parquet file on disk and a table in Postgres or MySQL line up in one expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;chdb.datastore&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;orders.parquet&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mysql://root:pass@db:3306/crm/customers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;by_country&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orders&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left_on&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customer_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right_on&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;country&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;amount&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
              &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ascending&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;by_country&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also reads CSV, TSV, JSON and friends the same way, so the &lt;a href="https://clickhouse.com/resources/engineering/read-csv-file-python" rel="noopener noreferrer"&gt;same approach works for a giant CSV&lt;/a&gt; you'd otherwise be afraid to open, and for &lt;a href="https://clickhouse.com/resources/engineering/how-to-query-parquet-file" rel="noopener noreferrer"&gt;Parquet&lt;/a&gt; as shown above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this became my default
&lt;/h2&gt;

&lt;p&gt;The honest reason I keep using it isn't the speed, though it is faster. It's that I stopped maintaining two versions of my analysis.&lt;/p&gt;

&lt;p&gt;Before, a notebook experiment used pandas, and then if it needed to run for real on the full dataset it got rewritten into SQL, against some warehouse, with a different dialect and a deployment story. With &lt;code&gt;chdb.datastore&lt;/code&gt; the exploration code &lt;em&gt;is&lt;/em&gt; the production code. It's pandas while I'm poking at a file on my laptop, and it's still pandas when the file is too big to open the normal way. I scale up by changing what the DataFrame points at, not by rewriting it.&lt;/p&gt;

&lt;p&gt;So my rule of thumb now: if a file is small and friendly, sure, regular pandas is fine. The second it's big enough to make Python sweat, I swap the import line. The code doesn't change, it doesn't run out of RAM, and the throwaway version turns out not to be throwaway.&lt;/p&gt;

&lt;p&gt;Next time you hit &lt;code&gt;MemoryError&lt;/code&gt;, try changing &lt;code&gt;import pandas as pd&lt;/code&gt; to &lt;code&gt;import chdb.datastore as pd&lt;/code&gt; and rerun the cell. Usually that's the whole fix.&lt;/p&gt;

</description>
      <category>database</category>
      <category>python</category>
    </item>
    <item>
      <title>I stopped writing throwaway scripts for messy CSVs and just use SQL now</title>
      <dc:creator>Herbert Tzekian</dc:creator>
      <pubDate>Sat, 20 Jun 2026 13:41:23 +0000</pubDate>
      <link>https://dev.to/herbze/i-stopped-writing-throwaway-scripts-for-messy-csvs-and-just-use-sql-now-p6h</link>
      <guid>https://dev.to/herbze/i-stopped-writing-throwaway-scripts-for-messy-csvs-and-just-use-sql-now-p6h</guid>
      <description>&lt;p&gt;Someone sends you a CSV. Then a folder of CSVs. Then a CSV that's actually tab-separated but named &lt;code&gt;.csv&lt;/code&gt;, with a stray header row and a column that's a number on most rows and the string &lt;code&gt;N/A&lt;/code&gt; on the rest.&lt;/p&gt;

&lt;p&gt;For years my answer to "can you pull a quick number out of this?" was a throwaway Python script. Read it in, fight pandas about dtypes, &lt;code&gt;groupby&lt;/code&gt;, print, delete the script, forget everything, repeat next week. It worked. It was also slow and I never kept any of it.&lt;/p&gt;

&lt;p&gt;These days I just point SQL at the file. I want to show you the exact workflow because it's embarrassingly simple and it's saved me a lot of evenings.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one binary I actually use
&lt;/h2&gt;

&lt;p&gt;The tool is &lt;a href="https://clickhouse.com/resources/engineering/what-is-clickhouse-local" rel="noopener noreferrer"&gt;&lt;code&gt;clickhouse-local&lt;/code&gt;&lt;/a&gt;. It's a single binary, the ClickHouse engine minus the server. You download it and run SQL against files on your disk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://clickhouse.com/ | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That gives you a &lt;code&gt;clickhouse&lt;/code&gt; binary in the current directory. Now you can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./clickhouse &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"SELECT count() FROM file('orders.csv')"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. It read the file, sniffed the format and the column types, and counted the rows. No setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Querying the thing like it's a table
&lt;/h2&gt;

&lt;p&gt;Say I've got &lt;code&gt;orders.csv&lt;/code&gt; and I want revenue by country, top 10. Normally that's a few lines of pandas. Here it's the query you'd write anyway:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./clickhouse &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"
  SELECT country, round(sum(amount), 2) AS revenue
  FROM file('orders.csv')
  GROUP BY country
  ORDER BY revenue DESC
  LIMIT 10
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;file()&lt;/code&gt; function is the whole trick. It &lt;a href="https://clickhouse.com/resources/engineering/run-sql-on-csv-file" rel="noopener noreferrer"&gt;reads the file and gives you something you can &lt;code&gt;SELECT&lt;/code&gt; from&lt;/a&gt;. It auto-detects CSV, TSV, JSON, Parquet and a pile of others from the extension and contents, and it infers column names and types from the header and the data. The example above is honestly 90% of what you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the file is "somebody else's CSV"
&lt;/h2&gt;

&lt;p&gt;Real files are messy, so here's where this stops being a toy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's actually tab-separated.&lt;/strong&gt; Override the format instead of renaming the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./clickhouse &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM file('weird.csv', 'TSV') LIMIT 5"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A column has &lt;code&gt;N/A&lt;/code&gt; mixed in with numbers.&lt;/strong&gt; Read it as text and clean it inline, no preprocessing pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;avg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toFloat64OrNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_amount&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'orders.csv'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;toFloat64OrNull&lt;/code&gt; turns the junk into &lt;code&gt;NULL&lt;/code&gt; instead of blowing up, and &lt;code&gt;avg&lt;/code&gt; skips nulls. I use the &lt;code&gt;*OrNull&lt;/code&gt; and &lt;code&gt;*OrZero&lt;/code&gt; functions constantly for this exact reason.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A whole folder of files.&lt;/strong&gt; Glob them and query all at once, still one query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./clickhouse &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"
  SELECT _file, count()
  FROM file('exports/*.csv')
  GROUP BY _file
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;_file&lt;/code&gt; is a virtual column telling you which file each row came from. Great for "which of these 40 exports is missing data."&lt;/p&gt;

&lt;h2&gt;
  
  
  Turn the slow file into a fast file
&lt;/h2&gt;

&lt;p&gt;If I'm going to keep poking at the same CSV, the first thing I do is &lt;a href="https://clickhouse.com/resources/engineering/convert-csv-to-parquet" rel="noopener noreferrer"&gt;convert it to Parquet&lt;/a&gt; once. Columnar, compressed, types baked in, so every query after that is faster and smaller on disk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./clickhouse &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"
  SELECT * FROM file('orders.csv')
  INTO OUTFILE 'orders.parquet'
  FORMAT Parquet
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then query &lt;code&gt;orders.parquet&lt;/code&gt; from then on. This one habit alone made my repeated ad-hoc queries feel instant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I stuck with this one
&lt;/h2&gt;

&lt;p&gt;Two reasons, and the second is the one that surprised me.&lt;/p&gt;

&lt;p&gt;First, the obvious one: it's fast and there's no ceremony. A multi-GB CSV that made my old pandas script swap is a sub-second &lt;code&gt;GROUP BY&lt;/code&gt; here, because the engine is columnar and uses all my cores without me asking.&lt;/p&gt;

&lt;p&gt;Second, and this is why I didn't just bounce to the next shiny CLI tool, it's &lt;em&gt;the same SQL and the same engine&lt;/em&gt; whether the data is a 5 MB CSV on my laptop or billions of rows in a real ClickHouse cluster. When a "quick look at a file" turns into "okay we actually need to run this every hour over a year of data," I'm not rewriting anything. Same &lt;code&gt;file()&lt;/code&gt;, same functions, same query, it just moves to a server and keeps going. I've been burned before by prototyping in one tool and then re-implementing everything for production. Not having to do that is worth a lot.&lt;/p&gt;

&lt;p&gt;So now the answer to "can you pull a number out of this?" is thirty seconds and a SQL query, and if it turns out to matter, the thirty-second version is already the production version.&lt;/p&gt;

&lt;p&gt;Give the messy-CSV thing a try next time one lands in your inbox. You'll stop writing the throwaway script too.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
  </channel>
</rss>
