{"slug": "teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent", "title": "Teaching Claude Code to Write and Grow Its Own Skills: A Self-Replicating Agent Environment", "summary": "A developer built a self-replicating agent environment for Claude Code that automatically discovers and accumulates reusable procedures as skills. Over several months, the system generated 64 auto-generated skills stored in ~/.claude/skills/auto/, using in-session generation and nightly batch harvesting with a curator to prevent overproduction and manage skill lifecycle.", "body_md": "Last time I wrote about [splitting Claude Code's memory into four layers](https://zenn.dev/bokuwalily/articles/f534402187bd07). This is the follow-up: a setup where **Claude Code itself discovers \"reusable procedures\" and accumulates them as skills** over time.\n\nAfter running this for a few months, `~/.claude/skills/auto/`\n\nnow holds **64** auto-generated skills. In this article I'll cover the design of that self-replication, the mechanisms that prevent overproduction, and the generation curve I observed while operating it.\n\nClaude Code is capable, but across sessions it forgets \"how I got around this error last time.\" How to fix `launchd`\n\n's exit 78, the steps to bake a favicon with `png-to-ico`\n\n, how to trim the RSC payload in Next.js — these **procedures I should have already solved once** were being rebuilt from scratch every single time.\n\nI could hand-write additions to CLAUDE.md, but that turns into a \"whoever notices, writes it\" workflow, and that doesn't last. So I flipped the idea around and decided to **make Claude do the work of finding the procedures too**.\n\nSkill generation is split into two tiers.\n\n| Tier | Timing | Cost | Owner |\n|---|---|---|---|\n| In-session generation | Any time during work | Free / instant | Claude itself, following CLAUDE.md instructions |\n| Nightly batch generation | Daily cron at 3:30 | Consumes Max quota |\n`skill-harvest.sh` (`claude -p` headless) |\n\nThen a **Curator** (`skill-curate.sh`\n\n) runs weekly to periodically organize the accumulated skills. The key is separating generation and organization into different processes.\n\nCLAUDE.md says this (excerpt).\n\n```\n## スキル自己生成（auto-skills）\n\n作業の中で再利用価値のある手順を見つけたら、頼まれなくても自分でスキル化する。\nただし乱造はしない。\n\n### 生成トリガー（いずれか該当時のみ）\n- 5回以上ツールを使う非自明なタスクを最後までやり切った\n- エラー・行き止まりにぶつかった後、動く回避策を見つけた\n- ユーザーにアプローチを修正された（同じ修正を繰り返さないため）\n- 再利用できる手順・コマンド列・ワークフローを発見した\n```\n\nThe crux is \"**but don't overproduce**,\" plus narrowing the triggers down to four. Without writing this, Claude turns everything into a skill and the space fills up with noise almost immediately.\n\nProcedures that never got written down during a session get picked up from the conversation logs by a nightly batch. The `skill-harvest.sh`\n\npipeline looks like this.\n\n`.harvest-watermark`\n\n(the previous processing position)`raw/conversations/*.md`\n\n)`claude -p`\n\n(`<name>/SKILL.md`\n\nwith three sections: `frontmatter + Procedure / Pitfalls / Verification`\n\n`claude -p`\n\nis the **headless invocation** I mentioned in the previous article. It runs on the Max quota, so API-key charges are zero.\n\n`auto/`\n\nAuto-generated skills **do not go in the same place** as hand-written skills or plugin-bundled skills. They're pushed into an isolated namespace, `~/.claude/skills/auto/`\n\n. Two reasons.\n\n`npx skills update -g`\n\nonly manages lock-registered skills. The ones in `auto/`\n\naren't added to the lock → `auto/`\n\nand `author: auto`\n\n\" → That `author: auto`\n\nis the Curator's target-detection key, and it's required in the frontmatter.\n\n```\n---\nname: <kebab-case>\ndescription: <発火条件を具体的に>\nauthor: auto          # ← Curatorの対象判定キー。必須\ncreated: <YYYY-MM-DD>\nversion: 1.0.0\nstatus: active        # active | stale（Curatorが自動設定）\n---\n```\n\nLeft ungoverned, skills rot. The Curator runs weekly like this.\n\n`.snapshots/`\n\n`status: stale`\n\n`.archive/`\n\n(`.curator-proposals.md`\n\nas :::message\n\nNot letting the Curator auto-delete is the core of the safe design. \"Untouched for 30 days\" doesn't necessarily mean the skill is bad (you just haven't done that kind of work). So it stops at demotion and archival, leaving the final call to a human.\n\n:::\n\nLooking at the distribution of `created:`\n\n, in the first three days after introduction (5/28–30) **28** skills were verbalized in one burst, after which the pace dropped to a few per day. This matches intuition — the \"unverbalized procedures\" accumulated in the past get released early, and after that only newly encountered procedures get added.\n\n```\n12 created: 2026-05-30\n 9 created: 2026-05-29\n 7 created: 2026-06-09\n 6 created: 2026-06-11\n 5 created: 2026-06-10\n 5 created: 2026-05-28\n```\n\nHere's this morning's harvest log.\n\n```\n会話ログを精査した結果、以下の理由から該当なし。\n- Codex CLI のセットアップ → codex-cli-setup が既存\n- /insights を CLAUDE.md に反映 → insights-to-claude-md が既存\n- カード債務の支払い優先順位 → 個人の財務状況に依存、再利用手順に非該当\n該当なし\n[2026-06-15 04:11:21] harvest done (exit 0, created=0)\n```\n\n`created=0`\n\n. It **rejected duplicates of existing skills, rejected one-off content tied to personal circumstances, and terminated normally with 0 generated**. This is proof that the \"don't overproduce\" design can process a miss as a *correct* miss. If it generated recklessly here, those 64 would balloon to 200 and turn to noise fast.\n\nFrom the `Pitfalls`\n\nsections of actual skills, the ones that mattered.\n\n`claude -p`\n\nhits the token cap when the full system prompt loads`MAX_THINKING_TOKENS=10000`\n\n`pmset`\n\nwake on scheduleYou don't need the full pipeline. **Just adding one block to CLAUDE.md** gets Tier 1 running.\n\n`~/.claude/skills/auto/`\n\n`author: auto`\n\nin the frontmatter (a marker for organizing later)That alone means skills grow a little with every piece of work. You can add the nightly batch and the Curator later, once skills have accumulated and you feel like organizing them — that's soon enough.\n\n`auto/`\n\n, and make `author: auto`\n\nthe Curator's target keyNext time I'll write about how these skills grew too numerous and Claude Code itself got heavy — [ the audit that cut context injection from 228KB to 48KB](https://zenn.dev/bokuwalily/articles/context-slimming).\n\n**Lily** ([@bokuwalily](https://x.com/bokuwalily)) — solo developer. I build automation infrastructure with Claude Code while mass-producing iOS apps and web services.\n\nYour ❤️ and shares mean a lot!\n\n*Written by **Lily** — I ship iOS apps and automate my content stack with Claude Code.\n\nFollow along: [Portfolio](https://bokuwalily.com) · [X](https://x.com/bokuwalily) · [GitHub](https://github.com/bokuwalily)*", "url": "https://wpnews.pro/news/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent", "canonical_source": "https://dev.to/bokuwalily/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent-environment-20eb", "published_at": "2026-07-10 17:30:33+00:00", "updated_at": "2026-07-10 17:44:36.135962+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "ai-agents", "developer-tools"], "entities": ["Claude Code", "Anthropic", "CLAUDE.md", "skill-harvest.sh", "skill-curate.sh", "Next.js"], "alternates": {"html": "https://wpnews.pro/news/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent", "markdown": "https://wpnews.pro/news/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent.md", "text": "https://wpnews.pro/news/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent.txt", "jsonld": "https://wpnews.pro/news/teaching-claude-code-to-write-and-grow-its-own-skills-a-self-replicating-agent.jsonld"}}