Rule Extraction logo

Rule Extraction

Organization
KnowledgeXLab
Rule Extraction

Extract a structured list of rules from all markdown files at the top level of a skill directory. Use this skill whenever you need to parse rules out of a skill for conflict checking, merging, or diffing.

Overview

PublisherKnowledgeXLab
Repositoryskill-git
Skill nameRule Extraction
Stars
42
Forks
1
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by KnowledgeXLab on GitHub. Read the source before you install it.

Installation

Install the Rule Extraction AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/KnowledgeXLab/skill-git/tree/main/skills/rule-extraction
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/KnowledgeXLab/skill-git.git /tmp/skill-git
mkdir -p .claude/skills
cp -r /tmp/skill-git/skills/rule-extraction .claude/skills/knowledgexlab-rule-extraction
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rule Extraction in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rule Extraction on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rule Extraction is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Rule Extraction

This skill teaches you how to extract a structured, line-numbered list of rules from a skill directory.

What Counts as a Rule

A rule is any statement that prescribes or constrains agent behavior. Recognize rules by their form:

  • Imperative directives: "Always add type annotations", "Never use var"
  • Prohibition patterns: "Do not X", "Avoid X", "禁止 X"
  • Requirement patterns: "Must X", "Should X", "需要 X", "必须 X"
  • Conditional behavior: "If X, then Y", "When X, do Y"
  • Style/format mandates: "Use camelCase", "Limit lines to 80 characters"
  • Preference statements: "Prefer X over Y", "优先使用 X"

Rules can appear as:

  • Bullet list items (- or * or +)
  • Numbered list items (1., 2.)
  • Bold or emphasized sentences (**Always do X**)
  • Plain sentences within a paragraph that contain directive language
  • Section headers that are themselves imperatives ("Never commit secrets")

What Does NOT Count as a Rule

Exclude the following from extraction:

  • Descriptive text: Explanations of why a rule exists, background context
  • Examples: Code blocks, sample outputs, "for example..." passages
  • Metadata: YAML frontmatter, version info, author notes
  • Headings that introduce a section (unless the heading itself is an imperative rule)
  • Vague non-actionable statements: "Do good work", "Be helpful" — extract these but flag them as vague: true

Output Format

Return a JSON array. Each rule is an object:

json
[
  {
    "id": 1,
    "file": "SKILL.md",
    "line": 12,
    "text": "Always add type annotations to function parameters",
    "source_text": "- Always add type annotations to function parameters",
    "vague": false
  },
  {
    "id": 2,
    "file": "SKILL.md",
    "line": 15,
    "text": "Do not use var, prefer const or let",
    "source_text": "**Do not use `var`** — prefer `const` or `let`",
    "vague": false
  },
  {
    "id": 3,
    "file": "examples.md",
    "line": 4,
    "text": "Do good work",
    "source_text": "- Do good work",
    "vague": true
  }
]

Field definitions:

  • id: Sequential integer starting from 1, across all files combined
  • file: Filename (basename only, e.g. SKILL.md, examples.md) where the rule appears
  • line: Line number within that file where the rule appears (1-indexed)
  • text: Cleaned rule text, stripped of markdown formatting
  • source_text: Original raw line as it appears in the file
  • vague: true if the rule is too broad to be actionable

Input Scope

The input is a skill directory path (e.g. ~/.claude/skills/humanizer/).

Files to read: all *.md files directly inside the skill directory — SKILL.md first, then any other *.md files in alphabetical order.

Files to skip:

  • Subdirectories and any files inside them (no recursive scan)
  • Non-markdown files (.sh, .py, .js, .json, etc.)

Extraction Process

  1. List all *.md files at the top level of the skill directory (non-recursive). Read SKILL.md first if present; read remaining *.md files in alphabetical order.
  2. For each file, read it line by line, tracking line numbers within that file.
  3. Skip frontmatter (everything between --- delimiters at the top of each file)
  4. Skip code blocks (between ``` fences) — these are examples, not rules
  5. For each line, determine if it contains a rule using the criteria above
  6. For paragraph text: split into sentences, check each sentence independently
  7. Clean the extracted text: remove markdown syntax (-, *, **, backticks) but preserve the meaning
  8. Assign line numbers based on where the rule text starts within its file
  9. Record the source filename for every rule

Handling Ambiguous Cases

  • Compound bullet: "Use camelCase and limit lines to 80 chars" → split into two rules, both on the same line number
  • Nested bullets: Treat each nested item as an independent rule
  • Conditional rules: Keep the full conditional ("If Python, use type hints") as one rule — do not split on the condition
  • Negated rules: "Don't use X" and "Never use X" are equivalent — normalize to a consistent form in text, preserve original in source_text

Example

Input skill directory: ~/.claude/skills/code-style/ Files found at top level: SKILL.md, extra-rules.md (Any subdirectory contents are ignored.)

SKILL.md:

---
name: Code Style
---

# Code Style Guidelines

Keep code clean and maintainable.

## Naming
- Use camelCase for variables and functions
- Use PascalCase for classes and types
- Never use single-letter variable names except for loop indices

## Comments
Always write comments in English.
Do not write comments explaining what the code does — only explain why.

## Example
\`\`\`python
# good
def calculate_total(items):
    return sum(items)
\`\`\`

extra-rules.md:

- Prefer explicit returns over implicit ones

Output:

json
[
  {
    "id": 1,
    "file": "SKILL.md",
    "line": 10,
    "text": "Use camelCase for variables and functions",
    "source_text": "- Use camelCase for variables and functions",
    "vague": false
  },
  {
    "id": 2,
    "file": "SKILL.md",
    "line": 11,
    "text": "Use PascalCase for classes and types",
    "source_text": "- Use PascalCase for classes and types",
    "vague": false
  },
  {
    "id": 3,
    "file": "SKILL.md",
    "line": 12,
    "text": "Never use single-letter variable names except for loop indices",
    "source_text": "- Never use single-letter variable names except for loop indices",
    "vague": false
  },
  {
    "id": 4,
    "file": "SKILL.md",
    "line": 15,
    "text": "Always write comments in English",
    "source_text": "Always write comments in English.",
    "vague": false
  },
  {
    "id": 5,
    "file": "SKILL.md",
    "line": 16,
    "text": "Do not write comments explaining what the code does — only explain why",
    "source_text": "Do not write comments explaining what the code does — only explain why.",
    "vague": false
  },
  {
    "id": 6,
    "file": "extra-rules.md",
    "line": 1,
    "text": "Prefer explicit returns over implicit ones",
    "source_text": "- Prefer explicit returns over implicit ones",
    "vague": false
  }
]

Notes:

  • SKILL.md lines 18–23 (the code block) are skipped entirely
  • id is sequential across all files; line resets to 1 for each new file
  • Any subdirectories inside ~/.claude/skills/code-style/ are not scanned

Frequently asked questions

What does the Rule Extraction AI skill do?

Extract a structured list of rules from all markdown files at the top level of a skill directory. Use this skill whenever you need to parse rules out of a skill for conflict checking, merging, or diffing.

Why use Rule Extraction on TypingMind?

Because you install it once and use it with any model. Rule Extraction is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rule Extraction in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/KnowledgeXLab/skill-git/tree/main/skills/rule-extraction. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Rule Extraction?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rule Extraction?

As many as you like. As long as a model supports skills, you can use Rule Extraction with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rule Extraction AI skill free?

Yes. It is published on GitHub by KnowledgeXLab under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇