Borrowing it
Nothing to install: this file belongs to juliensere/ha-claude-usage. 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/juliensere/ha-claude-usage/main/AGENTS.mdgit clone --depth 1 https://github.com/juliensere/ha-claude-usageWrote 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/instructions/juliensere/ha-claude-usage/agents-md)<a href="https://agentmods.dev/instructions/juliensere/ha-claude-usage/agents-md"><img src="https://agentmods.dev/badge/instructions/juliensere/ha-claude-usage/agents-md/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/instructions/juliensere/ha-claude-usage/agents-md"><img src="https://agentmods.dev/badge/instructions/juliensere/ha-claude-usage/agents-md.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.00644 | $0.00644 |
| Opus 5.5 | $0.00258 | $0.00258 |
| Sonnet 5.5 | $0.00129 | $0.00129 |
| Haiku 4.5 | $0.00064 | $0.00064 |
Grade A, and why
ha-claude-usage AGENTS.md scanned grade A with 1 finding 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 26d 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.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
- **URL-encode cookies** — `cf_clearance` contains unicode characters; always wrap values with `urllib.parse.quote(..., safe='')`. How it starts
The opening of the file, as written. The whole thing — 54 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md — Guidelines for AI agents working on this repository
Project overview
Home Assistant custom integration that exposes Claude.ai session and weekly usage as native sensors.
custom_components/claude_usage/ ← integration source (canonical location, HACS-compatible)
config/ ← HA runtime config for Docker dev (configuration.yaml)
tests/ ← pytest smoke tests
scripts/ ← standalone CLI helper
Architecture
| File | Role |
|---|---|
coordinator.py |
DataUpdateCoordinator — polls GET /api/organizations/{org_id}/usage every 60 s, auto-renews cookies, accumulates UsageMetrics |
sensor.py |
15 usage sensors + one per scoped weekly limit + 5 diagnostic sensors; ClaudeUsageSensorDescription carries a value_fn (usage) or metric_fn (diagnostics) |
config_flow.py |
Three flows: user (initial setup), reauth_confirm (triggered by ConfigEntryAuthFailed), reconfigure (manual update) |
__init__.py |
Entry setup/unload + async_get_config_entry_diagnostics |
const.py |
All constants — change UPDATE_INTERVAL here to adjust poll frequency |
Running tests
pip install -r requirements-dev.txt
python3 -m pytest tests/ -v
Tests use pytest-homeassistant-custom-component for HA fixtures and its aioclient_mock fixture for HTTP mocking. No real network calls are made.
Commit conventions
Use Conventional Commits with a single subject line, no body:
feat: add weekly token-count sensor
fix: url-encode cf_clearance cookie to avoid latin-1 error
chore: bump pytest-homeassistant-custom-component to 0.14
test: add coordinator cookie-renewal smoke test
docs: update README installation steps
Types: feat, fix, chore, test, docs, refactor, ci.
Key constraints
- No
brinAccept-Encoding— the server may return brotli-compressed responses that aiohttp cannot decode without the optionalbrotlipackage. Keep"accept-encoding": "gzip, deflate". - URL-encode cookies —
cf_clearancecontains unicode characters; always wrap values withurllib.parse.quote(..., safe=''). ConfigEntryAuthFailed— raise this (notUpdateFailed) on 401/403 so HA triggers the native reauth notification automatically.- Diagnostic sensors are always available — their
availableproperty returnsTrueunconditionally; they read fromcoordinator.metrics, notcoordinator.data. - Integration files are at the repo root under
custom_components/(HACS convention). The Docker dev setup mounts both./config:/config(HA runtime config) and./custom_components:/config/custom_components(integration files) separately.
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.
- 26d ago Changed · +9 tokens per session c75c01801168
- 2mo ago First seen · 54 lines · 635 tokens per session scan A 249997d09e6e
ha-claude-usage AGENTS.md is an instructions file published in the GitHub repository juliensere/ha-claude-usage (2 stars, last pushed 12d ago), licensed MIT. It adds 644 tokens to every session, about $0.0026 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
ha-claude-usage AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| ha-claude-usage AGENTS.mdjuliensere/ha-claude-usage | Instructions file | 2 | 12d ago | MIT | A | 644 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | today | MIT | A | 7,461 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 5,649 | GitHub Copilot |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | today | MIT | A | 4,680 | Codex, OpenCode |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 3,093 | GitHub Copilot |
| vscode model-prompts.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 2,022 | GitHub Copilot |