{"slug": "constrained-modeling-for-coding-agents", "title": "Constrained Modeling for Coding Agents", "summary": "Kkt, a new tool named after the Karush-Kuhn-Tucker conditions, applies constrained optimization to coding-agent workflows by forcing agents to identify explicit constraints before implementation. The tool aims to reduce accidental side effects and produce more disciplined plans by modeling work as an optimization problem with feasibility regions and validation certificates. It installs as a skill for Codex, Claude Code, Pi, and OpenCode, and is available via curl or GitHub checkout.", "body_md": "**Start modeling your implementation**\n\nkkt applies [constrained optimization](https://en.wikipedia.org/wiki/Constrained_optimization) to coding-agent workflows. Named after the [Karush-Kuhn-Tucker conditions](https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions), it translates mathematical modeling discipline into a practical framework for identifying application constraints, choosing feasible implementation paths, and validating the result.\n\nGood implementation plans are shaped as much by what not to do as by what to do.\n\nkkt makes those limits explicit. Before choosing an implementation path, it pushes the agent to identify the constraints that define a safe change: public contracts that must not break, architecture boundaries that must not be crossed, data rules that must not be weakened, and validation that must not be skipped.\n\nInstead of:\n\n```\nbuild xyz\n```\n\nmodel the work as:\n\n```\nwhat is the optimized implementation,\ngiven what must stay true?\n```\n\nThe result is a more disciplined implementation plan: fewer accidental side effects, clearer tradeoffs, smaller edits, and validation tied to the actual constraints of the work.\n\nFor coding agents, those constraints are usually concrete:\n\n- existing architecture and public contracts\n- files, modules, endpoints, schemas, and migrations\n- security, privacy, and data-integrity rules\n- ui and product boundaries\n- infrastructure and runtime limits\n- validation evidence required to prove completion\n\nThe core idea:\n\n```\nchoose\n  x in X\n\nmaximize\n  alignment(user_goal, x)\n\nsubject to\n  C_app(x)\n  C_arch(x)\n  C_data(x)\n  C_ui(x)\n  C_infra(x)\n  C_validation(x)\n```\n\nwhere:\n\n`x`\n\nis the implementation decision vector`X`\n\nis the feasible implementation region`C_*`\n\nare application constraints- the selected plan is the best feasible plan, not the first plausible plan\n- validation is the certificate that the selected plan satisfies the model\n\nInstall with curl:\n\n```\ncurl -fsSL https://raw.githubusercontent.com/dannylee1020/kkt/main/scripts/install.sh | bash\n```\n\nBy default, this installs the skills for Codex, Claude Code, Pi, and OpenCode using their shared skill locations:\n\n```\n~/.agents/skills\n~/.claude/skills\n```\n\nTarget-specific paths are also available for agents that prefer their own skill directory:\n\n```\nCodex:       ~/.agents/skills\nClaude Code: ~/.claude/skills\nPi:          ~/.pi/agent/skills\nOpenCode:    ~/.config/opencode/skills\n```\n\nUseful options:\n\n```\n--target codex\n--target claude\n--target pi\n--target opencode\n--local\n--dry-run\n```\n\nFrom a checkout:\n\n```\nscripts/install.sh\n```\n\nUse the skill syntax supported by your agent:\n\n```\nCodex:       $kkt\nClaude Code: /kkt\nPi:          /skill:kkt\nOpenCode:    ask OpenCode to use the kkt skill\n```\n\nStart with a rough request:\n\n```\nUse $kkt to add export-to-csv for reports.\n```\n\nAdd constraints only when you already know them:\n\n```\nUse $kkt to add export-to-csv for reports.\n\nConstraints:\n- Reuse the existing reports api.\n- Do not change billing code.\n- Do not add dependencies.\n\nValidation:\n- Add or update the smallest useful test.\n- Run the relevant test command if available.\n```\n\nkkt should inspect the repo, infer discoverable constraints, and ask only for decisions that materially affect feasibility, product behavior, risk, or execution mode.\n\nDefault agent flow:\n\n``` php\nuser request\n  -> plausible plan\n  -> edits\n  -> summary\n```\n\nwith kkt:\n\n``` php\nuser request\n  -> request intake\n  -> constraint discovery\n  -> feasible region\n  -> selected plan\n  -> focused edits\n  -> validation certificate\n```\n\nThe contract:\n\n```\noptimization model   objective, variables, constraints, feasible region, selected plan\nsolution audit       binding constraints and sensitivity analysis\nexecution contract   acceptance criteria, validation plan, evidence, stop conditions\n```\n\n| skill | use it for | output |\n|---|---|---|\n`$kkt` |\nnormal feature work, bug fixes, and refactors | model, implement, validate |\n`$kkt-loop` |\nlong-running or autonomous work | durable workspace, progress, evidence |\n`$kkt-model` |\narchitecture choices and tradeoff analysis | selected model or decision brief |\n\n`$kkt`\n\nis lightweight and does not create durable files by default.\n\n`$kkt-loop`\n\ncreates `.kkt/<slug>/`\n\nwith:\n\n```\nmodel.md\nplan.md\nevidence.md\nprogress.md\nnotes.md\n```\n\n`$kkt-model`\n\nis non-mutating by default. It inspects, models, compares feasible alternatives, and asks for user input only when the tradeoff cannot be resolved from the repo.\n\nkkt turns rough input into a request frame before modeling:\n\n```\nobjective\nknown non-goals\nconstraints\nvalidation expectations\n```\n\nThe user does not need to provide all of this upfront. Missing fields are inferred from the codebase when possible and marked as assumptions when needed.\n\nExpected final audit:\n\n```\nObjective: satisfied\nHard constraints: satisfied\nBinding constraints: respected\nValidation evidence: tests, checks, artifacts, or reason validation was not possible\nResidual risk: remaining uncertainty\n```\n\nApache-2.0", "url": "https://wpnews.pro/news/constrained-modeling-for-coding-agents", "canonical_source": "https://github.com/dannylee1020/kkt", "published_at": "2026-06-18 22:20:58+00:00", "updated_at": "2026-06-18 22:31:01.486646+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["kkt", "Codex", "Claude Code", "Pi", "OpenCode", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/constrained-modeling-for-coding-agents", "markdown": "https://wpnews.pro/news/constrained-modeling-for-coding-agents.md", "text": "https://wpnews.pro/news/constrained-modeling-for-coding-agents.txt", "jsonld": "https://wpnews.pro/news/constrained-modeling-for-coding-agents.jsonld"}}