add-trigger

A guide for adding triggered abilities in a digital version of Magic: The Gathering. These are abilities that activate after events such as a creature entering, attacking, or a spell being cast.

In plain words
What is it for?
Use it when adding or changing any “when,” “whenever,” or “at the beginning of” ability.
Why use it?
It helps connect the rules text to event detection, player choices, ordering, targeting, and resolution so the ability works throughout the game.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/phase-rs/phase/add-trigger
Any agent
npx skills add phase-rs/phase --skill add-trigger
Clone the repo
git clone --depth 1 https://github.com/phase-rs/phase

Made for: Claude Code, Codex.

Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,957 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00068 $0.04957
Opus 5 $0.00034 $0.02478
Sonnet 5 $0.00014 $0.00991
Haiku 4.5 $0.00007 $0.00496

Measured 2d ago against content hash 37d18c78c626, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

add-trigger scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/add-trigger/SKILL.md · 350 lines

How it starts

The opening of the file, as written. The whole thing — 350 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Adding a Triggered Ability

Triggered abilities fire in response to game events and go on the stack (MTG Rule 603). They differ from replacement effects (which modify events) and static abilities (which exist continuously). This skill covers the full trigger pipeline: event fired → matcher detects → APNAP ordering → targeting → stack → resolution.

Before you start: Trace how ChangesZone (ETB/dies) triggers work end-to-end. They're the most complete reference: parse_trigger_line() in oracle_trigger.rsTriggerDefinitionprocess_triggers()match_changes_zone() → stack placement → resolve_top().

CR Verification Rule: Every CR number in annotations MUST be verified by grepping docs/MagicCompRules.txt before writing. Do NOT rely on memory — 701.x and 702.x numbers are arbitrary sequential assignments that LLMs consistently hallucinate. Run grep -n "^603.2" docs/MagicCompRules.txt (etc.) for every number. If you cannot find it, do not write the annotation.


MTG Rules Reference

Rule What it governs Engine implication
603.2 A triggered ability triggers when its event occurs process_triggers() scans all permanents against the event
603.3 Triggered abilities are placed on the stack (APNAP order) Sort by (is_nap, timestamp) before stack placement
603.3b Active player's triggers go on stack first (resolve last) NAP triggers pushed after AP triggers
603.4 Intervening-if checked at fire-time AND resolution-time TriggerCondition checked in both process_triggers() and resolve_top()
603.5 Triggered abilities target when placed on stack extract_target_filter_from_effect() → targeting phase before stack
603.6c "Once each turn" constraint TriggerConstraint::OncePerTurn tracked in triggers_fired_this_turn

Key Types

TriggerDefinitioncrates/engine/src/types/ability.rs

pub struct TriggerDefinition {
    pub mode: TriggerMode,                    // Event type: ChangesZone, DamageDone, SpellCast, etc.
    pub execute: Option<Box<AbilityDefinition>>, // Effect to run when triggered
    pub valid_card: Option<TargetFilter>,      // Filter on the event subject ("another creature")
    pub origin: Option<Zone>,                  // For zone changes: from where
    pub destination: Option<Zone>,             // For zone changes: to where
    pub trigger_zones: Vec<Zone>,             // Active zones (default: Battlefield)
    pub phase: Option<Phase>,                 // For phase triggers (Upkeep, End, etc.)
    pub optional: bool,                       // "You may" triggers
    pub combat_damage: bool,                  // Combat damage only filter
    pub secondary: bool,                      // Multi-target secondary indicator
    pub valid_target: Option<TargetFilter>,   // Controller filter for events (You, Opponent)
    pub valid_source: Option<TargetFilter>,   // Source filter for damage/spell triggers
    pub description: Option<String>,          // Human-readable text
    pub constraint: Option<TriggerConstraint>, // OncePerTurn, OncePerGame, OnlyDuringYourTurn
    pub condition: Option<TriggerCondition>,   // Intervening-if condition
}

Read the full file on GitHub · 350 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 350 lines · 68 tokens per session scan A 37d18c78c626

Subscribe to this mod's changes

add-trigger is a skill published in the GitHub repository phase-rs/phase (259 stars, last pushed 2d ago), licensed Apache-2.0. It adds 68 tokens to every session and 4,957 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

qa-cli-mcp-api

Select and run explicitly requested, risk-based QA for Anarlog's CLI, webhooks, stdio MCP, hosted Cloud API, and remote MCP. Test only affected lanes unless comprehensive coverage is requested.

fastrepl/anarlog · 47 tokens

product-update-newsletter

Draft, update, or audit a crisp, changelog-grounded Anarlog product-update newsletter in Loops (app.loops.so) for a desktop release. Use after the changelog is merged, when asked to draft, revise, or pre-send check the release announcement email.

fastrepl/anarlog · 62 tokens

release-new-version

Release a new desktop stable version for Anarlog. Use when asked to cut, publish, or prepare a new stable desktop release after checking and merging the changelog.

fastrepl/anarlog · 38 tokens

sqlite-schema-design

Design or review schemas for crates/cloudsync using SQLite Sync constraints, not generic SQLite advice. Use when adding synced tables, changing synced columns, or planning CloudSync-safe migrations.

fastrepl/anarlog · 42 tokens

fix-ready-prs

Inspect every open non-draft PR for CI failures and unresolved Cursor Bugbot findings, then fix them on the existing PR branches. Use when asked to check active PRs, triage ready PRs, fix CI, or address Bugbot comments.

fastrepl/anarlog · 55 tokens

reactive-sqlite-ui

Build SQLite-backed reactive UI in apps/desktop using stable patterns for reads, selection, forms, writes, and loading states. Use when implementing or reviewing screens built on useDrizzleLiveQuery and SQLite mutations.

fastrepl/anarlog · 53 tokens