agentleFS
getGanemogetGanemo/agent-stack-core-oss/skills/create_agent_rule/SKILL.md

create_agent_rule

Skill0 starsChanged 6 months agoMITView on GitHub

USE before creating any new Agent Rule (.md in .agents/rules/). Ensures the rule (a) lives in the correct stack repo per the transversal-vs-product test, (b) is named with a product suffix when it could collide with a transversal rule, (c) has the strict frontmatter (trigger/description/globs) required by VS Code's Open Agent Manager, (d) is written with LF endings. NEVER create a rule directly in a workspace's .agents/rules/ — that gets blown away by `wsp sync`.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill whenever the user asks to create a new Rule for the agent.

    line 8
  2. Very specific:

    Add _<product> suffix to the filename when either is true:

    line 37
  3. Distinctive:

    Every rule file MUST have these three fields in the YAML frontmatter:

    line 69
  4. Distinctive:

    All rules MUST be authored in their source stack repo (decided in Section 1):

    line 105
  5. Distinctive:

    Use snake_case for the filename.

    line 113
  6. Very specific:

    If existing rule files are not appearing in the panel, they likely have CRLF endings.

    line 152
  7. Very specific:

    Do NOT: use PowerShell (Get-Content) | Set-Content — it may re-introduce CRLF.

    line 154
  8. Distinctive:

    After creating or fixing a rule, confirm:

    line 160

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create Agent Rule

Use this skill whenever the user asks to create a new Rule for the agent. Rules live in .agents/rules/ of every workspace, but they are composed from stack repos by wsp bootstrap / wsp sync — so the source of truth is a stack repo, not the workspace.


1. Decide which stack repo the rule lives in (do this FIRST)

Editing a rule directly inside a workspace's .agents/rules/ is wrong — that directory is regenerated from the source stacks on every wsp sync and your edit will be blown away. The rule must live in a stack repo and reach workspaces via composition.

Apply the transversal-vs-product test

From agent-stack-core/awac.yml#org_scaffold.transversal_vs_product:

  1. Could another product in your portfolio use this rule as-is?
  2. Does the rule codify a team or technology convention rather than a product-specific one?
  3. If two products needed it, would two copies be a mistake?

Any "yes" → transversal. All "no" → product-specific.

Map the answer to a stack repo

ScopeStack repoTrigger to use this scope
Universal<your-org>/agent-stack-core/rules/<name>.mdRule is about agent behavior, AWaC, security guardrails. Examples already there: anti_prompt_injection.md, aws_resource_safety.md, auto_propagate.md, capture_learnings.md.
Topical transversal<your-org>/agent-stack-<topic>/rules/<name>.md (topic ∈ aws, mcp, cloudflare, research, …)Rule applies whenever this technology is used, across products.
Cross-org by ecosystemthe stack of that ecosystem org. Example: any Odoo development rule goes in <ecosystem-org>/agent-stack/rules/<name>.md.Rule is about how to work with the ecosystem itself, regardless of which product consumes it.
Product-specific<product>/agent-stack/rules/<name>.mdRule encodes something true ONLY for this product.

Naming: when to add a product suffix

Add _<product> suffix to the filename when either is true:

  • A transversal rule with the same base name already exists or could plausibly exist (e.g. aws_resource_safety_<product>.md extends and coexists with the universal aws_resource_safety.md from core — last-stack-wins composition would otherwise overwrite the universal one silently).
  • The base name is generic enough that a reader seeing the file alone would not know which product it belongs to (init_project_<product>.md vs an ambiguous init_project.md in <product>/agent-stack/rules/).

Skip the suffix only when the file name already references a product-specific entity (use_orchestrator_api.md, use_ssm_deploy_<product>.md — though even there an explicit suffix is fine).

Rationale: composer.compose_agents applies last-stack-wins on identical filenames. A product rule that accidentally shadows a universal rule with the same name will silently replace it in workspaces, with only a collisions[] entry in the bootstrap report. Suffixes prevent the silent shadowing.

Default when unsure

Conservative default: product-specific. Promotion to transversal later is cheap; retraction after two products depend on a transversal rule is expensive.


2. Root Cause: Why Rules Fail to Appear

VS Code's Open Agent Manager detects rule files using a strict YAML parser. Two conditions will prevent a rule from appearing in the Rules panel:

ProblemSymptomRoot Cause
CRLF line endingsFile exists but not listedWindows editors save \r\n by default
Missing trigger: fieldFile exists but not listedThe panel requires this field in the frontmatter

CRITICAL: Always write rule files with LF (\n) line endings — never CRLF. The write_to_file tool produces LF by default. Always use it to create or overwrite rule files. Never use a Windows text editor to create them.


3. Correct Rule File Format

Every rule file MUST have these three fields in the YAML frontmatter:

---
trigger: always_on
description: <One-line summary of what this rule enforces.>
globs: ["**/*"]
---

# Rule Title

Rule content in Markdown...

Field Reference

FieldRequiredValueNotes
trigger✅ Yesalways_onWithout this, the panel ignores the file
description✅ YesStringShown in the panel tooltip
globs✅ YesArray of glob patterns["**/*"] for all files; be specific when possible

Common globs patterns

ScopeValue
All files["**/*"]
Python + XML["**/*.py", "**/*.xml"]
Python only["**/*.py"]
Python + XML + JS["**/*.py", "**/*.xml", "**/*.js"]
Python + CSV["**/*.py", "**/*.xml", "**/*.csv"]

4. File Location

All rules MUST be authored in their source stack repo (decided in Section 1):

<stack-repo>/rules/<rule_name>.md

Inside any workspace, after wsp bootstrap or wsp sync, the same rule appears at .agents/rules/<rule_name>.md (composed from its source stack — DO NOT edit this composed copy; the next sync rewrites it).

Use snake_case for the filename. The filename becomes the rule's identifier.


5. Step-by-Step: Creating a New Rule

  1. Decide the host stack repo — apply Section 1's transversal-vs-product test. Open it locally; clone if missing.
  2. Determine the rule name — snake_case, descriptive, e.g. use_mcp_tools. Add _<product> suffix if needed (Section 1).
  3. Determine the glob scope — be specific (avoid **/* unless the rule is truly universal).
  4. Write the file using write_to_file with Overwrite: false at <stack-repo>/rules/<name>.md — this guarantees LF endings.
  5. Commit + push to the stack repo. Any workspace running wsp sync (or wsp bootstrap) picks the rule up automatically — workspaces never receive rules pushed only to their own .agents/rules/.
  6. Verify it appears in VS Code → Open Agent Manager → Rules panel after a Reload Window (Ctrl+Shift+P → Reload Window) in any workspace that consumes that stack.

Template (copy-paste ready)

---
trigger: always_on
description: <Short description of what this rule enforces.>
globs: ["**/*.py", "**/*.xml"]
---

# Rule Title

> **Summary directive in one line.**

## Section 1

- Bullet point...

## Section 2

- Bullet point...

6. Fixing Existing Rules with CRLF

If existing rule files are not appearing in the panel, they likely have CRLF endings. Fix them by rewriting each file with write_to_file (Overwrite: true), preserving the original content but adding trigger: always_on to the frontmatter.

Do NOT use PowerShell (Get-Content) | Set-Content — it may re-introduce CRLF.


7. Verification Checklist

After creating or fixing a rule, confirm:

  • File is in <stack-repo>/rules/ (NOT directly in a workspace's .agents/rules/)
  • The chosen stack repo matches the transversal-vs-product test from Section 1
  • Filename has _<product> suffix if it could collide with a transversal rule (Section 1)
  • Frontmatter has trigger: always_on, description:, and globs:
  • File was written with write_to_file tool (guarantees LF)
  • Stack repo commit pushed to origin
  • After wsp sync in a consuming workspace, rule appears in VS Code Open Agent Manager → Rules panel after Reload Window

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.