agentleFS
LNSDLNSD/lorecraft/skills/code-rules/SKILL.md

code-rules

Skill0 starsChanged 57 days agoApache-2.0View on GitHub

Load the repository's code rules that apply to the work at hand, from the rule documents in docs/code/, reading their frontmatter first and only the documents whose triggers match. Use before planning or writing code, or when asked about the repository's conventions, standards, or design principles. Not for checking finished code; see /code-rules-check

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    If docs/code/ does not exist, say so: the repository has no code rules to load.

    line 14
  2. Distinctive:

    Run this first; it is the whole index:

    line 19
  3. Distinctive:

    Read nothing adjacent: If no trigger matches, say so: a gap in the rules is worth reporting.

    line 49
  4. Very specific:

    Read selections at docs/code/<name>.md, or docs/arch/<name>.md for a decision record.

    line 51

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Code Rules

A repository that uses Lorecraft keeps the rules for how its code is written as a corpus of rule documents in docs/code/, one rule or topic per document. This skill loads only their frontmatter, and you choose what to read from it. Selecting well is the whole job: read what the task needs, nothing more.

If docs/code/ does not exist, say so: the repository has no code rules to load. Its specification, if one exists, is docs/__meta__/code.md; /docs-rules-creator sets one up.

1. The catalog

Run this first; it is the whole index:

grep -m 3 -E '^(description|type|scope):' docs/code/*.md

Where the repository also keeps architecture decision records in docs/arch/, an accepted one binds code as a rule document does: it states how the code is built. List them too, and treat only those whose status is accepted as rules:

grep -m 4 -E '^(description|status):' docs/arch/adr-*.md

Each description says what its document covers and, where the corpus specification asks for one, a trigger clause — Load when … or similar — naming the situations the document governs. Other fields, such as type or scope, are whatever docs/__meta__/code.md defines; read its frontmatter section once if their meaning is not obvious.

2. Selecting

Match the task against the trigger clauses, then:

  • Take the most specific match. A filename prefix is a group: python-*, test-*. Read the member whose trigger fits — the document on docstrings for a docstring, the one on handling errors for an except — not the group's broadest document. Add a broader one only when the task turns on what it owns.
  • Expect two to four documents. One is common. More than four means the task is unscoped, or you are matching topics instead of triggers.
  • Break ties by specificity: a document scoped to the package or directory being changed over a global one, where the frontmatter says which is which.
  • Read nothing adjacent. If no trigger matches, say so: a gap in the rules is worth reporting.

Read selections at docs/code/<name>.md, or docs/arch/<name>.md for a decision record. Do not re-read what is already in context.

3. Rules that apply to all design work

Some rules — design principles, usually a principle-* group — govern every change, so no task will match their triggers. Treat their catalog descriptions as the rules themselves and design against every one. Read a full principle document only to argue one: to justify a decision, settle a disagreement, or cite it in a review. Asked for the principles, read them all and summarise.

4. Applying

The rules are the repository's decisions, and they outrank general practice and your defaults. Where a rule seems wrong for the task, follow it and raise the conflict; do not silently deviate. Each rule document usually ends with a checklist: hold it while writing, since /code-rules-check checks the result against it.

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.