--- description: "Agent Skill architecture, documentation layering discipline, and tool-agent boundary principles" globs: "skills/**/*.md" trigger: "manual" --- # Agent Skill Architecture & Documentation Discipline When authoring, refactoring, or maintaining Agent Skills under `skills/`: ## 1. Document Layering & Single Source of Truth Agent Skill documentation follows a strict two-tier architecture: ``` skills// ├── SKILL.md # Tier 1: Lightweight Traffic Routing Hub (导流中枢) └── references/ # Tier 2: Deep Domain Guides & Manuals (业务纵深手册) ├── enterprise-onboarding.md ├── report-templates.md └── ... ``` ### Tier 1: Main `SKILL.md` (Traffic Routing Hub) - **Role**: Lightweight, high-signal, rapid routing hub. - **Allowed Contents**: 1. Frontmatter metadata (name, description, version); 2. Bootstrap & installation guide; 3. Universal system invariants (timestamp format `+08:00`, data masking, stdout/stderr boundaries); 4. Core domain navigation (`corps`, `rules`); 5. Cross-domain terminology contracts; 6. **Reference Routing Table (`## 参考文档路由`)**: The primary mechanism to guide AI agents to specific deep-dive guides based on user intent and intent triggers; 7. A strictly limited number of high-frequency single-step aggregate shortcut commands (e.g. `approval-runs diagnose`). - **Strict Anti-Patterns**: - ❌ **No "Feature Billboard" bloat**: NEVER dump multi-step workflows, full section breakdowns, complete schemas, or qualitative debate procedures into `SKILL.md`. - ❌ **Overcoming "Locality Bias" (就近修改惯性)**: When adding a new capability (e.g. `--ledger`), DO NOT casually expand the main `SKILL.md` just because it's in front of you. Always route to or expand the corresponding `references/*.md`. - ❌ **No Duplicate Maintenance**: If a topic is covered in `references/.md`, do not duplicate its prose or guidelines in `SKILL.md`. The routing table row is sufficient. ### Tier 2: `references/*.md` (Deep Domain Manuals) - **Role**: The authoritative, exhaustive source of truth for deep workflows, business context, and operational troubleshooting. - **Contents**: 1. Business background, objectives, and audience; 2. Multi-step collaborative lifecycles (e.g. human-in-the-loop Tangent reviews); 3. Complete column-by-column schema specifications; 4. Decision matrices and terminology rules; 5. Troubleshooting guides, validation error catalogs (e.g. `HD001`~`INFO002`), and mitigation examples; 6. Concrete Markdown/JSON payload examples. --- ## 2. Tool vs. Agent Boundary Contract (Wrench vs. Discretion) When designing CLI features and their Skill documentation: - **CLI is a Deterministic Wrench (确定性扳手)**: - The CLI provides deterministic, repeatable, pure operations: data extraction, file export/import, offline schema/math validation, and self-contained rendering. - The CLI **MUST NOT** overstep into business discretion: it does not guess subjective fault attribution ("who is right/wrong"), nor does it fabricate explanations. - **Agent Exercises Business Discretion (自由裁量权)**: - The Agent (together with the user) exercises full discretion: pruning templates, filtering dirty data, conducting review debates (Tangent), and authoring qualitative takeaways. - **Strict Offline Boundary (本地事实源绝不越界)**: - When driven by a local artifact (e.g. `--ledger 台账.xlsx`), the CLI treats the local file as the **absolute and exclusive boundary**. - The CLI **MUST NEVER** reach out to remote cloud APIs to investigate records that were intentionally pruned/deleted from the local ledger. - The offline validation gatekeeper evaluates only the internal consistency and mathematical harmony of the remaining records in the ledger. --- ## 3. Terminology Precision & Anti-Ambiguity Contract - **Avoid Ambiguous Catch-All Words**: Never use vague terms that conflate document status with system performance (e.g. completely retire the ambiguous word "失准"). - **Strict Two-Level Separation**: - **Level 1: Document Validity / Approval Decision (审批决策)**: Focuses on the business document itself. Use `通过 (Pass)` / `驳回 (Reject)` / `违规拦截 (Interception)`. Rejection represents rule enforcement, NOT a system defect. - **Level 2: Review Verdict / Correctness Judgment (复核裁决)**: Focuses on whether the AI or human decision was correct upon subsequent review. Use explicit verdicts: `ai_correct`, `human_correct`, `both_correct`, `both_wrong`, `undecided`.