{
  "markdown": "<p align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"assets/logo-dark.svg\">\n    <img src=\"assets/logo.svg\" width=\"220\" alt=\"ken: Thompson-mode systems discipline\">\n  </picture>\n</p>\n\n<h1 align=\"center\">ken</h1>\n\n<p align=\"center\">\n  <em>Try it, and if it doesn't work, throw it out and do it again.</em>\n</p>\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](PROVENANCE.md) lists the sources.\n\n## What ken measures\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/](benchmarks/) score them; a maintenance-over-time benchmark scores\nwhat survives a sequence of tickets, plus rewrite, reuse, root cause, and the\ntrusted base (no unvouched import enters a stdlib-only project).\n\n### The rewrite rule, measured\n\n```mermaid\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\nrewritten, never patched a fourth time. Three patches mean the original idea\nwas 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**Without ken**, the agent glues a fourth fix onto the bottom of the trail, 3\nof 3 runs:\n\n```python\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.\nNeither 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. One unmeasured field report from an interactive session\nshows that rule firing there — one fix in the shared helper, then a sweep that\ncaught two more broken callers — consistent with the miss being specific to\nsingle-shot sessions. Every round, wins and misses, sits in\n[benchmarks/results/](benchmarks/results/).\n\n## Install\n\nNode.js must be on your PATH for the two lifecycle hooks. Skills work without\nit, but activation stays quiet.\n\n### Claude Code\n\n```\n/plugin marketplace add rajnandan1/ken\n```\n\n```\n/plugin install ken@ken\n```\n\nFrom a local clone: `claude plugin marketplace add /path/to/ken` then\n`claude plugin install ken@ken`.\n\n### Other hosts\n\nCursor, Windsurf, Cline, Copilot, Gemini CLI, OpenCode, pi, Hermes, Qoder,\nKiro, Grok, Codex, and any `AGENTS.md`-reading agent: see\n[docs/agent-portability.md](docs/agent-portability.md). MCP-only hosts:\n[ken-mcp/](ken-mcp/).\n\n## Levels\n\n| Level | Trigger      | What changes                                                                                |\n| ----- | ------------ | ------------------------------------------------------------------------------------------- |\n| lite  | `/ken lite`  | Build what's asked; name the Thompson move in one line.                                     |\n| full  | `/ken`       | The loop enforced. Brute force until measured. Rewrite over third patch. Default.           |\n| ultra | `/ken ultra` | Darwinist: rewrite-first on rot, require an argument for each feature, no new dependencies. |\n\n`/ken default <level>` persists across sessions (or `KEN_DEFAULT_MODE`, or\n`~/.config/ken/config.json`). Off: say `stop ken`, or `/ken off`.\n\n## Commands\n\n`/ken` · `/ken-review` (method review: `rot:` `layer:` `unvouched:` `fancy:`\n`ceremony:`) · `/ken-audit` (repo-wide) · `/ken-debt` (harvest `ken:`\nbrute-force ceilings) · `/ken-gain` (measured scoreboard) · `/ken-help`.\n\nDeliberate brute-force ceilings are marked in code:\n\n```js\n// ken: linear scan; sort + bisect when n > 10k measured\n```\n\n## Safety limits\n\nBrute force stops at correctness, input validation at trust boundaries, error\nhandling that prevents data loss, security, accessibility, and what you asked\nfor. Ken traces a unit end to end before rewriting it.\n\n## Uninstall\n\nEach host's own uninstall removes the plugin files. `node scripts/uninstall.js`\nclears what they miss: the mode flag, the config, and ken's statusline entry,\nleaving other plugins' statusline segments alone.\n\n## Provenance & credits\n\n[PROVENANCE.md](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](LICENSE)).\n\nMIT © Raj Nandan Sharma\n",
  "bytes": 6633,
  "sha": "10af59473b078398c23fbf074e11ccce710023faf939e007c766b4dedb95fab1",
  "repo_slug": "rajnandan1/ken",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_rajnandan1_ken_32aec145/readme"
}