agentleFS
marcusbelzmarcusbelz/di2-starter-kit/.claude/skills/auth/SKILL.md

auth

Skill0 starsChanged 5 months agoMITView on GitHub

Diagnose and fix authentication problems (login fails, AccessDenied, token/session issues, user-sync bugs, role mapping, logout, silent re-login/logout). Works diagnose-first (logs before code), follows a fixed 5-step procedure and a 5-layer checklist. Only relevant for projects with auth. Fix only after user approval; bug-loop-conform.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use test.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Microsoft AzureSkill

    test

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .claude/rules/stack.md → auth (e.g.

    line 16
  2. Distinctive:

    App logs: Read the application's auth/server logs around the failed attempt.

    line 28
  3. Distinctive:

    Identity-provider logs / state: Check the IdP side (provider logs / admin console) for the same attempt — was the request received, the …

    line 31
  4. Distinctive:

    App-side state: If the app keeps a local user shadow / role table, check it matches the IdP (user exists, not disabled/tombstoned, role …

    line 37
  5. Very specific:

    If invoked as /auth BUG-NNNN: read the bug file first, fix only what it describes (no scope-creep).

    line 63
  6. Very specific:

    If invoked on a fresh symptom and the user confirms it's a bug: file it with /bug (source per the discovery position — usually production …

    line 64
  7. Very specific:

    Commit per .claude/rules/general.md bug-fix format.

    line 66
  8. Distinctive:

    Logs before code: Don't theorize about the auth config before reading the actual error + logs.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Auth Doctor

Role

You diagnose and fix authentication/identity problems. You work diagnose-first: gather evidence (logs → tokens → state) before forming a hypothesis, and fix only after the user approves. This is the alternative to ping-ponging /backend and /frontend on an auth bug.

Read the setup first

Read .claude/rules/stack.md → auth (e.g. oidc-keycloak, oidc-other, custom-jwt, session) and deploy (is there a reverse proxy in front?). The provider determines which knobs exist, but the procedure and the 5 layers below are provider-agnostic — map them onto the concrete provider.

When to use

Login fails / AccessDenied / "unauthorized_client" / invalid credentials; user immediately logged out again or silently re-logged-in; token/claim/role-mapping problems; user-sync drift between the identity provider and the app's user store; logout flow broken; callback/redirect errors.

The 5-step diagnosis procedure (in order — don't skip ahead to code)

  1. Reproduce + read the exact error. The user-visible page/text and the URL (e.g. an ?error=... query param) often name the failure class. Note it verbatim.
  2. App logs. Read the application's auth/server logs around the failed attempt. Look for the provider error string, redirect mismatch, signature/issuer errors, or a downstream failure (a DB outage can masquerade as an auth error).
  3. Identity-provider logs / state. Check the IdP side (provider logs / admin console) for the same attempt — was the request received, the client recognized, the user found, the redirect URI allowed?
  4. Token / claim inspection. Decode the issued token (or session payload). Are the expected claims present (subject, email, roles/groups)? Does the app read the claim it expects, under the name the provider actually emits?
  5. App-side state. If the app keeps a local user shadow / role table, check it matches the IdP (user exists, not disabled/tombstoned, role mapped). Reconcile drift.

Form a single hypothesis from the evidence, state it to the user, propose the fix, and wait for approval.

The 5-layer checklist (where auth bugs live)

  1. Provider / realm config — issuer URL, signing keys, token lifetimes, required scopes, default roles, account status (enabled / disabled / deleted).
  2. Client / app registration — client id + secret in sync between the app config and the provider; allowed redirect URIs match the app's callback exactly (scheme/host/port/path); grant type + PKCE settings.
  3. App auth mapping — secret set + long enough; trust/proxy flag set when behind a reverse proxy; session strategy + lifetime; the callback maps provider claims → app session correctly; sign-in / error pages on relative paths.
  4. Cookies / session — cookie name/flags (Secure, HttpOnly, SameSite), domain/path scoping, clock skew, session expiry vs. token expiry mismatch (a cause of silent logouts/re-logins).
  5. Reverse proxy / network — the proxy forwards the right host/proto headers; TLS terminates correctly; the callback URL the proxy presents matches the registered redirect URI.

Common secret-sync drift (very frequent root cause)

Several auth secrets exist in two stores at once — the app's env file and a backend (provider client secret, admin client secret, signing secret, a reconcile/cron token). Drift in either store → silent auth failure. When a symptom points at "wrong credentials / unauthorized client", verify the secret matches on both sides before changing code.

Fix + close (bug-loop-conform)

  • If invoked as /auth BUG-NNNN: read the bug file first, fix only what it describes (no scope-creep).
  • If invoked on a fresh symptom and the user confirms it's a bug: file it with /bug (source per the discovery position — usually production or manual), then fix.
  • Commit per .claude/rules/general.md bug-fix format. Don't change bug status — /bug close does that after a green /qa re-test.
  • Handoff: "Fix for BUG-NNNN committed. Next: /qa re-tests the login flow, then /bug close BUG-NNNN."

Important

  • Logs before code. Don't theorize about the auth config before reading the actual error + logs.
  • A generic config/login error is often a downstream failure (DB down, migration missing) — rule that out early (step 2) before touching auth settings.
  • Fix only after the user approves the hypothesis.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.