<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Denis on Medium]]></title>
        <description><![CDATA[Stories by Denis on Medium]]></description>
        <link>https://medium.com/@devlato?source=rss-6eb902b4018------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_82ustRiUhsq_SJxiwVWKg.png</url>
            <title>Stories by Denis on Medium</title>
            <link>https://medium.com/@devlato?source=rss-6eb902b4018------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:10:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devlato/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Rule That Writes the Rules: Exploring rules.mdc]]></title>
            <link>https://medium.com/@devlato/a-rule-that-writes-the-rules-exploring-rules-mdc-288dc6cf4092?source=rss-6eb902b4018------2</link>
            <guid isPermaLink="false">https://medium.com/p/288dc6cf4092</guid>
            <category><![CDATA[rules]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[cursor]]></category>
            <dc:creator><![CDATA[Denis]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 15:34:34 GMT</pubDate>
            <atom:updated>2025-04-12T15:46:54.397Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ks45ghe2N8ROA3WM" /><figcaption>Source: <a href="https://unsplash.com/photos/white-arrow-logo-deb2EnbWPr8">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/@devlato/are-your-cursor-rules-actually-working-f470026ba11f">my previous article</a>, I introduced a strict format for Cursor rules using YAML frontmatter and a pseudo-XML body. That format helps LLMs reliably follow rule files instead of guessing.</p><p>This post explores the rule that defines that format: rules.mdc.</p><p>It’s not just a helpful convention. It’s a hard contract that ensures all other rules are structured, interpretable, and enforceable — both by Cursor and other agents.</p><h3>What Is rules.mdc?</h3><p>rules.mdc defines the schema for all .mdc rule files.</p><p>If you’re writing or maintaining Cursor rules, this file is the standard they must follow. It covers structure, grammar, examples, language, and relationships between rules.</p><p>Its full source is provided below.</p><pre>---<br>description: Rules for writing .mdc files (Cursor rules)<br>globs: &quot;*.mdc&quot;<br>alwaysApply: true<br>---<br><br>&lt;rule&gt;<br>  &lt;meta&gt;<br>    &lt;title&gt;Cursor Rule File Format (.mdc)&lt;/title&gt;<br>    &lt;description&gt;Standard format and requirements for writing .mdc files (Cursor rules)&lt;/description&gt;<br>    &lt;created-at utc-timestamp=&quot;1744157700&quot;&gt;April 9, 2025, 10:15 AM AEST&lt;/created-at&gt;<br>    &lt;last-updated-at utc-timestamp=&quot;1744240920&quot;&gt;April 10, 2025, 09:22 AM AEST&lt;/last-updated-at&gt;<br>    &lt;applies-to&gt;<br>      &lt;file-matcher glob=&quot;*.mdc&quot;&gt;All Cursor rule files with .mdc extension&lt;/file-matcher&gt;<br>      &lt;action-matcher action=&quot;create-rule&quot;&gt;Triggered when creating a new Cursor rule&lt;/action-matcher&gt;<br>    &lt;/applies-to&gt;<br>  &lt;/meta&gt;<br>  &lt;requirements&gt;<br>    &lt;requirement priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Follow the specified structure for .mdc files, starting with YAML frontmatter followed by XML-like rule representation.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Basic Rule Structure&quot;&gt;<br>          &lt;correct-example title=&quot;Properly structured rule file&quot; conditions=&quot;Creating a new rule file&quot; expected-result=&quot;Valid .mdc file structure&quot; correctness-criteria=&quot;Follows the required format with frontmatter and XML structure&quot;&gt;&lt;![CDATA[---<br>description: Example rule<br>globs: &quot;*.js&quot;<br>alwaysApply: false<br>---<br><br>&lt;rule&gt;<br>  &lt;meta&gt;<br>    &lt;title&gt;JavaScript Formatting Rule&lt;/title&gt;<br>    &lt;description&gt;Ensures consistent formatting in JavaScript files&lt;/description&gt;<br>    &lt;!-- Additional meta elements --&gt;<br>  &lt;/meta&gt;<br>  &lt;!-- Additional rule elements --&gt;<br>&lt;/rule&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Improperly structured rule file&quot; conditions=&quot;Creating a new rule file&quot; expected-result=&quot;Valid .mdc file structure&quot; incorrectness-criteria=&quot;Missing frontmatter and incorrect XML structure&quot;&gt;&lt;![CDATA[&lt;rule&gt;<br>  &lt;meta&gt;<br>    &lt;title&gt;JavaScript Formatting Rule&lt;/title&gt;<br>    &lt;description&gt;Ensures consistent formatting in JavaScript files&lt;/description&gt;<br>  &lt;/meta&gt;<br>&lt;/rule&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;requirement priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Use concise, clear, and unambiguous language throughout the rule.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Language Clarity&quot;&gt;<br>          &lt;correct-example title=&quot;Clear requirement description&quot; conditions=&quot;Writing a requirement&quot; expected-result=&quot;Unambiguous instruction&quot; correctness-criteria=&quot;Uses precise, clear language&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;high&quot;&gt;<br>  &lt;description&gt;Limit function length to maximum 30 lines of code.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Ambiguous requirement description&quot; conditions=&quot;Writing a requirement&quot; expected-result=&quot;Clear instruction&quot; incorrectness-criteria=&quot;Uses vague, imprecise language&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;high&quot;&gt;<br>  &lt;description&gt;Functions should not be too long.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;requirement priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Include concrete examples that demonstrate correct and incorrect applications of the rule.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Providing Related Examples&quot;&gt;<br>          &lt;correct-example title=&quot;Related correct/incorrect examples&quot; conditions=&quot;Demonstrating a naming convention rule&quot; expected-result=&quot;Examples that clearly show the contrast&quot; correctness-criteria=&quot;Examples are directly related and show the same concept correctly and incorrectly&quot;&gt;&lt;![CDATA[&lt;example title=&quot;Variable Naming&quot;&gt;<br>  &lt;correct-example title=&quot;Proper camelCase&quot; conditions=&quot;Naming a variable&quot; expected-result=&quot;Valid variable name&quot; correctness-criteria=&quot;Uses camelCase format&quot;&gt;const userName = &#39;John&#39;;&lt;/correct-example&gt;<br>  &lt;incorrect-example title=&quot;Improper snake_case&quot; conditions=&quot;Naming a variable&quot; expected-result=&quot;Valid variable name&quot; incorrectness-criteria=&quot;Uses snake_case instead of required camelCase&quot;&gt;const user_name = &#39;John&#39;;&lt;/incorrect-example&gt;<br>&lt;/example&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Unrelated examples&quot; conditions=&quot;Demonstrating a naming convention rule&quot; expected-result=&quot;Clear contrast between correct and incorrect&quot; incorrectness-criteria=&quot;Examples show different concepts and aren&#39;t directly comparable&quot;&gt;&lt;![CDATA[&lt;example title=&quot;Variable Naming&quot;&gt;<br>  &lt;correct-example title=&quot;Proper camelCase&quot; conditions=&quot;Naming a variable&quot; expected-result=&quot;Valid variable name&quot; correctness-criteria=&quot;Uses camelCase format&quot;&gt;const userName = &#39;John&#39;;&lt;/correct-example&gt;<br>  &lt;incorrect-example title=&quot;Missing semicolon&quot; conditions=&quot;Ending a statement&quot; expected-result=&quot;Statement with semicolon&quot; incorrectness-criteria=&quot;Lacks required semicolon&quot;&gt;const age = 30&lt;/incorrect-example&gt;<br>&lt;/example&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;requirement priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;All other rule files (.mdc) must reference this file as a dependency in their references section.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Rule Dependency Reference&quot;&gt;<br>          &lt;correct-example title=&quot;Proper dependency reference&quot; conditions=&quot;Creating a new rule file&quot; expected-result=&quot;Valid reference to rules.mdc&quot; correctness-criteria=&quot;Includes proper reference to the main rules file&quot;&gt;&lt;![CDATA[&lt;references&gt;<br>  &lt;reference as=&quot;dependency&quot; href=&quot;.cursor/rules/rules.mdc&quot; reason=&quot;Follows standard rule format&quot;&gt;Base rule format definition&lt;/reference&gt;<br>  &lt;!-- Other references as needed --&gt;<br>&lt;/references&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Missing dependency reference&quot; conditions=&quot;Creating a new rule file&quot; expected-result=&quot;Valid reference to rules.mdc&quot; incorrectness-criteria=&quot;Missing required reference to the main rules file&quot;&gt;&lt;![CDATA[&lt;references&gt;<br>  &lt;reference as=&quot;context&quot; href=&quot;.cursor/rules/other-file.mdc&quot; reason=&quot;Related context&quot;&gt;Additional context&lt;/reference&gt;<br>  &lt;!-- No reference to the main rules.mdc file --&gt;<br>&lt;/references&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;requirement priority=&quot;high&quot;&gt;<br>      &lt;description&gt;Use CDATA tags for multiline content within XML elements.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;CDATA Usage&quot;&gt;<br>          &lt;correct-example title=&quot;Proper CDATA wrapping&quot; conditions=&quot;Including multiline content&quot; expected-result=&quot;Properly escaped content&quot; correctness-criteria=&quot;Uses CDATA tags correctly&quot;&gt;&lt;![CDATA[&lt;example title=&quot;Function Structure&quot;&gt;<br>  &lt;correct-example title=&quot;Properly structured function&quot; conditions=&quot;Writing a function&quot; expected-result=&quot;Valid function definition&quot; correctness-criteria=&quot;Follows the style guide&quot;&gt;&lt;![CDATA[function calculateTotal(items) {<br>  let sum = 0;<br>  for (const item of items) {<br>    sum += item.price;<br>  }<br>  return sum;<br>}]]]]&gt;&lt;![CDATA[&gt;&lt;/correct-example&gt;<br>&lt;/example&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Missing CDATA tags&quot; conditions=&quot;Including multiline content&quot; expected-result=&quot;Properly escaped content&quot; incorrectness-criteria=&quot;Lacks required CDATA tags&quot;&gt;&lt;![CDATA[&lt;example title=&quot;Function Structure&quot;&gt;<br>  &lt;correct-example title=&quot;Properly structured function&quot; conditions=&quot;Writing a function&quot; expected-result=&quot;Valid function definition&quot; correctness-criteria=&quot;Follows the style guide&quot;&gt;function calculateTotal(items) {<br>  let sum = 0;<br>  for (const item of items) {<br>    sum += item.price;<br>  }<br>  return sum;<br>}&lt;/correct-example&gt;<br>&lt;/example&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;non-negotiable priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Always maintain precise structure and avoid ambiguity in rule definitions.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Precision and Clarity&quot;&gt;<br>          &lt;correct-example title=&quot;Precise rule specification&quot; conditions=&quot;Defining a coding standard&quot; expected-result=&quot;Clear, actionable rule&quot; correctness-criteria=&quot;Provides specific, measurable criteria&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;high&quot;&gt;<br>  &lt;description&gt;Maximum line length must be 80 characters. Lines exceeding this limit must be broken with line continuation.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Ambiguous rule specification&quot; conditions=&quot;Defining a coding standard&quot; expected-result=&quot;Clear, actionable rule&quot; incorrectness-criteria=&quot;Uses subjective language without measurable criteria&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;high&quot;&gt;<br>  &lt;description&gt;Keep lines to a reasonable length and break them when they get too long.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>    &lt;non-negotiable priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Create rules that address only the specified problem without introducing unrelated constraints or assumptions.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Problem-Specific Rules&quot;&gt;<br>          &lt;correct-example title=&quot;Focused rule&quot; conditions=&quot;Creating a rule for import ordering&quot; expected-result=&quot;Rule addressing only import ordering&quot; correctness-criteria=&quot;Stays focused on the specific problem&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;medium&quot;&gt;<br>  &lt;description&gt;Group imports in the following order: built-in modules, external dependencies, internal modules.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Overreaching rule&quot; conditions=&quot;Creating a rule for import ordering&quot; expected-result=&quot;Rule addressing only import ordering&quot; incorrectness-criteria=&quot;Introduces unrelated constraints&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;medium&quot;&gt;<br>  &lt;description&gt;Group imports in the following order: built-in modules, external dependencies, internal modules. Also ensure all code is properly commented and functions have error handling.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>    &lt;non-negotiable priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Use single line content when possible, reserving multiline format only for examples or when absolutely necessary.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Line Format Efficiency&quot;&gt;<br>          &lt;correct-example title=&quot;Concise single-line description&quot; conditions=&quot;Writing a requirement description&quot; expected-result=&quot;Brief, clear description&quot; correctness-criteria=&quot;Uses single line for concise content&quot;&gt;&lt;![CDATA[&lt;description&gt;Use camelCase for variable names and PascalCase for class names.&lt;/description&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Unnecessarily multi-line description&quot; conditions=&quot;Writing a requirement description&quot; expected-result=&quot;Brief, clear description&quot; incorrectness-criteria=&quot;Splits simple content across multiple lines&quot;&gt;&lt;![CDATA[&lt;description&gt;<br>  Use camelCase for variable names<br>  and PascalCase for class names.<br>&lt;/description&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>    &lt;non-negotiable priority=&quot;critical&quot;&gt;<br>      &lt;description&gt;Mark critical requirements that are most likely to be misinterpreted as non-negotiable with high priority.&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;Non-negotiable Designation&quot;&gt;<br>          &lt;correct-example title=&quot;Properly marked critical requirement&quot; conditions=&quot;Defining a security standard&quot; expected-result=&quot;Clearly marked non-negotiable rule&quot; correctness-criteria=&quot;Uses non-negotiable tag with critical priority&quot;&gt;&lt;![CDATA[&lt;non-negotiable priority=&quot;critical&quot;&gt;<br>  &lt;description&gt;Never store passwords or API keys in source code.&lt;/description&gt;<br>&lt;/non-negotiable&gt;]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;Improperly categorized critical requirement&quot; conditions=&quot;Defining a security standard&quot; expected-result=&quot;Clearly marked non-negotiable rule&quot; incorrectness-criteria=&quot;Uses regular requirement tag for critical security rule&quot;&gt;&lt;![CDATA[&lt;requirement priority=&quot;high&quot;&gt;<br>  &lt;description&gt;Never store passwords or API keys in source code.&lt;/description&gt;<br>&lt;/requirement&gt;]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>  &lt;/requirements&gt;<br>  &lt;grammar&gt;<br>    &lt;grammar-entry title=&quot;Frontmatter Structure&quot;&gt;<br>      &lt;pattern description=&quot;YAML frontmatter format&quot;&gt;^---\ndescription: .+\nglobs: .+\nalwaysApply: (true|false)\n---$&lt;/pattern&gt;<br>      &lt;example description=&quot;Valid frontmatter&quot;&gt;---<br>description: Rule for consistent comment formatting<br>globs: &quot;*.{js,ts}&quot;<br>alwaysApply: false<br>---&lt;/example&gt;<br>    &lt;/grammar-entry&gt;<br>    &lt;grammar-entry title=&quot;XML Structure&quot;&gt;<br>      &lt;pattern description=&quot;Valid rule element structure&quot;&gt;&amp;lt;rule&amp;gt;(\s*&amp;lt;meta&amp;gt;.+&amp;lt;/meta&amp;gt;\s*&amp;lt;requirements&amp;gt;.+&amp;lt;/requirements&amp;gt;(\s*&amp;lt;grammar&amp;gt;.+&amp;lt;/grammar&amp;gt;)?(\s*&amp;lt;context&amp;gt;.+&amp;lt;/context&amp;gt;)?(\s*&amp;lt;references&amp;gt;.+&amp;lt;/references&amp;gt;)?)&amp;lt;/rule&amp;gt;&lt;/pattern&gt;<br>    &lt;/grammar-entry&gt;<br>    &lt;schema title=&quot;Cursor Rule Schema&quot; description=&quot;Standard structure for .mdc cursor rule files&quot;&gt;<br>&lt;![CDATA[---<br>description: {Rule description}<br>globs: {glob patterns of files this rule applies to, or wildcard glob that matches all files if alwaysApply is true}<br>alwaysApply: {true or false}<br>---<br><br>&lt;rule&gt;<br>  &lt;meta&gt;<br>    &lt;title&gt;{Rule title}&lt;/title&gt;<br>    &lt;description&gt;{Rule description}&lt;/description&gt;<br>    &lt;created-at utc-timestamp=&quot;{creation timestamp in UTC}&quot;&gt;{Datetime of creation in human-readable form and local time}&lt;/created-at&gt;<br>    &lt;last-updated-at utc-timestamp=&quot;{last update timestamp in UTC}&quot;&gt;{Last update date and time in human-readable form and local time}&lt;/last-updated-at&gt;<br>    &lt;applies-to&gt;<br>      &lt;file-matcher glob=&quot;{glob pattern}&quot;&gt;{Description of files that match the glob}&lt;/file-matcher&gt;<br>      &lt;!-- Repeat for each glob or use a wildcard glob if alwaysApply is true --&gt;<br>      &lt;!-- Optional action matcher --&gt;<br>      &lt;action-matcher action=&quot;{keyword for trigger action}&quot;&gt;{Description of action that triggers this rule}&lt;/action&gt;<br>    &lt;/applies-to&gt;<br>  &lt;/meta&gt;<br>  &lt;requirements&gt;<br>    &lt;requirement priority=&quot;{priority keyword: high, medium, critical, etc.}&quot;&gt;<br>      &lt;description&gt;{Requirement description}&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;{example title}&quot;&gt;<br>          &lt;correct-example title=&quot;{scenario title}&quot; conditions=&quot;{conditions description}&quot; expected-result=&quot;{expected result}&quot; correctness-criteria=&quot;{correctness criteria}&quot;&gt;{Example content}&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;{scenario title}&quot; conditions=&quot;{conditions description}&quot; expected-result=&quot;{expected result}&quot; incorrectness-criteria=&quot;{incorrectness criteria}&quot;&gt;{Example content}&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>        &lt;!-- Repeat for each example --&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;!-- Repeat for each requirement --&gt;<br>    &lt;non-negotiable priority=&quot;{priority keyword: high, medium, critical, etc.}&quot;&gt;<br>      &lt;description&gt;{Non-negotiable requirement description}&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;{example title}&quot;&gt;<br>          &lt;correct-example title=&quot;{scenario title}&quot; conditions=&quot;{conditions description}&quot; expected-result=&quot;{expected result}&quot; correctness-criteria=&quot;{correctness criteria}&quot;&gt;{Example content}&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;{scenario title}&quot; conditions=&quot;{conditions description}&quot; expected-result=&quot;{expected result}&quot; incorrectness-criteria=&quot;{incorrectness criteria}&quot;&gt;{Example content}&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>        &lt;!-- Repeat for each example --&gt;<br>      &lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>    &lt;!-- Repeat for each non-negotiable requirement --&gt;<br>  &lt;/requirements&gt;<br>  &lt;grammar&gt;<br>    &lt;grammar-entry title=&quot;{grammar requirement title}&quot;&gt;<br>      &lt;pattern description=&quot;{pattern description}&quot;&gt;{grammar pattern}&lt;/pattern&gt;<br>      &lt;!-- Repeat for each pattern --&gt;<br>      &lt;example description=&quot;{example description}&quot;&gt;{example content}&lt;/example&gt;<br>      &lt;!-- Repeat for each example --&gt;<br>    &lt;/grammar-entry&gt;<br>    &lt;!-- Repeat for each grammar entry --&gt;<br>    &lt;schema title=&quot;{schema title}&quot; description=&quot;{schema description}&quot;&gt;<br>      &lt;!-- Include schema definition here if applicable --&gt;<br>    &lt;/schema&gt;<br>  &lt;/grammar&gt;<br>  &lt;!-- Optional context section --&gt;<br>  &lt;context description=&quot;{context description}&quot;&gt;<br>    {Additional information for rule application}<br>  &lt;/context&gt;<br>  &lt;!-- Optional references section --&gt;<br>  &lt;references&gt;<br>    &lt;reference as=&quot;{reference type: context, dependency, glossary, examples}&quot; href=&quot;{path to referenced file}&quot; reason=&quot;{reason for reference}&quot;&gt;{Reference description}&lt;/reference&gt;<br>    &lt;!-- Repeat for each reference --&gt;<br>  &lt;/references&gt;<br>&lt;/rule&gt;]]&gt;<br>    &lt;/schema&gt;<br>  &lt;/grammar&gt;<br>  &lt;context description=&quot;Additional considerations for creating Cursor rules&quot;&gt;<br>    The primary purpose of a Cursor rule (.mdc file) is to provide clear, unambiguous guidance that can be consistently applied. The rule acts essentially as a prompt or part of a prompt for an LLM, so clarity and precision are paramount. When creating rules, focus on solving only the specific problem the rule is intended to address, avoiding scope creep or assumptions based on common knowledge unless explicitly requested.<br>  &lt;/context&gt;<br>&lt;/rule&gt;</pre><h3>Explanation</h3><h4>1. YAML Frontmatter</h4><p>Every rule starts with:</p><pre>---<br>description: Summary of the rule<br>globs: &quot;*.ts&quot;<br>alwaysApply: false<br>---</pre><p>This defines the rule’s scope. All three fields are required.</p><h4>2. meta</h4><p>The metadata section includes:</p><ul><li>&lt;title&gt; and &lt;description&gt;: Clear and concise</li><li>&lt;created-at&gt; / &lt;last-updated-at&gt;: With required UTC timestamps</li><li>&lt;applies-to&gt;: Specifies what files or actions the rule applies to</li><li>&lt;file-matcher&gt;: Glob patterns</li><li>&lt;action-matcher&gt; (optional): Action-based triggers</li></ul><p>This metadata helps LLMs and tools reason about when the rule should activate and what context it belongs in.</p><h4>3. requirements</h4><p>This is the core of the rule. It defines what must be enforced and at what priority:</p><ul><li>Use &lt;requirement priority=&quot;...&quot;&gt; for guidance (e.g., high, medium)</li><li>Use &lt;non-negotiable priority=&quot;...&quot;&gt; for strict enforcement (e.g., critical)</li></ul><p>Each requirement must:</p><ul><li>Contain a &lt;description&gt; that is specific and measurable</li><li>Include a matching &lt;examples&gt; block with both &lt;correct-example&gt; and &lt;incorrect-example&gt;</li><li>Focus on a single behavior or concept</li></ul><p>This is not just for logic — it’s for priority alignment. Rules must clearly express their intent and weight.</p><h4>4. references</h4><p>This section defines relationships between rules.</p><p>You use &lt;reference&gt; to explicitly state what another rule file contributes to this one.</p><p>Each reference must include:</p><ul><li>as: One of dependency, context, glossary, or examples</li><li>href: Path to the other rule file</li><li>Reason: Plain text explanation</li></ul><p>Example:</p><pre>&lt;references&gt;<br>  &lt;reference as=&quot;dependency&quot; href=&quot;.cursor/rules/specifications.mdc&quot; reason=&quot;Defines spec-first behavior&quot;&gt;specifications.mdc&lt;/reference&gt;<br>  &lt;reference as=&quot;context&quot; href=&quot;.cursor/rules/conventions.mdc&quot; reason=&quot;Naming rules this depends on&quot;&gt;conventions.mdc&lt;/reference&gt;<br>&lt;/references&gt;</pre><p>This improves explainability and traceability across large rule sets. It’s also important for LLMs consuming multiple files at once.</p><h4>5. grammar and schema</h4><p>Rules can define regex-validated structures or full file schemas. This enables static validation or structural alignment across rules.</p><p>Example grammar:</p><pre>&lt;grammar-entry title=&quot;YAML frontmatter&quot;&gt;<br>  &lt;pattern description=&quot;Required keys&quot;&gt;^---\ndescription:.+\nglobs:.+\nalwaysApply:.+\n---$&lt;/pattern&gt;<br>&lt;/grammar-entry&gt;</pre><p>The &lt;schema&gt; section defines a canonical .mdc rule structure with placeholders. This allows agents to verify or generate rules consistently.</p><h4>6. context (optional)</h4><p>If a rule needs additional explanation — such as assumptions, scope limits, or motivations — it goes here.</p><pre>&lt;context description=&quot;Why this rule exists&quot;&gt;<br>  Prevents inconsistency in rule structure and helps validate rules programmatically.<br>&lt;/context&gt;</pre><h3>Why It Matters</h3><p>rules.mdc makes rule writing:</p><ul><li>Consistent — across contributors and tools</li><li>Enforceable — by both AI and humans</li><li>Traceable — via references and structured meta</li><li>Validatable — with optional grammar and schema</li></ul><p>It keeps rule files from turning into vague Markdown lists or pseudo-guides. It replaces guesswork with contract enforcement.</p><h3>Recap</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ay2Xv1iKrvtdBCQb" /><figcaption>Source: <a href="https://unsplash.com/photos/two-men-facing-each-other-while-shake-hands-and-smiling-NbtIDoFKGO8">Unsplash</a></figcaption></figure><p>If you’re maintaining rules for an LLM-driven workflow, you need a standard for how those rules are written.</p><p>That standard is rules.mdc.</p><p>It defines the format, language, priority model, structure, and relationships for every rule file in your system.</p><p>Reference it. Follow it. Use it to validate your rules.</p><p>If you don’t — you’ll drift into ambiguity and inconsistency. If you do — you get repeatable, predictable, automatable behavior from any LLM working with your project.</p><p>That’s the point.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=288dc6cf4092" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are Your Cursor Rules Actually Working?]]></title>
            <link>https://medium.com/@devlato/are-your-cursor-rules-actually-working-f470026ba11f?source=rss-6eb902b4018------2</link>
            <guid isPermaLink="false">https://medium.com/p/f470026ba11f</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[cursor]]></category>
            <category><![CDATA[rules]]></category>
            <dc:creator><![CDATA[Denis]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 14:02:53 GMT</pubDate>
            <atom:updated>2025-04-12T15:36:55.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wO_rd47MwMoGz2MI" /><figcaption>Source: <a href="https://unsplash.com/photos/cursor-on-black-background-wB7V7mhufy4">Unsplash</a></figcaption></figure><p>If you’re writing .mdc files for <a href="https://www.cursor.so/">Cursor</a> or feeding custom rules into LLMs like <a href="https://claude.ai/">Claude</a>, here&#39;s a question for you:</p><p>Are those rules doing what you think they’re doing?</p><p>If you’re using vague Markdown bullets or stuffing random YAML into a .mdc, chances are: they&#39;re not.</p><p>LLMs don’t guess. They follow structure. And if that structure sucks — so does the output.</p><p>But there’s a fix.</p><h3>The Problem With Most .mdc Files</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fNWjao5wmSsOdeKc" /><figcaption>Source: <a href="https://www.pexels.com/photo/bionic-hand-and-human-hand-finger-pointing-6153354/">Unsplash</a></figcaption></figure><p>Let’s be honest: most .mdc files out there look like rough notes or loose guidelines. And sure, that might help <em>a bit</em> — until something breaks, or the AI &quot;forgets&quot; your rule halfway through a refactor.</p><p>Why?</p><p>Because there’s no clarity. No enforceable structure. No consistency.</p><p>And Cursor? It only cares about a few things:</p><ul><li>description</li><li>globs</li><li>alwaysApply</li></ul><p>Everything else? Just raw text passed into a prompt.</p><p>If that text isn’t <em>rigidly structured</em>, the AI will treat it like a vague suggestion.</p><h3>The Format That Actually Works</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iIUVkxj9mPu_z9O0" /><figcaption>Source: <a href="https://www.pexels.com/photo/black-flat-screen-computer-monitor-4584830/">Unsplash</a></figcaption></figure><p>Here’s what does work — every time:</p><ul><li>Start with YAML frontmatter to control when the rule loads</li><li>Follow with a pseudo-XML rule body that describes:</li><li>What the rule is</li><li>What must happen</li><li>What must never happen</li><li>Concrete examples</li><li>Optional grammar or schema</li><li>References to other rule files</li></ul><p>This format is readable by humans, parsable by LLMs, and enforceable in Cursor.</p><p>You don’t have to invent it. You just have to follow the one rule that defines how to write rules: rules.mdc.</p><h3>The Correct Rule Schema</h3><p>Below is the structure Cursor agents and other LLMs (like Claude or GPT-4) will interpret correctly and follow with high accuracy:</p><pre>&lt;rule&gt;<br>  &lt;meta&gt;<br>    &lt;title&gt;{Title}&lt;/title&gt;<br>    &lt;description&gt;{What this rule enforces}&lt;/description&gt;<br>    &lt;created-at utc-timestamp=&quot;{timestamp}&quot;&gt;{Human date}&lt;/created-at&gt;<br>    &lt;last-updated-at utc-timestamp=&quot;{timestamp}&quot;&gt;{Human date}&lt;/last-updated-at&gt;<br>    &lt;applies-to&gt;<br>      &lt;file-matcher glob=&quot;{glob}&quot;&gt;{Optional description}&lt;/file-matcher&gt;<br>      &lt;action-matcher action=&quot;{optional-trigger}&quot;&gt;{Optional description}&lt;/action-matcher&gt;<br>    &lt;/applies-to&gt;<br>  &lt;/meta&gt;<br>  &lt;requirements&gt;<br>    &lt;requirement priority=&quot;{critical|high|medium|low}&quot;&gt;<br>      &lt;description&gt;{Clear requirement}&lt;/description&gt;<br>      &lt;examples&gt;<br>        &lt;example title=&quot;{Example title}&quot;&gt;<br>          &lt;correct-example title=&quot;{Context}&quot; conditions=&quot;{Preconditions}&quot; expected-result=&quot;{Expected output}&quot; correctness-criteria=&quot;{Why it&#39;s right}&quot;&gt;&lt;![CDATA[<br>            // Valid example code<br>          ]]&gt;&lt;/correct-example&gt;<br>          &lt;incorrect-example title=&quot;{Context}&quot; conditions=&quot;{Preconditions}&quot; expected-result=&quot;{Expected output}&quot; incorrectness-criteria=&quot;{Why it&#39;s wrong}&quot;&gt;&lt;![CDATA[<br>            // Invalid example code<br>          ]]&gt;&lt;/incorrect-example&gt;<br>        &lt;/example&gt;<br>      &lt;/examples&gt;<br>    &lt;/requirement&gt;<br>    &lt;non-negotiable priority=&quot;{critical|high}&quot;&gt;<br>      &lt;description&gt;{This MUST be followed}&lt;/description&gt;<br>      &lt;examples&gt;...&lt;/examples&gt;<br>    &lt;/non-negotiable&gt;<br>  &lt;/requirements&gt;<br>  &lt;grammar&gt;<br>    &lt;grammar-entry title=&quot;{Pattern name}&quot;&gt;<br>      &lt;pattern description=&quot;{What this enforces}&quot;&gt;{Regex}&lt;/pattern&gt;<br>      &lt;example description=&quot;{Valid usage}&quot;&gt;{Pattern example}&lt;/example&gt;<br>    &lt;/grammar-entry&gt;<br>    &lt;schema title=&quot;{Schema title}&quot; description=&quot;{Schema description}&quot;&gt;&lt;![CDATA[<br>      &lt;rule&gt;...&lt;/rule&gt;<br>    ]]&gt;&lt;/schema&gt;<br>  &lt;/grammar&gt;<br>  &lt;references&gt;<br>    &lt;reference as=&quot;dependency&quot; href=&quot;.cursor/rules/rules.mdc&quot; reason=&quot;Follows standard rule format&quot;&gt;rules.mdc&lt;/reference&gt;<br>  &lt;/references&gt;<br>&lt;/rule&gt;</pre><h3>How the Schema Works</h3><p>Each .mdc rule file must follow a two-part format:</p><h4>1. YAML Frontmatter</h4><p>This tells Cursor when the rule applies:</p><pre>---<br>description: Enforces camelCase naming<br>globs: &quot;*.ts&quot;<br>alwaysApply: false<br>---</pre><h4>2. Pseudo-XML Rule Body</h4><p>This contains everything the LLM uses:</p><h4>&lt;meta&gt;</h4><p>Basic metadata:</p><pre>&lt;meta&gt;<br>  &lt;title&gt;Rule Name&lt;/title&gt;<br>  &lt;description&gt;Short summary&lt;/description&gt;<br>  &lt;created-at utc-timestamp=&quot;...&quot;&gt;Human readable&lt;/created-at&gt;<br>  &lt;last-updated-at utc-timestamp=&quot;...&quot;&gt;Human readable&lt;/last-updated-at&gt;<br>  &lt;applies-to&gt;<br>    &lt;file-matcher glob=&quot;*.ts&quot;&gt;Target files&lt;/file-matcher&gt;<br>    &lt;action-matcher action=&quot;create-rule&quot;&gt;Optional action&lt;/action-matcher&gt;<br>  &lt;/applies-to&gt;<br>&lt;/meta&gt;</pre><h4>&lt;requirements&gt;</h4><p>The actual logic.</p><pre>&lt;non-negotiable priority=&quot;critical&quot;&gt;<br>  &lt;description&gt;Never use index.ts barrel files&lt;/description&gt;<br>  &lt;examples&gt;<br>    &lt;example title=&quot;Barrel File&quot;&gt;<br>      &lt;correct-example title=&quot;Direct import&quot; conditions=&quot;Importing components&quot; expected-result=&quot;No barrel usage&quot; correctness-criteria=&quot;No index.ts&quot;&gt;&lt;![CDATA[<br>import { Button } from &quot;@/components/button/button&quot;;<br>      ]]&gt;&lt;/correct-example&gt;<br>      &lt;incorrect-example title=&quot;Barrel used&quot; conditions=&quot;Importing components&quot; expected-result=&quot;No barrel usage&quot; incorrectness-criteria=&quot;Using index.ts&quot;&gt;&lt;![CDATA[<br>import { Button } from &quot;@/components&quot;;<br>      ]]&gt;&lt;/incorrect-example&gt;<br>    &lt;/example&gt;<br>  &lt;/examples&gt;<br>&lt;/non-negotiable&gt;</pre><p>Use:</p><ul><li>&lt;requirement&gt; for optional (but important) logic. Specify priorities.</li><li>&lt;non-negotiable&gt; for hard constraints</li><li>Always provide &lt;examples&gt;, including both &lt;correct-example&gt; and &lt;incorrect-example&gt;</li><li>Wrap any multiline content in &lt;![CDATA[ ... ]]&gt;</li></ul><h4>&lt;grammar&gt; (Optional)</h4><p>Defines schema or regex validation:</p><pre>&lt;grammar&gt;<br>  &lt;grammar-entry title=&quot;Valid Frontmatter&quot;&gt;<br>    &lt;pattern description=&quot;YAML format&quot;&gt;^---\ndescription:.+\nglobs:.+\nalwaysApply:.+\n---$&lt;/pattern&gt;<br>    &lt;example description=&quot;Sample&quot;&gt;---\ndescription: Example\nglobs: *.ts\nalwaysApply: true\n---&lt;/example&gt;<br>  &lt;/grammar-entry&gt;<br>  &lt;schema title=&quot;Cursor Rule Schema&quot; description=&quot;Full structure&quot;&gt;&lt;![CDATA[<br>    &lt;rule&gt;<br>      &lt;meta&gt;...&lt;/meta&gt;<br>      &lt;requirements&gt;...&lt;/requirements&gt;<br>      &lt;references&gt;...&lt;/references&gt;<br>    &lt;/rule&gt;<br>  ]]&gt;&lt;/schema&gt;<br>&lt;/grammar&gt;</pre><h4>&lt;context&gt; (Optional)</h4><p>Explain the purpose or constraints behind the rule.</p><h4>&lt;references&gt; (Required)</h4><p>Link other .mdc files.</p><pre>&lt;references&gt;<br>  &lt;reference as=&quot;dependency&quot; href=&quot;.cursor/rules/rules.mdc&quot; reason=&quot;Schema enforcement&quot;&gt;rules.mdc&lt;/reference&gt;<br>&lt;/references&gt;</pre><p>Valid values for as:</p><ul><li>dependency: Rule relies on another</li><li>context: Shares rationale</li><li>examples: Shows related examples</li><li>glossary: Defines shared concepts</li></ul><h3>Can I Just Use Markdown?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MtJdM5AA3ErtZGmI.jpeg" /><figcaption>Source: <a href="https://www.pexels.com/photo/medieval-black-and-white-chess-pieces-7978844/">Unsplash</a></figcaption></figure><p>You can. But you’ll pay for it in ambiguity.</p><p>Markdown isn’t a contract — it’s a memo. The AI might follow it. It might not. There’s no hierarchy, no priority, no way to tell what’s mandatory vs optional.</p><p>If you want rules to actually be followed, use pseudo-XML.</p><h3>You don’t write it manually</h3><p>You don’t have to write XML-like tags by hand. Ask your AI:</p><blockquote><em>“Write a rule for &lt;…&gt;. Use the pseudo-XML format defined in rules.mdc.”</em></blockquote><p>And you’ll get a valid rule file.</p><p>Just describe what you want, and the agent will generate &lt;rule&gt; definitions with examples, actions, and everything else.</p><h3>What If My Rule Gets Too Big?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K5PHue2brAH8D2iw" /><figcaption>Source: <a href="https://www.pexels.com/photo/woman-in-white-shirt-showing-frustration-3807738/">Unsplash</a></figcaption></figure><p>No problem.</p><p>Cursor can summarize long rules. After loading the rule file, just ask:</p><blockquote><em>“Summarize this rule.”<br>“What are the non-negotiables?”<br>“What does this apply to?”</em></blockquote><p>Because your structure is consistent, the model will break it down and explain it perfectly.</p><h3>Final Checklist</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BOOCHB6k-DIvkzpY" /><figcaption>Source: <a href="https://www.pexels.com/photo/notebook-1226398/">Unsplash</a></figcaption></figure><p>✅ YAML frontmatter<br>✅ &lt;meta&gt; with timestamps and matchers<br>✅ &lt;requirements&gt; with examples<br>✅ &lt;grammar&gt; and &lt;references&gt;<br>✅ All multiline content wrapped in &lt;![CDATA[ ... ]]&gt;<br>✅ Reference .cursor/rules/rules.mdc<br>✅ Keep it concise and declarative</p><h3>Links</h3><ul><li><a href="https://medium.com/@devlato/a-rule-that-writes-the-rules-exploring-rules-mdc-288dc6cf4092">A Rule That Writes the Rules: Exploring `rules.mdc</a>`</li><li><a href="https://cursor.fan/tutorial/HowTo/using-cursor-rules-effectively/">Cursor Rules Tutorial</a></li><li><a href="https://github.com/sanjeed5/awesome-cursor-rules-mdc?ref=producthunt">Awesome </a><a href="https://github.com/sanjeed5/awesome-cursor-rules-mdc?ref=producthunt">.mdc Examples</a></li><li><a href="https://forum.cursor.com/t/my-take-on-cursor-rules/67535">My Take on Cursor Rules (Forum)</a></li><li><a href="https://claude.ai/">Claude</a> — works great with structured .mdc in prompt context</li></ul><p>Stop writing rules the AI might follow.</p><p>Start writing rules it can’t ignore.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f470026ba11f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Higher Level Languages]]></title>
            <link>https://medium.com/@devlato/higher-level-languages-e7e6dc8f8f70?source=rss-6eb902b4018------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7e6dc8f8f70</guid>
            <category><![CDATA[coding-assistance]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[codice]]></category>
            <dc:creator><![CDATA[Denis]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 05:12:45 GMT</pubDate>
            <atom:updated>2022-06-28T05:41:12.899Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Over the decades, the way we write software has changed a lot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3uGRhwvo8SVgjkYs1mgaBQ.jpeg" /><figcaption>A little Robot by <a href="https://unsplash.com/@rocknrollmonkey">@rocknrollmonkey</a>. Unsplash.com</figcaption></figure><p>From the first programming languages that provided 1:1 mapping to the CPU instructions and to the modern era ones that offer cross-platform abstractions over the hardware, OS, networking and synchronization primitives, and sometimes the code execution itself, the new languages have been emerging to help engineers be more productive and solve more and more significant problems faster and easier.</p><p>Thus, with the rise of AI-powered coding assistance and experimental technologies like <a href="https://openai.com/blog/openai-codex/">OpenAI’s Codex</a>, future software engineers will be able to work even faster by focusing on defining terms, their relations, and transitions in their state instead of writing instructions to manipulate data structures. As a result, contemporary programming languages will be considered an “old-fashioned,” “low-level” technology.</p><p>Day-to-day application development will be about figuring out the best possible user scenarios, addressing security considerations around user data processing, and inventing better UX patterns. Still, the coding will become cheap in most cases, with only some pieces being custom-made.</p><p>These will be exciting times!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7e6dc8f8f70" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>