Borrowing it
Nothing to install: this file belongs to gotgenes/pi-anthropic-auth. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/gotgenes/pi-anthropic-auth/main/.pi/skills/anthropic/SKILL.mdgit clone --depth 1 https://github.com/gotgenes/pi-anthropic-authWrote 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.
[](https://agentmods.dev/skills/gotgenes/pi-anthropic-auth/anthropic)<a href="https://agentmods.dev/skills/gotgenes/pi-anthropic-auth/anthropic"><img src="https://agentmods.dev/badge/skills/gotgenes/pi-anthropic-auth/anthropic/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.
<a href="https://agentmods.dev/skills/gotgenes/pi-anthropic-auth/anthropic"><img src="https://agentmods.dev/badge/skills/gotgenes/pi-anthropic-auth/anthropic.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00049 | $0.03559 |
| Opus 5.5 | $0.00020 | $0.01424 |
| Sonnet 5.5 | $0.00010 | $0.00712 |
| Haiku 4.5 | $0.00005 | $0.00356 |
Grade A, and why
anthropic 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 13d 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.
How it starts
The opening of the file, as written. The whole thing — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Anthropic OAuth Compatibility
Use When
- Anthropic OAuth requests fail with
You're out of extra usage. - Pi Anthropic OAuth works for login but fails for actual requests.
- You need to compare Pi, OpenCode, and
opencode-anthropic-authbehavior. - You need to decide whether a fix belongs in
before_provider_request, thestreamSimpletransport wrapper, or a deeper override.
Core Lessons
- Treat Anthropic's
You're out of extra usage.error as a possible disguised request rejection, not only a billing problem. - Prefer the thinnest fix that works.
- Preserve Pi's built-in Anthropic behavior by default.
- Prefer request shaping before prompt rewriting.
- A refusal blamed on request content needs an organic-data control before it becomes a diagnosis (Issue #65).
- Avoid
streamSimpleunless hooks are clearly insufficient — they are insufficient for compaction and background-agent calls, which is why this repo wraps the transport (Issue #18).
Repo-Specific Findings
Confirmed Pi upstream behavior
- Pi already handles Claude Code OAuth headers, Claude Code identity injection, native Anthropic OAuth login, and tool-name normalization.
- Pi auth storage already refreshes OAuth tokens under a lock.
Confirmed local fixes
- OAuth Anthropic payload shaping prepends an
x-anthropic-billing-headersystem block. - The billing block must not add
cache_control, or Anthropic can reject the request for exceeding the cache-control block limit. - Content-less
role: "system"messages carryingoutput_configmust survive system-message shaping: on managed-effort models (those pi-ai flagscompat.supportsMidConvoEffort, whichtest/managed-effort-drift.test.tsenumerates from the installed catalog) they are the only carrier of the requested effort, since Pi pins the top-level effort to"high". Dropping them errors nowhere and silently runs every request at"high"; Anthropic accepts them withcontent: [](verified live on pi 0.87.1, PR #79). - Assistant block ordering must not be normalized: measured 2026-09-20, Anthropic returns 200 for
[tool_use..., text]and[text, tool_use, text, tool_use]on sonnet-4-5, haiku-4-5, sonnet-5, fable-5, and opus-4-8. The split that used to rewrite those turns corrupted signedthinkingblocks and was removed (Issue #66). - Pi's default system prompt can act as an Anthropic fingerprint and trigger disguised rejection errors.
- Shaping runs in a thin
streamSimpletransport wrapper (delegating to Pi's built-in Anthropic transport, resolved from the installed pi-ai layout), gated on thesk-ant-oattoken. - The billing header's
cc_versionis a floor, not a fixed value: the wrapper injects anoptions.fetchthat reads pi's ownuser-agent: claude-cli/<version>off the built request and rebuilds the header at pi's version when pi reports a higher one (Issue #74). An explicitPI_ANTHROPIC_AUTH_CLAUDE_CODE_VERSIONoverride is absolute and is never raised. Measured live on pi 0.87.1 againstclaude-opus-5-5: with the pin forced to 2.1.260 the request succeeds; with the same value set through the env override it is rejected asclaude_code_version_too_old. - When Anthropic raises a floor above both pi and the pin, the same
fetchretries once at the floor the 400 names, and remembers it for the wrapper's lifetime (Issue #75). Unrecovered rejections (override set, floor unnamed, body not rebuildable, retry rejected) reach the user with a[pi-anthropic-auth]hint appended toerror.message. On pi 0.87.1 the retry is unreachable live without a patch, because pi's own 2.1.280 already meets every current floor; the live check forces the pin to 2.1.260 and disables the pi-version read in the working tree, then looks for theclaude-code-version-recoverydebug line. - The wrapper covers the main loop and compaction — everything that dispatches through
modelRuntime. - It covers only the provider names this extension registers:
anthropic, plus any the user names inextensions/pi-anthropic-auth/config.json(global, or a trusted project's.pi/). An Anthropic OAuth subscription another extension registers under its own name (pi-multi-pass'santhropic-2) is otherwise unshaped and fails real prompts with the extra-usage 400 (Issue #70). Reproduced live on 2026-09-24 with a second login of the same account: 400 without the config, 200 with it. Short prompts pass either way, so check/anthropic-auth:status'sshaped providersline before debugging anything else. - Background agents that pass
ctx.modelRegistry.streamSimple()as their stream function (pi >=0.86.0) route throughmodelRuntimeand are shaped; pi-observational-memory 3.1.x does this (measured live, Issue #53). - On pi >=0.80.8, callers that dispatch through pi-ai's
compat.streamSimple(passed explicitly, or reached through thesetDefaultStreamFnfallback whenstreamFnis omitted) are confirmed uncovered, and cannot be covered from this extension (Issue #46); seedocs/architecture.mdfor why, and for the supported path for extension authors.
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.
- 13d ago Changed 1011ee0de685
- 29d ago Changed · +1 lines 5697b5d7c97e
- 1mo ago Changed · +9 lines ceed0aac394d
- 1mo ago Changed · +4 lines cee43f3eaf6c
- 1mo ago Changed · +8 lines b0a724439e21
- 1mo ago Changed · +4 lines 9eb05f855342
- 1mo ago Changed · +17 lines 7aef3b680a5a
- 1mo ago Changed · +4 lines 214df5baeb17
- 2mo ago First seen · 147 lines · 49 tokens per session scan A b6f22c5f324d
anthropic is a skill published in the GitHub repository gotgenes/pi-anthropic-auth (426 stars, last pushed 13d ago), licensed MIT. It adds 49 tokens to every session and 3,559 once invoked, about $0.0002 per session on Opus 5.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-30.
Other skills, from other repositories
api-integration-architect
Design, implement, debug, and optimize API integrations with expert-level patterns for REST, GraphQL, webhooks, and authentication flows.
auth-patterns
Use when implementing authentication (JWT, sessions, OAuth), authorization (RBAC, ABAC), password hashing, MFA, or security best practices for backend services.
api-integration-architect
Design, implement, debug, and optimize API integrations with expert-level patterns for REST, GraphQL, webhooks, and authentication flows.
prisma-database-setup
Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".
api-integration-architect
Design, implement, debug, and optimize API integrations with expert-level patterns for REST, GraphQL, webhooks, and authentication flows.
watcha-oauth
A guide to adding Watcha sign-in to a website or mobile app through OAuth 2.0, a standard way for users to grant access without sharing their password.