AgentSkillsCN

arch-checker

为Sage TypeScript模块强化架构依赖边界约束。当src/shared、src/core、src/bot、src/app等目录之间的导入关系发生变化,或在重构模块位置时,亦或是当npm run arch:check命令或CI报告提示边界违规时,可使用此功能。

SKILL.md
--- frontmatter
name: arch-checker
description: Enforce architecture dependency boundaries for Sage TypeScript modules. Use when imports change across src/shared, src/core, src/bot, src/app, when refactoring module placement, or when npm run arch:check or CI reports boundary violations.

arch-checker

Objective

Detect and remediate illegal dependency edges with the smallest safe code change.

Workflow

  1. Run npm run arch:check.
  2. Identify the exact illegal edge from the error output (from -> to).
  3. Apply the smallest remediation:
    • Move adapter/integration code upward to a higher layer.
    • Extract reusable primitives downward into src/shared when truly cross-layer.
    • Replace direct import with an existing allowed interface.
  4. Re-run npm run arch:check.
  5. Re-run npm run test -- tests/unit/architecture/dependencyBoundaries.test.ts.
  6. If imports changed materially, run npm run check.

Remediation Patterns

  • shared importing core or bot:
    • Move business/runtime dependency out of shared.
    • Keep only generic utilities, types, and neutral primitives in shared.
  • core importing bot:
    • Move Discord-specific code into bot.
    • Pass data via core-facing interfaces instead of bot concrete modules.
  • Intentional new edge:
    • Update src/shared/architecture/dependencyBoundaries.ts.
    • Update docs/architecture/OVERVIEW.md.
    • Record migration context in the repository issue tracker when partial.

Guardrails

  • Preserve user-facing behavior.
  • Prefer moving code over weakening rules.
  • Do not relax boundaries without explicit architecture intent.

Output Contract

  • Report failing edge(s), concrete fix, and verification commands run.
  • Include whether policy files were updated or intentionally unchanged.