rules-lawyer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRules Lawyer
Rules Lawyer
Answer Magic: The Gathering rules questions by citing the actual
Comprehensive Rules (CR) and Scryfall per-card rulings. Usable
standalone ("does prowess trigger off my own spells?") or invoked by
deck-wizard / cube-wizard via the Skill tool whenever they hit a
trigger-interaction or timing question during deck tuning.
Think of this as the project's legal research department: the CR is
statute, the Scryfall rulings are case law. Always quote chapter and
verse — never paraphrase from memory.
通过引用官方《万智牌综合规则》(CR)和Scryfall单卡裁定来解答Magic: The Gathering(MTG)规则问题。可独立使用(例如:“prowess会因我自己的法术触发吗?”),也可在deck-wizard或cube-wizard进行套牌调试时遇到触发交互或时机问题时,通过Skill工具调用。
可以将其视为项目的法律研究部门:CR相当于成文法,Scryfall裁定相当于判例法。必须精确引用具体条款——绝不能凭记忆复述。
The Iron Rule
铁则
NEVER answer a rules question from training data. Every answer
MUST cite at least one specific CR rule number (e.g., "702.19a") with
the rule text the CLI returned. If the agent is uncertain or the CLI
returns no match, say so and escalate (Phase 3) rather than making
something up. A confident hallucinated rule number is worse than an
honest "I couldn't find a matching rule — here's the closest neighbor."
绝对不要仅凭训练数据回答规则问题。 每一个回答都必须引用至少一个具体的CR规则编号(例如:"702.19a"),并附上CLI返回的规则文本。如果Agent不确定或CLI未返回匹配结果,应如实说明并进入升级流程(阶段3),而非编造内容。自信地编造规则编号比诚实地说“我找不到匹配的规则——以下是最接近的相关内容”更糟糕。
Setup (First Run)
首次运行设置
bash
uv sync --directory <skill-install-dir>
download-rules --output-dir <working-dir>
download-mtgjson # only for local-first rulings-lookup (API fallback needs no bulk)download-rulesdownload-mtgjsonMagicCompRules*.txt<working-dir>/comprehensive-rules-YYYYMMDD.txtbash
uv sync --directory <skill-install-dir>
download-rules --output-dir <working-dir>
download-mtgjson # only for local-first rulings-lookup (API fallback needs no bulk)download-rulesdownload-mtgjsonMagicCompRules*.txt<working-dir>/comprehensive-rules-YYYYMMDD.txtWorkflow
工作流程
Phase 1: Classify the Question
阶段1:问题分类
Before running any CLI, decide what kind of rules question this is.
The query mode maps 1:1 to a flag.
rules-lookup| Question shape | CLI |
|---|---|
| "What does rule 702.19a say?" | |
| "What's the rule for trample?" / "Define 'library'." | |
| "Which rules mention 'combat damage step'?" | |
| "How does Card Name interact with X?" | |
| "Given this deck, are there any stack/layer issues with Y?" | Use deck-wizard's |
Keyword → term mapping. Most CR keywords (trample, deathtouch,
double strike, menace, flash, haste, hexproof, indestructible, etc.)
map to a glossary entry whose field points to the
authoritative rule. Prefer for these: you get both the
glossary definition AND the rule number in one round-trip.
see_rules--term在运行任何CLI命令前,先确定规则问题的类型。查询模式与的参数一一对应。
rules-lookup| 问题类型 | CLI命令 |
|---|---|
| “规则702.19a的内容是什么?” | |
| “trample(践踏)的规则是什么?” / “定义‘牌库’。” | |
| “哪些规则提到了‘战斗伤害步骤’?” | |
| “卡牌Card Name与X如何交互?” | |
| “给定这套牌,Y是否存在堆叠/层级问题?” | 使用deck-wizard的 |
关键字→术语映射。大多数CR关键字(trample、deathtouch、double strike、menace、flash、haste、hexproof、indestructible等)都对应一个术语表条目,其字段指向权威规则。对于这类问题优先使用参数:一次查询即可同时获取术语表定义和规则编号。
see_rules--termPhase 2: Look Up
阶段2:规则检索
Run exactly one invocation for the classified question.
The CLI writes a JSON sidecar and prints a human-readable summary. If
the summary answers the question, stop — don't escalate for its own
sake.
rules-lookupbash
undefined针对分类后的问题运行一次命令。CLI会生成JSON辅助文件并打印人类可读的摘要。如果摘要已回答问题,则停止操作——无需为升级而升级。
rules-lookupbash
undefinedExact rule number
精确规则编号查询
rules-lookup --rule 702.19a --rules-file <wd>/comprehensive-rules-*.txt
rules-lookup --rule 702.19a --rules-file <wd>/comprehensive-rules-*.txt
Glossary term (preferred for keyword questions)
术语表查询(关键字问题首选)
rules-lookup --term "deathtouch" --rules-file <wd>/comprehensive-rules-*.txt
rules-lookup --term "deathtouch" --rules-file <wd>/comprehensive-rules-*.txt
Regex search — use a narrow pattern or you'll get noise
正则搜索——使用精准模式,否则会返回大量无关结果
rules-lookup --grep "can't be blocked by more than" --rules-file <wd>/comprehensive-rules-*.txt --limit 5
For per-card questions, prefer rulings first, then resolve the cited
rules:
```bash
rulings-lookup --card "Sensei's Divining Top" --bulk-data <wd>/default-cards.jsonrules-lookup --grep "can't be blocked by more than" --rules-file <wd>/comprehensive-rules-*.txt --limit 5
针对单卡问题,优先查询裁定,再解析引用的规则:
```bash
rulings-lookup --card "Sensei's Divining Top" --bulk-data <wd>/default-cards.jsonThen for any CR rule referenced in a ruling:
然后针对裁定中引用的任何CR规则:
rules-lookup --rule 116.1 --rules-file <wd>/comprehensive-rules-*.txt
undefinedrules-lookup --rule 116.1 --rules-file <wd>/comprehensive-rules-*.txt
undefinedPhase 3: Escalate (only when needed)
阶段3:升级流程(仅在必要时使用)
If returns no match or the match is clearly wrong for
the question, do ONE of:
rules-lookup- Widen the search. Try a lookup with a synonym, or a broader
--termpattern. The CR glossary is large (~670 terms in the 2024 CR) — a missed term usually means a bad query.--grep - Read a section slice. For complex multi-rule reasoning (layer
interactions, replacement effects applying simultaneously, stack
ordering across triggered and activated abilities), the relevant section directly from the downloaded TXT:
Read- : turn structure
500-series - : spells, abilities, effects (including stack)
600-series - : additional rules, keyword abilities/actions
700-series - : multiplayer Use
800-seriesto pull only the relevant band.Read <comprehensive-rules-*.txt> offset=<line> limit=<n>
- Spawn a subagent. For a question that needs reasoning across
multiple sections (e.g., "how do layers interact with a static
ability that's turned off by a replacement effect"), a specialist with the relevant section text preloaded. Prompt the subagent to return a rule-cited answer, not a paraphrase.
Agent
Worked example — escalation path #2 (section slice):
User asks: "Does my Teferi's Puzzle Box trigger interact with Rule of
Law somehow — can I still draw my new hand?"
This is a replacement-effect / triggered-ability interaction. The
first lookup is cheap:
bash
rules-lookup --term "replacement effect" --rules-file <wd>/comprehensive-rules-*.txtOutput: glossary entry pointing at rule . Now read the category
itself to see whether drawing cards is a "replacement" at all:
614bash
rules-lookup --rule 614 --rules-file <wd>/comprehensive-rules-*.txtIf 's prose is thin (category headers are just titles), pull the
full section band by finding the line number and -ing the TXT:
614Readbash
grep -n "^614\." <wd>/comprehensive-rules-*.txt | head -1如果未返回匹配结果,或结果明显与问题不符,执行以下操作之一:
rules-lookup- 扩大搜索范围。尝试使用同义词进行查询,或使用更宽泛的
--term模式。CR术语表规模庞大(2024版约有670个术语)——未找到术语通常意味着查询语句不够准确。--grep - 读取章节片段。对于需要跨多规则推理的复杂问题(如层级交互、替换效应同时生效、触发式与启动式异能的堆叠顺序),直接从下载的TXT文件中读取相关章节:
- :回合结构
500系列 - :咒语、异能、效应(包括堆叠)
600系列 - :附加规则、关键字异能/动作
700系列 - :多人游戏 使用
800系列仅提取相关片段。Read <comprehensive-rules-*.txt> offset=<line> limit=<n>
- 生成子Agent。对于需要跨多章节推理的问题(例如:“层级与被替换效应关闭的静态异能如何交互?”),生成一个预加载相关章节文本的专业子Agent。提示子Agent返回带规则引用的答案,而非复述内容。
升级流程示例——方式2(章节片段):
用户提问:“我的Teferi's Puzzle Box触发异能是否会与Rule of Law产生交互——我还能抽新的手牌吗?”
这是一个替换效应/触发式异能交互问题。首先进行简单检索:
bash
rules-lookup --term "replacement effect" --rules-file <wd>/comprehensive-rules-*.txt输出:指向规则的术语表条目。现在读取该类别本身,判断抽牌是否属于“替换效应”:
614bash
rules-lookup --rule 614 --rules-file <wd>/comprehensive-rules-*.txt如果的内容过于简略(类别标题仅为名称),则通过查找行号并读取TXT文件的完整章节片段:
614Readbash
grep -n "^614\." <wd>/comprehensive-rules-*.txt | head -1Prints e.g.: "3108:614. Replacement Effects"
输出示例:"3108:614. Replacement Effects"
Then read lines `3108-3250` (typical category size) to see every
subrule:
Read <wd>/comprehensive-rules-20260417.txt offset=3108 limit=140
Most rules-lawyer questions resolve inside Phase 2 — this escalation
is for the ones that don't.
然后读取`3108-3250`行(典型类别篇幅)查看所有子规则:
Read <wd>/comprehensive-rules-20260417.txt offset=3108 limit=140
大多数规则问题可在阶段2解决——升级流程仅用于特殊情况。Phase 4: Write the Answer
阶段4:撰写答案
Every answer has three required parts:
- The verdict. One sentence: what happens / what the ruling is.
- The citations. Each cited rule number MUST come from the CLI output, not from memory. Include the verbatim rule text the CLI returned (trim to the directly-relevant sentence).
- The edge cases. If the ruling hinges on a condition ("only if the source has deathtouch", "only during your upkeep"), name that condition explicitly. If there's a well-known trap the question sounds like but ISN'T asking about, note it briefly.
Example answer shape:
Verdict. Yes — a creature with both trample and deathtouch only needs to assign 1 damage per blocker to consider it "lethal," then trample over the rest.CR 702.19b: "…the attacking creature's controller need not assign lethal damage to all those blocking creatures but in any case may not assign combat damage to a player or planeswalker or battle unless every blocking creature is assigned at least lethal damage."CR 702.2b: "A creature with toughness greater than 0 that's been dealt damage by a source with deathtouch since the last time state-based actions were checked is destroyed as a state-based action."Edge case. This requires the source to have deathtouch at the moment damage is assigned; removing deathtouch mid-combat (e.g., via protection or static abilities in the continuous-effects layer 6) kills the interaction. See CR 613 for layers.
每个答案必须包含三个部分:
- 结论。一句话说明结果/裁定内容。
- 引用。每个引用的规则编号必须来自CLI输出,而非记忆。附上CLI返回的规则原文(仅保留直接相关的句子)。
- 边缘情况。如果裁定依赖特定条件(“仅当来源具有deathtouch时”、“仅在你的维持阶段”),需明确说明该条件。如果问题看似涉及某个常见误区但实际并非如此,可简要提及。
答案示例格式:
结论。是的——同时具有trample和deathtouch的生物只需为每个阻挡者分配1点伤害即可视为“致命伤害”,剩余伤害可穿透到玩家。CR 702.19b:“…攻击生物的操控者无需为所有阻挡生物分配致命伤害,但在为玩家、鹏洛客或战棋分配战斗伤害前,必须为每个阻挡生物分配至少致命伤害。”CR 702.2b:“自上次检查状态动作以来,受到具有deathtouch的来源造成伤害的 toughness大于0的生物,会作为状态动作被消灭。”边缘情况。这要求来源在伤害分配时具有deathtouch;战斗中途移除deathtouch(例如:通过保护或连续效应层级6的静态异能)会中断该交互。详见CR 613关于层级的规则。
Decision Table
决策表
| Task | Tool |
|---|---|
| Look up a rule by number | |
| Look up a keyword / defined term | |
| Search for rules mentioning a phrase | |
| Per-card rulings (Scryfall "case law") | |
| Batch rulings for a deck | |
| Download/refresh CR locally | |
| Download MTGJSON card data | `download-mtgjson |
| Resolve card name → oracle text | |
All CLIs emit a human-readable summary to stdout plus a full JSON
sidecar at an absolute path (prefix , ,
etc.). Read the sidecar with when you need fields the summary
elided.
rules-lookup-rulings-lookup-Read| 任务 | 工具 |
|---|---|
| 通过编号查找规则 | |
| 查找关键字/定义术语 | |
| 搜索包含特定短语的规则 | |
| 单卡裁定(Scryfall“判例法”) | |
| 套牌批量裁定 | |
| 下载/本地更新CR | |
| 下载MTGJSON卡牌数据 | |
| 解析卡牌名称→ oracle文本 | |
所有CLI工具会向stdout输出人类可读的摘要,并在绝对路径生成完整的JSON辅助文件(前缀为、等)。当需要摘要中省略的字段时,可使用读取辅助文件。
rules-lookup-rulings-lookup-ReadDelegation: When Other Skills Should Invoke This
委托调用:其他Skill应何时调用本工具
deck-wizard's and accept a
flag. When that's set, they call for
any flagged keyword interaction and attach CR citations to the JSON
output. That flag covers the common case; for anything more nuanced
(the agent is unsure why a cut was flagged, or a user asks "why did
the auditor complain?"), invoke this skill.
cut-checklegality-audit--cite-rulesrules-lookup --term <keyword>deck-wizard的和支持参数。启用该参数后,工具会针对任何标记的关键字交互调用,并将CR引用附加到JSON输出中。该参数覆盖常见场景;对于更复杂的情况(Agent不确定为何标记某卡牌,或用户提问“为什么审核工具提出异议?”),请调用本Skill。
cut-checklegality-audit--cite-rulesrules-lookup --term <keyword>Scratch File Paths
临时文件路径
Reuse these stable paths within a session:
, .
/tmp/rules-scratch.json/tmp/rulings-scratch.json/tmpReadWriteWriteBash会话内可复用以下稳定路径:
, .
/tmp/rules-scratch.json/tmp/rulings-scratch.json/tmpWriteReadWriteBashPath Requirements
路径要求
- Absolute paths only. rebases the working directory to the skill install; relative paths resolve against the wrong root.
uv - Rules file: Store under the calling skill's working directory
(e.g., ), NOT the skill install directory.
<wd>/comprehensive-rules-20260417.txt - Cache directory for rulings: is used automatically; callers don't need to manage it.
$TMPDIR/scryfall-rulings/
- 仅使用绝对路径。会将工作目录重定向到Skill安装目录;相对路径会解析到错误的根目录。
uv - 规则文件:存储在调用Skill的工作目录下(例如:),而非Skill安装目录。
<wd>/comprehensive-rules-20260417.txt - 裁定缓存目录:自动使用;调用者无需管理该目录。
$TMPDIR/scryfall-rulings/