ha-claude-usage: Instructions file for Codex

AGENTS.md

ha-claude-usage AGENTS.md is an instructions file for Codex, OpenCode from juliensere/ha-claude-usage. It costs 644 tokens per session, scanned A, original, MIT.

Project instructions for the ha-claude-usage code repository, stored in an AGENTS.md file.

In plain words
What is it for?
Understanding the repository structure, running its tests, following its commit conventions, and respecting project-specific limits.
Why use it?
They give the coding agent the project context, required checks, commit rules, and constraints needed to work consistently.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is juliensere/ha-claude-usage's own configuration. It tells Codex and OpenCode how to work on ha-claude-usage itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything ha-claude-usage configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/juliensere/ha-claude-usage/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/juliensere/ha-claude-usage

Made for: Codex, OpenCode.

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 ha-claude-usage AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/juliensere/ha-claude-usage/agents-md/github.svg)](https://agentmods.dev/instructions/juliensere/ha-claude-usage/agents-md)
Your own site
<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.

agentmods 80×15 button for ha-claude-usage AGENTS.md

Your own site · 80×15
<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>
Per session 644 This file is loaded in full into every session.
When invoked 644 The same file — it is already loaded in full.
Security scan A 1 finding. 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.00644 $0.00644
Opus 5.5 $0.00258 $0.00258
Sonnet 5.5 $0.00129 $0.00129
Haiku 4.5 $0.00064 $0.00064

Measured 26d ago against content hash c75c01801168, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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='')`.
AGENTS.md · 54 lines

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 br in Accept-Encoding — the server may return brotli-compressed responses that aiohttp cannot decode without the optional brotli package. Keep "accept-encoding": "gzip, deflate".
  • URL-encode cookies — cf_clearance contains unicode characters; always wrap values with urllib.parse.quote(..., safe='').
  • ConfigEntryAuthFailed — raise this (not UpdateFailed) on 401/403 so HA triggers the native reauth notification automatically.
  • Diagnostic sensors are always available — their available property returns True unconditionally; they read from coordinator.metrics, not coordinator.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.

Read the full file on GitHub · 54 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. 26d ago Changed · +9 tokens per session c75c01801168
  2. 2mo ago First seen · 54 lines · 635 tokens per session scan A 249997d09e6e

Subscribe to this mod's changes

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.

Related

ha-claude-usage AGENTS.md compared with instructions from other repositories

ha-claude-usage AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ha-claude-usage AGENTS.mdjuliensere/ha-claude-usageInstructions file212d agoMITA644Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,649GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
vscode model-prompts.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA2,022GitHub Copilot