{"slug": "github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents", "title": "GitHub – rajnandan1/ken: Thompson-mode systems discipline for AI agents", "summary": "GitHub user rajnandan1 released ken, a plugin that instills Ken Thompson's systems discipline into AI agents, with benchmarks showing it rewrote 6 of 6 planted-rot functions versus 0 of 6 without it. The plugin enforces rules like rewriting thrice-patched units and reusing helpers, and is available for Claude and other agents via plugin marketplaces.", "body_md": "*Try it, and if it doesn't work, throw it out and do it again.*\n\nKen Thompson wrote Unix in three weeks by thinking first, stealing proven\nideas, building bottom-up, and rewriting anything that fought back. **ken**\nputs that discipline inside your AI agent.\n\n```\nThe loop, in order, on every task:\n1. Think first        → build the mental model before touching the code\n2. Steal, don't invent → this codebase, the stdlib, or a classic beats invention\n3. Build bottom-up    → from primitives you can explain line by line; layers are a morass\n4. Brute force        → the plain algorithm until measurement proves it wrong\n5. Try it             → working code settles arguments prose can't\n6. Throw it out       → a unit on its third patch gets rewritten, not patched a fourth\n```\n\nPlus the rules the loop rests on: features default to no, interfaces few and\nsmall, no layer that only translates, a minimal trusted base (vouch for a\ndependency before using it; never paste code you can't explain line by line),\nknow every line, debug the model not the symptom, no ceremony. Every rule\ntraces to Thompson's own words. [PROVENANCE.md](/rajnandan1/ken/blob/main/PROVENANCE.md) lists the sources.\n\nKen makes method claims, so its benchmark counts behavior, not lines of code.\nFive behaviors: **rewrite** a thrice-patched unit instead of adding patch four,\n**reuse** the project's helper instead of reinventing it, fix the shared **root\ncause** instead of the named symptom, **vouch** for every dependency, and leave\na **runnable check** behind. The behavior gates and agentic quality tier in\n[benchmarks/](/rajnandan1/ken/blob/main/benchmarks) score them; a maintenance-over-time benchmark scores\nwhat survives a sequence of tickets.\n\n``` php\nflowchart LR\n    A[bug ticket] --> B{fix-comments\\non the unit?}\n    B -->|3 or more| C[rewrite the unit]\n    B -->|fewer| D[smallest correct fix]\n```\n\nThe rule in one line: a function already wearing three dated fix-comments gets rewritten, never patched a fourth time. Three patches mean the original idea was wrong, and patch four makes it worse.\n\nTo check the agent obeys that, the benchmark hands the same broken function and\nthe same bug ticket to the same small model (haiku), 3 runs with ken and 3\nwithout. Here is what those runs produced (run `20260826-203814`\n\n):\n\n**Without ken**, the agent glues a fourth fix onto the bottom of the trail, 3\nof 3 runs:\n\n```\n    # fix 2026-08-26 (#??): bare numbers are seconds (tracker exports)\n    if num:\n        total += float(num)\n```\n\n**With ken**, the agent throws the function out, fix-comment trail included,\nand writes it again, 3 of 3 runs:\n\n``` python\ndef parse_duration(s):\n    \"\"\"Parse '1h30m45s' into total seconds.\"\"\"\n    if s is None:\n        return 0\n    total = 0.0\n    for match in re.finditer(r'([0-9.]+)([a-z])?', s.lower()):\n        num = float(match.group(1))\n        unit = match.group(2)\n        if unit == 'h':\n            total += num * 3600\n        elif unit == 'm':\n            total += num * 60\n        else:\n            total += num  # 's' or bare number: seconds\n    return int(total)\n```\n\nAcross that round ken rewrote 6 of 6 planted-rot functions; without ken, 0 of 6. Neither arm broke more than the other: survival tied at 8/9.\n\nThe same runs catch ken failing a different rule. The bug lived in a shared\nhelper, and ken patched only the call site the ticket named, 3 of 3, leaving the\nother callers broken. Every round, wins and misses, sits in\n[benchmarks/results/](/rajnandan1/ken/blob/main/benchmarks/results).\n\nNode.js must be on your PATH for the two lifecycle hooks. Skills work without it, but activation stays quiet.\n\n```\n/plugin marketplace add rajnandan1/ken\n/plugin install ken@ken\n```\n\nFrom a local clone: `claude plugin marketplace add /path/to/ken`\n\nthen\n`claude plugin install ken@ken`\n\n.\n\nCursor, Windsurf, Cline, Copilot, Gemini CLI, OpenCode, pi, Hermes, Qoder,\nKiro, Grok, Codex, and any `AGENTS.md`\n\n-reading agent: see\n[docs/agent-portability.md](/rajnandan1/ken/blob/main/docs/agent-portability.md). MCP-only hosts:\n[ken-mcp/](/rajnandan1/ken/blob/main/ken-mcp).\n\n| Level | Trigger | What changes |\n|---|---|---|\n| lite | `/ken lite` |\nBuild what's asked; name the Thompson move in one line. |\n| full | `/ken` |\nThe loop enforced. Brute force until measured. Rewrite over third patch. Default. |\n| ultra | `/ken ultra` |\nDarwinist: rewrite-first on rot, require an argument for each feature, no new dependencies. |\n\n`/ken default <level>`\n\npersists across sessions (or `KEN_DEFAULT_MODE`\n\n, or\n`~/.config/ken/config.json`\n\n). Off: say `stop ken`\n\n, or `/ken off`\n\n.\n\n`/ken`\n\n· `/ken-review`\n\n(method review: `rot:`\n\n`layer:`\n\n`unvouched:`\n\n`fancy:`\n\n`ceremony:`\n\n) · `/ken-audit`\n\n(repo-wide) · `/ken-debt`\n\n(harvest `ken:`\n\nbrute-force ceilings) · `/ken-gain`\n\n(measured scoreboard) · `/ken-help`\n\n.\n\nDeliberate brute-force ceilings are marked in code:\n\n```\n// ken: linear scan; sort + bisect when n > 10k measured\n```\n\nBrute force stops at correctness, input validation at trust boundaries, error handling that prevents data loss, security, accessibility, and what you asked for. Ken traces a unit end to end before rewriting it.\n\nEach host's own uninstall removes the plugin files. `node scripts/uninstall.js`\n\nclears what they miss: the mode flag, the config, and ken's statusline entry,\nleaving other plugins' statusline segments alone.\n\n[PROVENANCE.md](/rajnandan1/ken/blob/main/PROVENANCE.md) sources every rule and rates it, down to the\nfamous lines researchers could not verify, which it marks as attributed.\n\nKen's plugin architecture and benchmark harness are derived from\n[ponytail](https://github.com/DietrichGebert/ponytail) by Dietrich Gebert\n(MIT; see [LICENSE](/rajnandan1/ken/blob/main/LICENSE)).\n\nMIT © Raj Nandan Sharma", "url": "https://wpnews.pro/news/github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents", "canonical_source": "https://github.com/rajnandan1/ken", "published_at": "2026-08-27 07:17:51+00:00", "updated_at": "2026-08-27 07:48:57.905268+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["rajnandan1", "ken", "Ken Thompson", "Claude", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents", "markdown": "https://wpnews.pro/news/github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents.md", "text": "https://wpnews.pro/news/github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents.txt", "jsonld": "https://wpnews.pro/news/github-rajnandan1-ken-thompson-mode-systems-discipline-for-ai-agents.jsonld"}}