Force a global-first posture for every code change that touches shared contracts:
names, states, paths, configs, schemas, entry points, fallbacks, or documentation.
The default agent behavior is to patch the immediate error site. This skill overrides
that instinct: **scan globally, identify the single source of truth, modify as a group,
audit for residue, then verify.**
Every task under this skill MUST follow these phases in order.
Skip a phase only if you can explicitly justify why it does not apply.
Determine which consistency category applies:
| Category | Examples |
|---|---|
| ---------- | ---------- |
| naming | Variable, field, parameter, event name unification |
| state-machine | Status values, transition rules, write-back entry |
| config-path | DB path, env var, runtime config, deploy assumption |
| entry-point | Consolidating orchestrator / service / manager as sole entry |
| schema | Table name, column name, migration, compatibility layer |
| legacy-cleanup | Removing old fallback, old table writes, old function names |
| doc-alignment | Syncing SKILL.md, README, comments, contract docs with code |
| cross-module | Multi-repo or multi-directory coordinated change |
If multiple categories apply, lead with the one closest to the source of truth.
Answer explicitly before writing any code:
If no architecture contract document exists, produce a temporary contract summary
(inline in your plan) covering: canonical state field, canonical write entry, canonical
config source, and legacy items to retire. Read references/contract_template.md for
the template when creating a persistent contract file.
Search the entire relevant scope (not just the current file) for:
Use scripts/grep_legacy.py when available:
python3 <skill_dir>/scripts/grep_legacy.py <directory> <pattern1> <pattern2> ...
Use scripts/scan_contract_drift.py for multi-source detection:
python3 <skill_dir>/scripts/scan_contract_drift.py <directory> [--pattern-file <file>] [--mode default|lite|strict]
Mode guidance:
default: best general-purpose mode; ignores reference/template/test-only mentions as evidencelite: same filtering as default, but down-ranks lower-risk categories for quick triagestrict: count every matching file, including references and tests, for forensic auditsFor small consistency fixes touching only 2-3 files with one clear source of truth,
you may run a lite variant of the workflow:
Use full 8-phase mode for state machines, schema changes, config paths, entry-point
consolidation, or any task where multiple competing truths may exist.
Before touching code, output a concise plan:
Do NOT proceed to edits without this plan.
Recommended order: source of truth → callers → config layer → compatibility layer → tests → docs.
Rules:
# COMPAT:
After all edits, actively search for:
Use scripts/grep_legacy.py again with the retired names.
If any residue is found, either fix it or explicitly document why it remains.
Execute at least one of:
Every task MUST end with a report containing these sections:
| Section | Required | Content |
|---|---|---|
| --------- | ---------- | --------- |
| Classification | ✅ | Which consistency category |
| Source of truth | ✅ | The canonical location |
| Scope | ✅ | Files/modules affected |
| Changes made | ✅ | Concrete list of modifications |
| Residual compat | ✅ | What old logic remains and why |
| Verification | ✅ | What checks were performed |
| Follow-up risks | Recommended | Next steps or remaining debt |
Read references/output_template.md for the full report template.
These are non-negotiable constraints:
table/column names, status fields, status values, event names, service entry points,
fallback logic, or documented main paths.
If you observe any of these recurring in a project, recommend creating an
ARCHITECTURE_CONTRACT.md (template in references/contract_template.md):
references/workflow.md — Detailed workflow with decision branches and edge casesreferences/output_template.md — Structured report templatereferences/risk_patterns.md — Common consistency risk patterns with examplesreferences/contract_template.md — Architecture contract template for projects lacking onescripts/grep_legacy.py — Scan directories for legacy name/path/status residuescripts/scan_contract_drift.py — Detect multiple competing sources of truth; supports --mode default|lite|strictscripts/summarize_impacts.py — Aggregate scan results into an impact summary共 1 个版本