7-auth — Claude Code rule: what it does, how to install
7-auth governs how assistant code reads and saves auth credentials: lazy GitHub token lookup, tight file permissions, and delayed error handling.
MIT ★ 571 updated 2026-10-29
.claude/rules/7-auth.mdWhat 7-auth does
This rule targets auth code in src/runtime/auth/**/*.ts and src/contexts/*/application/**/*.ts. It instructs the agent to resolve credentials via AuthReaderAdapter.resolve(), checking AIDD_TOKEN, project .aidd/auth.json, and user auth.json. The first match wins and gets memoized, so gh CLI spawns at most once. Reading via method: "external" runs gh auth token, while a dedicated "gh" method does not exist.
Credential storage requires strict access rights: 0600 on POSIX environments and icacls /inheritance:r on win32. If tightening file permissions fails, the adapter must throw an exception immediately.
Missing tokens never block commands up front. Authentication errors surface only as CatalogFetchAuthError upon receiving a 401 status, while local framework paths bypass token requirements entirely.
What it helps with
- enforce 0600 and icacls file permissions when saving credentials
- memoize GitHub token resolution to prevent duplicate gh calls
- map HTTP 401 responses to CatalogFetchAuthError
- set up credential resolution across AIDD_TOKEN and auth.json files
Example prompts for the agent
- Implement token retrieval in AuthReaderAdapter.resolve() following our auth rule
- Store the credential file with proper OS permissions for Windows and POSIX
- Ensure missing auth tokens do not block local execution paths
How to install 7-auth
Manually: put the files in place
.claude/rules/7-auth.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/7-auth.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/7-auth.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/7-auth.mdManually: put the files in place
.clinerules/7-auth.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about 7-auth
How to install 7-auth in Claude Code?
Place the rule file at .claude/rules/7-auth.md in your project root.
What does 7-auth do?
It guides code assistants on resolving tokens in order, memoizing shell lookups, and securing saved auth files on disk.
Does 7-auth halt execution if a token is absent?
No. Execution continues until an actual 401 occurs, raising CatalogFetchAuthError only when a remote request fails.
Source text
7-auth.md · MIT
--- description: Apply when a token is read, stored or checked; one GitHub token, resolved once, never checked eagerly. paths: - "src/runtime/auth/**/*.ts" - "src/contexts/*/application/**/*.ts" --- # Auth ## Resolution - `AuthReaderAdapter.resolve()`: `AIDD_TOKEN`, project `.aidd/auth.json`, user `auth.json`. - First hit wins; memoized, so `gh` spawns at most once. - `method: "stored"` holds the token. - `method: "external"` runs `gh auth token` at read time, at its own level. - No `"gh"` method exists. ## Storage - Write a credential `0600` on POSIX, `icacls /inheritance:r` on win32. - Throw when the restriction fails. ## Not checked - No command refuses for a missing token. - Authorization surfaces as `CatalogFetchAuthError` on a 401. - A local framework path needs no token. - Full contract: `aidd_docs/memory/auth.md`.
© ai-driven-dev · MIT · ai-driven-dev/framework