MagicTools

⚠️ Claude Lessons

The fastest way to make Claude stronger is writing other people's incident-earned lessons straight into its memory. All 15 rules here come from real production failures (lost files, hallucinated "done", silently failing APIs…), each distilled into one actionable line. Pick your combination and merge it into your Claude Code with one command — updates always merge, never overwrite your own memory or edits.

Version: 2026-08-05 · 15 rules · JSON · install.sh

🧩 Compose Your Import Pack

Check the lessons you want — the command updates live. Different combos merge on install; nothing gets overwritten.

Presets:
Verification & Honesty
🐚 Shell & File Operations
🔌 External API Integration
🚀 Git / CI / Deployment
🎨 AI-Generated Content
⚙️ Unattended Pipelines
Selected: 15 lessonsResident cost: 495 tokens/session + 6 on-demand skills (zero resident cost)

One-line install / update (idempotent)

curl -fsSL https://tools.cooconsbit.com/claude-lessons/install.sh | bash -s -- --locale en

Verification & Honesty

highNever claim "done/fixed" without verification — run the test, read the log, or fire a real request first

The incident: "It should work now" is where AI assistants hallucinate most. The moment you claim done, you must be able to paste evidence: test output, a log line, an HTTP status. No evidence = not done.

When docs contradict code, trust the code — and fix the docs while you're there

The incident: The project docs listed an old server IP while the deploy workflow had long moved on. Following the docs meant touching the wrong machine. Docs are snapshots; code is the truth.

Before concluding "no traffic / no logs", confirm where logs are actually written (e.g. nginx -T)

The incident: The default /var/log/nginx/access.log was 0 bytes — nearly concluding "this box gets no traffic". nginx -T revealed access_log had been repointed to a custom directory all along.

Hard limits on length/count must be measured by script — "looks short enough now" is not verification

The incident: A DB column capped at 500 chars; the summary was trimmed from 598 and submitted on feel — it was 506 and failed again. The root cause: eyeballing where counting was required.

🐚 Shell & File Operations

highBatch mv/rename must use mv -n or check the target first — name collisions silently destroy data

The incident: Renaming logs by mtime-derived dates: two files rotated on the same day mapped to the same target name, mv overwrote silently, three history files were lost for good.

Before suspecting "file tampered / tool haunted", check your own flags — rg's -r means --replace, not recursive

The incident: rg -r turned matches into replaced display output, which "looked like the file changed" — nearly triggering a wild goose chase about injected tool output.

Put throwaway scripts in the project's ./tmp/, not system /tmp — Node can't resolve project deps from /tmp

The incident: A rescue script placed in /tmp failed with ERR_MODULE_NOT_FOUND — Node resolves node_modules upward from the script's location. Inside the project's ./tmp/ it ran first try.

🔌 External API Integration

highSome APIs (MiniMax etc.) hide business errors inside HTTP 200 bodies — checking only the HTTP status = no error handling

The incident: Rate limits, auth failures, empty balance, content blocks — all returned as HTTP 200 with the real code in base_resp.status_code. Retry logic keyed on HTTP status never fires once.

Proxy env vars need the http:// scheme prefix; and gRPC reads grpc_proxy while REST reads HTTPS_PROXY — each honors its own

The incident: A bare 127.0.0.1:7897 in grpc_proxy fails parsing then times out 60s; proxy config that worked for GA4 (gRPC) did nothing for GSC (REST) — Node's built-in fetch ignores HTTPS_PROXY entirely.

Only rate limits deserve backoff retries; auth/balance/content-block errors return the same answer ten thousand retries later — throw immediately

The incident: Indiscriminate retries turned one auth failure into three slow failures and buried the real error. The retry whitelist should contain only rate limits and transient network errors.

🚀 Git / CI / Deployment

Bump the version before triggering a build — rebuilding the same tag races and overwrites itself

The incident: Two builds on the same image tag: whichever finished later won, so the deployed version depended on which runner was slower. The version number is a build's identity, not decoration.

CI failing in seconds = network/auth; only minute-scale failures are compile/deps — check the failure timestamp first

The incident: A build died 2 seconds in at "load metadata" with the error pointing at the Dockerfile — the real culprit was a cross-border registry connection reset. The same Dockerfile building fine before and after was the proof.

🎨 AI-Generated Content

highAI images own the mood, code owns the information: composite titles/numbers/brand marks programmatically (model-drawn CJK text is always garbled); for wide banners give explicit composition orders (subject centered, filling the full width) — never aesthetic adjectives like "negative space"

The incident: One "generous negative space" in the prompt shoved the subject to one edge leaving 60% empty — exactly where the share thumbnail center-crops. "Subject centered, filling the full width" fixed it in one retry. Titles are always composited as SVG: sharp and never garbled.

⚙️ Unattended Pipelines

highBefore saving/submitting, wait for third-party async work to actually finish — poll for the target state, don't sleep and guess

The incident: Saving a WeChat draft right after pasting external images drops them: the editor needs ~4s to rehost onto its CDN. The fix: poll until every img src flips to the target domain, then save.

highEvery stage of an unattended pipeline needs a fallback — AI and external APIs are inherently flaky; survive by degradation, not prayer

The incident: When AI cover generation fails (rate limit / content block / missing key), fall back to a template cover: a plain cover for a day is fine, a broken daily pipeline is not. Test the fallback path as seriously as the happy path.

💡 Design Philosophy: Unlimited Capture, Budgeted Residency, Gated Promotion

The enemy of an experience library isn't remembering too little — it's bloat: every resident memory taxes every single session's context. We fight it with four mechanisms:

① Tiered loading: hot rules (hard cap of 10 library-wide) live in the always-on @import; warm rules install as per-category Claude Code skills — only a one-line trigger description stays resident, the body loads only when you're doing related work (shell ops, API integration, CI debugging…). Near-zero context cost.

② Entry gate: a rule must be repeatable, expressible in one line, and backed by a real incident. One-off hiccups go to the incident log, never the rulebook.

③ Usage decay: every rule carries last_confirmed (when it last actually fired); rules that stay silent get demoted or archived at quarterly review instead of squatting forever.

④ Periodic compaction: related pitfalls merge upward into one more general rule (three proxy bugs become one "proxy config triple-check"). A healthy library compresses; it doesn't just append.

How the import works (why "never overwrites" holds)

  1. Only dedicated managed files are written — ~/.claude/claude-lessons.md and ~/.claude/skills/claude-lessons-*/; your CLAUDE.md gets a single idempotent @import line;
  2. Each rule is a marker block with ID + version + content hash: your edits are preserved (with a conflict note), your deletions go into an ignore list and never come back; everything below the local:below marker is yours;
  3. Different combinations accumulate across runs; uninstall = remove the import line + delete the managed files and skills.

FAQ

Will this overwrite my CLAUDE.md?

No. Installation appends a single marked @import line to your CLAUDE.md; all content lives in separate managed files. Your memory and these rules are physically isolated.

I edited or deleted a rule — will updates clobber it?

No. Each rule carries a content hash: detected edits are kept (with a conflict note), and deleted IDs are recorded in an ignore file so updates never re-add them.

Will installing more rules make Claude slower and more expensive over time?

No. Only hot-tier iron rules (≤10, a few hundred tokens) stay resident; warm-tier rules install as on-demand skills where only a one-line description is present until relevant work triggers the body. Even the full 15-rule pack costs ~400 resident tokens.

How much context does the import cost?

The page shows a live resident-cost estimate as you select. The full pack is ~400 tokens/session plus 6 on-demand skills; the essentials preset stays under 200 tokens.