agent-self-funding

agent-self-funding is a skill for Claude Code, Codex from gblinproject/gblin-treasury-risk-regime. It costs 52 tokens per session (1,273 once invoked), scanned A, original, MIT.

A design guide for building an AI agent that earns money through x402 micropayments and uses that revenue to pay its operating costs.

In plain words
What is it for?
Use it to plan the earn-preserve-spend cycle, calculate daily margins, estimate break-even time, and protect operating funds.
Why use it?
It helps determine whether the agent's expected income can cover hosting, model usage, transaction fees, and other expenses.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to plan the earn-preserve-spend cycle, calculate daily margins, estimate break-even time, and protect operating funds.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gblinproject/gblin-treasury-risk-regime --skill agent-self-funding
Clone the repo
git clone --depth 1 https://github.com/gblinproject/gblin-treasury-risk-regime

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-self-funding

README.md
[![agentmods](https://agentmods.dev/badge/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding/github.svg)](https://agentmods.dev/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding)
Your own site
<a href="https://agentmods.dev/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding"><img src="https://agentmods.dev/badge/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agent-self-funding

Your own site · 80×15
<a href="https://agentmods.dev/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding"><img src="https://agentmods.dev/badge/skills/gblinproject/gblin-treasury-risk-regime/agent-self-funding.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,273 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01273
Opus 5 $0.00026 $0.00636
Sonnet 5 $0.00010 $0.00255
Haiku 4.5 $0.00005 $0.00127

Measured 12d ago against content hash a93b974fe2bb, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

agent-self-funding scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agent-self-funding/SKILL.md · 135 lines

How it starts

The opening of the file, as written. The whole thing — 135 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Self-Funding AI Agent Architecture

When this skill applies

Trigger when the user describes:

  • "Build an agent that pays for its own hosting"
  • "Self-sustaining AI agent"
  • "Agent that earns and reinvests"
  • "Make my bot economically viable"
  • "Autonomous economic loop"

The core loop

A self-funding agent has three phases that cycle continuously:

EARN (x402 endpoint) → PRESERVE (treasury) → SPEND (operational costs)
       ↑                                              ↓
       └──────────── repeat ─────────────────────────┘

If EARN > SPEND over a rolling window, the agent grows. If SPEND > EARN, it dies (treasury depletes to zero).

Minimum economic viability

Before writing code, calculate whether the agent can be viable:

function isViable(params: {
  pricePerCall: number;
  expectedCallsPerDay: number;
  hostingCostPerDay: number;
  llmCostPerCall?: number;
  txFeesPerDay?: number;
}): { viable: boolean; marginPerDay: number; daysToBreakeven: number } {
  const dailyRevenue = params.pricePerCall * params.expectedCallsPerDay;
  const dailyVariableCost = (params.llmCostPerCall || 0) * params.expectedCallsPerDay;
  const dailyFixedCost = params.hostingCostPerDay + (params.txFeesPerDay || 0);
  const marginPerDay = dailyRevenue - dailyVariableCost - dailyFixedCost;
  return {
    viable: marginPerDay > 0,
    marginPerDay,
    daysToBreakeven: marginPerDay > 0 ? params.hostingCostPerDay / marginPerDay : Infinity,
  };
}

Example viability check:

const check = isViable({
  pricePerCall: 0.01,
  expectedCallsPerDay: 50,
  hostingCostPerDay: 0,      // Vercel free tier
  llmCostPerCall: 0.002,
  txFeesPerDay: 0.05,
});
// → { viable: true, marginPerDay: 0.35, daysToBreakeven: 0 }

If marginPerDay < $0.10, the agent is too marginal to survive temporary outages or LLM price changes. Aim for marginPerDay > $0.50 minimum.

Architecture

self-funding-agent/
├── src/pages/api/
│   ├── service.ts            # x402-paywalled endpoint (REVENUE)
│   ├── cron.ts               # Treasury management (PRESERVE)
│   └── stats.ts              # Public dashboard data
├── src/lib/
│   ├── x402-paywall.ts       # Payment middleware
│   ├── treasury.ts           # Auto-invest / auto-redeem logic
│   └── service-logic.ts      # The actual value-add of the agent
└── vercel.json               # Cron schedule

Read the full file on GitHub · 135 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 135 lines · 52 tokens per session scan A a93b974fe2bb

Subscribe to this mod's changes

agent-self-funding is a skill published in the GitHub repository gblinproject/gblin-treasury-risk-regime (1 stars, last pushed 2d ago), licensed MIT. It adds 52 tokens to every session and 1,273 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.