{"slug": "show-hn-self-improving-claude-code-with-turn-counter-hook", "title": "Show HN: Self-improving Claude Code with turn-counter hook", "summary": "A developer released a Claude Code skill, claude-skill-self-improve, that runs a recurring retro reviewing recent work, extracting reusable lessons into ~/.claude/ (CLAUDE.md, rules, memory, skills, agents) and pruning stale entries. A UserPromptSubmit hook script increments a per-session counter in ~/.claude/state/self-improve/<session_id>.count and prints a [self-improve] line every N turns, defaulting to 20 and configurable via SELF_IMPROVE_EVERY (0 disables it), or the retro can be triggered manually with /self-improve. Each retro writes its summary to ~/.claude/state/self-improve/last-retro.md for the next retro to read, and lessons belonging in a project repo are listed as proposals rather than applied.", "body_md": "A Claude Code skill that runs a recurring retro: it reviews recent work, extracts general,\nreusable lessons and folds them into `~/.claude/` (CLAUDE.md, rules, memory, skills, agents),\npruning stale entries as it goes. A `UserPromptSubmit` hook nudges it every N turns; it can\nalso be run by hand with `/self-improve`.\n\nNote\n\nThis skill is a starting point, not a finished product. It is meant to be adapted to your\nown use case: edit `SKILL.md` to match where your lessons should live, what counts as a\ngood lesson for your work, and how often the retro should run.\n\n```\nSKILL.md                          the skill\nscripts/self-improve-counter.sh   turn-counter hook\n```\n\n1. \nClone the skill into your skills folder: \n\n```\ngit clone git@github.com:JonnaMat/claude-skill-self-improve.git ~/.claude/skills/self-improve\n```\n\n2. \nInstall the hook script: \n\n```\nmkdir -p ~/.claude/hooks && cp ~/.claude/skills/self-improve/scripts/self-improve-counter.sh ~/.claude/hooks/ && chmod +x ~/.claude/hooks/self-improve-counter.sh\n```\n\n3. \nRegister the hook in `~/.claude/settings.json` (merge with any hooks you already have):\n\n```\n{\n  \"hooks\": {\n    \"UserPromptSubmit\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"~/.claude/hooks/self-improve-counter.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n4. \nRestart Claude Code and check `/hooks` lists the`UserPromptSubmit` entry.\n\nOn every prompt the script reads `session_id` from the hook's JSON payload, increments\n`~/.claude/state/self-improve/<session_id>.count`, and every N-th turn prints a\n`[self-improve]` line, which Claude Code adds to the conversation as context. The skill then\nruns the retro (in the background when a subagent tool is available).\n\n- Cadence: `SELF_IMPROVE_EVERY=30 claude` (default 20).\n- Disable without removing the hook: `SELF_IMPROVE_EVERY=0` .\n- Reset counters: delete `~/.claude/state/self-improve/*.count` .\n- Each retro writes its summary to `~/.claude/state/self-improve/last-retro.md` , which the\nnext retro reads.\n\nThe retro writes only under `~/.claude/`. Lessons that belong in a project repo are listed in\nits report as proposals for you to apply.", "url": "https://wpnews.pro/news/show-hn-self-improving-claude-code-with-turn-counter-hook", "canonical_source": "https://github.com/JonnaMat/claude-skill-self-improve", "published_at": "2026-12-03 22:33:03+00:00", "updated_at": "2026-12-03 22:46:31.622538+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Claude Code", "Anthropic", "JonnaMat", "claude-skill-self-improve"], "also_reported_by": [], "takeaway": "Install the self-improve skill and its UserPromptSubmit hook to trigger a retro every 20 turns by default, tune cadence with SELF_IMPROVE_EVERY, and reset counters by deleting ~/.claude/state/self-improve/*.count.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-self-improving-claude-code-with-turn-counter-hook", "markdown": "https://wpnews.pro/news/show-hn-self-improving-claude-code-with-turn-counter-hook.md", "text": "https://wpnews.pro/news/show-hn-self-improving-claude-code-with-turn-counter-hook.txt", "jsonld": "https://wpnews.pro/news/show-hn-self-improving-claude-code-with-turn-counter-hook.jsonld"}}