fetch-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFetch Rules
获取规则
Purpose
用途
This skill emulates Cursor's rule selection behavior for AI agents.
It discovers and selects rules from:
- Project Rules ()
.cursor/rules/- files with frontmatter (
.mdc,description,globs)alwaysApply - files without frontmatter (treated as always-apply)
.md
- AGENTS.md files (root and nested subdirectories)
- Legacy at repo root (deprecated but still supported)
.cursorrules
本Skill模拟Cursor针对AI Agent的规则选择行为。
它会从以下位置发现并选择规则:
- 项目规则()
.cursor/rules/- 带前置元数据(、
description、globs)的alwaysApply文件.mdc - 无前置元数据的文件(视为始终应用)
.md
- 带前置元数据(
- AGENTS.md文件(根目录及嵌套子目录)
- 旧版(仓库根目录,已弃用但仍支持)
.cursorrules
Rule Selection Semantics
规则选择语义
| Rule Type | Selection Behavior |
|---|---|
| Always included |
Simple | Always included |
| Included when any candidate file matches |
| Included when prompt overlaps with description keywords |
No metadata ( | Included only when explicitly referenced |
| Always included when in scope (directory hierarchy) |
Candidate files come from , , and file-like paths found in .
--files--use-git-diff--prompt| 规则类型 | 选择行为 |
|---|---|
| 始终包含 |
简单 | 始终包含 |
| 当任意候选文件匹配时包含 |
| 当提示与描述关键词重叠时包含 |
无元数据(仅 | 仅在显式引用时包含 |
| 处于作用域(目录层级)时始终包含 |
候选文件来自、以及中指定的类文件路径。
--files--use-git-diff--promptRequirements
要求
- (macOS / Linux default)
bash - optional (only if you use
git)--use-git-diff
No Python, Node, or jq required.
- (macOS / Linux默认自带)
bash - (可选,仅在使用
git时需要)--use-git-diff
无需Python、Node或jq。
Usage
使用方法
Run commands from this skill directory (the directory containing this ). Do not hardcode agent install paths.
SKILL.mdbash
bash scripts/fetch_rules.sh --prompt "<your request>"Optional file hints:
bash
bash scripts/fetch_rules.sh --prompt "<request>" --files path/to/a.ts path/to/b.sql
bash scripts/fetch_rules.sh --prompt "<request>" --use-git-diffForce-include a rule by filename:
bash
bash scripts/fetch_rules.sh --prompt "<request>" --explicit global.mdc
bash scripts/fetch_rules.sh --prompt "<request>" --explicit react-patterns.md从本Skill所在目录(包含此的目录)运行命令。请勿硬编码Agent安装路径。
SKILL.mdbash
bash scripts/fetch_rules.sh --prompt "<你的请求>"可选文件提示:
bash
bash scripts/fetch_rules.sh --prompt "<请求内容>" --files path/to/a.ts path/to/b.sql
bash scripts/fetch_rules.sh --prompt "<请求内容>" --use-git-diff通过文件名强制包含某条规则:
bash
bash scripts/fetch_rules.sh --prompt "<请求内容>" --explicit global.mdc
bash scripts/fetch_rules.sh --prompt "<请求内容>" --explicit react-patterns.mdSupported Formats
支持的格式
| Format | Location | Description |
|---|---|---|
| | Rules with YAML frontmatter for fine-grained control |
| | Simple markdown rules (always applied) |
| Root or subdirs | Simple agent instructions (always applied in scope) |
| Root only | Legacy format (deprecated, will be removed) |
| 格式 | 位置 | 描述 |
|---|---|---|
| | 带YAML前置元数据的规则,支持细粒度控制 |
| | 简单Markdown规则(始终应用) |
| 根目录或子目录 | 简单Agent指令(在作用域内始终应用) |
| 仅根目录 | 旧版格式(已弃用,后续将移除) |
Notes
注意事项
- If multiple rules share the same filename, the rule in the closest scoped directory wins (deepest scope).
- Glob matching uses bash pattern matching (). Cursor-style
[[ file == pattern ]]works effectively as**in this matcher.* - files are combined hierarchically—parent directories' instructions apply alongside more specific subdirectory instructions.
AGENTS.md
- 若多条规则文件名相同,作用域最接近的目录中的规则优先(层级最深的目录)。
- 通配符匹配使用bash模式匹配()。在此匹配器中,Cursor风格的
[[ file == pattern ]]等效于**。* - 文件会按层级合并——父目录的指令会与更具体的子目录指令一同生效。
AGENTS.md