Wink Pings

Rules for AI Agents: Turn Them Into Code Instead of Leaving Them in Markdown

Lauren Tan shares a reusable prompt to audit natural language rules written for AI agents, including AGENTS.md, Cursor rules, skill documents and more. It converts as many rule segments as possible into type definitions, lint checks and executable tests. This article explains the problems the prompt solves and how to get started with it.

Lauren Tan shared a reusable prompt on X that audits unstructured text written for AI agents in code repositories. The goal is straightforward: move every applicable part of rules stored in files like AGENTS.md, skill docs and Cursor rules out of natural language, and turn them into executable code, type definitions, lint checks and tests whenever possible.

This work is well worth a look for developers. A growing number of code repos now have a dedicated layer of "instruction manuals for AI": an AGENTS.md file at the root directory, over a dozen rule files under the .cursor/rules folder, and a full set of workflow guides in the skills directory. When a new AI agent accesses the project and reads through these materials, it might end up following conventions agreed on three months ago, or even run into two conflicting rules. Over time, these documents bloat into a messy, unmaintainable internal policy handbook no one dares to edit or delete.

Natural language rules have very clear flaws. They rely on the AI agent to follow them voluntarily, on human engineers to remember to update them, and on sufficient capacity in the context window to store all of them completely. No matter how detailed you write these rules, they will drift away from the original requirements over time without hard enforcement. Development teams have long known this principle, which is why they put all critical constraints into type systems, linting pipelines, unit tests and CI workflows. But for AI coding agents, far too many constraints are still only stored in Markdown files.

Lauren Tan's prompt is built specifically to fill this gap. Per its official description, it audits all agent-facing unstructured text in the repository, and identifies which rules can be replaced with more rigid, enforceable implementations. For example, the rule "all tests must pass before a commit" can be enforced via CI; "this function only accepts parameters of a specific type" can be implemented via type definitions; "do not use a certain deprecated API" can be added to lint rules; "output must conform to a specific structure" can be validated by tests or schema checks. Only the content that truly requires explaining background context, tradeoffs and edge cases stays written in natural language.

Regular users can think of this process as a repository health check. The natural language guides for AI agents are like new employee handbooks: useful, but they go out of date very easily. Code, type definitions, lint checks and tests act as access controls and standardized checklists that never rely on human or AI memory. Both approaches are necessary, but the ratio between them is definitely worth readjusting.

If you want to try this workflow, we recommend letting your coding agent list every rule line by line for each relevant file, then mark for each rule whether it can be converted to code, what the alternative implementation is, the corresponding migration risk, and the reason to keep it as natural language if applicable. Run a small pilot first, do not rewrite all existing rules in one go. The prompt is not a magic solution, and human review is still required for all final results.

Original post link: Lauren Tan's post

AIHOT entry: https://aihot.news/items/f6a8lbw8efzb36x3cnqzbpvz5

发布时间: 2026-12-04 05:01