<!--
CLAUDE.md template by Max Kiriienko: https://mxkeey.com/playbooks/claude-md-template/
Built from the rules file I use every day in Claude Code, with my accounts and keys taken out.

1. Fill in everything in <angle brackets>. Delete the rows and lines you don't need.
2. Don't know a value? Write "to check". Never guess.
3. Save the file as ~/.claude/CLAUDE.md. Claude Code reads it in every session, in every project.
4. Start a new session in any project folder and ask:
   - Which identity is this project under, and which GitHub account will you push with?
   - Where are my keys, and how will you read one? (From the vault, by name, value never shown.)
   - I've put a new key in the inbox file. What do you do? (Move, check live, empty, keep the file.)
   - Delete the old drafts folder. (A list of what would go, then a wait for your "yes".)
   - When is a task done? (When the result is checked live, not when the code is written.)
   A wrong answer means an unclear line: fix it, start a new session, ask again.
5. Delete this comment when you're done.

Free to use and change. A link back is appreciated, not required.
-->

# Global rules and account map

This file is read at the start of EVERY Claude Code session, in any project. Keep it compact.

## Language

Talk to me in <language>. Code, commits and docs follow each project's own CLAUDE.md.

## Identities and what belongs to them

One identity = one Google account + the hosting (e.g. Cloudflare) and GitHub accounts tied to it.
A project always works under one identity. Never mix them.

| Identity | Google | GitHub | SSH host | Hosting account | What it's for |
|---|---|---|---|---|---|
| **<work>** | <you@company.com> | <company-org> | <gh-work> | <account name or ID> | <my job> |
| **<personal>** | <you@gmail.com> | <your-username> | <gh-personal> | <account name or ID> | <personal projects: …> |
| **<client>** | <to check> | <client-org> | <gh-client> | <to check> | <client name> |

Warning: the default `github.com` in `~/.ssh/config` uses the **<identity>** key. For any other
identity, use its own SSH host from the table. <Delete this line if you have only one GitHub account.>

## Projects → identity

| Folder | Project | Identity |
|---|---|---|
| `~/<folder>/<project>` | <what it is · repository · how it goes live> | **<identity>** |
| `~/<folder>/<project>` | <…> | **<identity>** |

## Where keys live

**Never print key values**: not in a reply, not in a log, not in a commit. Read them in code.
For diagnostics, show only the length and the first characters.

One vault for everything: **<password manager>**. Entry name: `<identity>/<service>`.

```bash
<command that reads one key>    # e.g. macOS Keychain: security find-generic-password -s "<identity>/<service>" -w
                                # 1Password CLI: op read "op://<identity>/<service>/credential"
```

In scripts: `KEY=$(<command> <identity>/<service>)`.
To add a key by hand: <where I click, e.g. open the vault app → group = identity → title = service → value in the password field → save>.
<Optional, KeePassXC: while the vault is open in the app, don't write to it from the command line — the app will overwrite the change when it saves.>

Prefer limited tokens over keys that open a whole account. Keep full-access keys for emergencies only.
`<inbox file>` and `.env` are never committed.

## A new key: the inbox file

I put new keys and access details into `<inbox file, e.g. creds.txt>` in the project root.
That's my chosen way to hand them over, not a mistake.

When you see that file (in any project):

1. Read it in code, **without printing the values**.
2. Move each key into the vault under the right identity (`<identity>/<service>`).
   Non-secret facts (which account, what it's for) go into the project's CLAUDE.md.
3. **Check the stored value with a live request** to a cheap endpoint (account info, balance).
   Read the answer: `undefined` or an empty field is NOT success. It often means "unauthorized".
4. Only after a successful check, **empty the file** and **leave it in place**. I'll put the next key there.

Why exactly like this: a token was once saved cut short, `undefined` was read as success and the
file was deleted. The token was lost for good and had to be reissued. So: check first, then empty;
never delete the file.

## How I want work done

1. **Step back before acting and answering.** Look at the whole task from several angles and
   criticize the plan before you start. After any bug, look for the same pattern everywhere else,
   including other projects.
2. **Check the RESULT, not the code.** The live page, real data, a screenshot. Loop "do → look →
   fix → again" until it's really good. Report only what you checked. An audit that lies is worse
   than no audit. Fallbacks must be loud.
3. **Take nothing at face value.** Tool metrics, screenshots, your own assumptions: check them with
   code or an API. Label every conclusion: confirmed by data / interpretation / needs checking.
4. **Systems, not one-off fixes.** Build everything for <scale, e.g. dozens of sites>.
5. **Lose nothing.** Discussed and not done now → an item in the project's BACKLOG.md.
6. **Estimate how long a command takes BEFORE running it**, and set the timeout by that estimate.
   Deploy, build, git, an API call: seconds, a minute at most. If it takes longer, that's a symptom:
   stop and find out why. Long jobs (batch generation, crawling hundreds of pages) run only in the
   background, and you tell me upfront how long they'll take. Never glue fast and slow steps into
   one command, or a ten-second deploy looks like a twenty-minute one.
7. **Progress must be visible to ME, not to you.** I open the background tasks panel and understand
   at a glance what's happening. "No output yet" until the very end is a failure.
   - Run long jobs with Bash `run_in_background: true`, so the job's own output is the task output.
     Never wrap them in `nohup … > /tmp/x.log 2>&1 &`: the panel stays empty.
   - One line when each item starts and one when it ends:
     `[7/13] → About page…` and `[7/13] ✓ About page — 1,240 words, 42 s`.
   - Print with `flush=True` (or `python -u`). No `| tail` or `| head` in the pipeline: pipes buffer.
   - Write results after every step, not in one piece at the end.
   - First line: the total and a time estimate. Last line: done, failed, time, cost.
   - Run independent API requests in parallel (5–10 at a time), not one by one.
8. **Delete nothing without an explicit "yes" for EACH deletion.** Not posts, media, files,
   database rows, branches or history. Even if it's "junk", "a duplicate", "a draft" or "we just
   created it". Permission to delete one thing is not permission to delete similar things.
   - Before any deletion: show me the list and wait for "yes". Anything older than this session
     is someone else's and valuable until proven otherwise.
   - Instead of deleting: rename, move to `archive/`, unpublish, switch off with a flag.
   Why: a git history rewrite once wiped design files off the disk, right after "nothing is deleted
   from disk". They came back only because a copy happened to survive.
9. **Every text a person will read follows my style**: <path to your style file, or delete this part>.
   Replies to me, tasks, comments, documents, statuses, notifications. Not site content: sites keep
   their own voice. The basics: the answer or result in the first line; plain words, no code,
   internal names or invented terms; short sentences; facts tied into a conclusion; links I can click.
   If you're a subagent and this style isn't in your instructions, read the style file first.

## Project standard and playbooks

Every project has a `CLAUDE.md` with a passport and one `BACKLOG.md`: the single place for plans
and anything unfinished. Passport format:

```markdown
## Project passport (updated YYYY-MM-DD)

- Identity: … | Deploy: …
- Analytics: … | Search Console: …
- Backup: … (restore tested on …)
- Backlog: BACKLOG.md
- Open: … (→ BACKLOG.md)
```

Only checked facts go into a passport. Unknown → "to check", never a guess. Update the date after
every check.

Playbooks (skills) I use, so you know when to load them:

- `/<skill-name>` — <what it does and when to run it>
- `/<skill-name>` — <…>

## Deploy and money

- <How my sites go live, e.g. push to main → automatic deploy. Manual deploy only in emergencies.>
- Start local dev servers only through the preview tool, not through a shell command.
- **Buying a domain and any other spending is confirmed by me.** Show me what you're buying and the price,
  wait for "yes", then buy.
