AGENT SKILL

complexity-anti-drift

Use when ESLint flags complexity, max-depth, max-lines, max-lines-per-function, or max-params; when jscpd is over 3%; when a changed function exceeds 60 lines, cyclomatic 15, 4 params, or nest 4, or a changed file exceeds 1000 lines; or when the user asks to split a function or extract a helper.

License 许可
MIT
最近更新
2026-10-28
Stars
★ 2
Forks
0

01 前言 Front Matter

name
complexity-anti-drift
type
discipline
bucket
engineering
description
Use when ESLint flags complexity, max-depth, max-lines, max-lines-per-function, or max-params; when jscpd is over 3%; when a changed function exceeds 60 lines, cyclomatic 15, 4 params, or nest 4, or a changed file exceeds 1000 lines; or when the user asks to split a function or extract a helper.

02 资源文件 3

03 SKILL.md 正文

Complexity Anti-Drift

Complexity drifts by accretion: one branch, one nested if, one more parameter. Each addition is locally defensible and globally fatal. The fix is extraction along the responsibility line, not along "where the code happens to be". Helpers extract; comments do not.

This skill owns the extract/split on a complexity offender. Hard FAIL vs soft REVIEW gates live in references/thresholds.md. Measurement is arthurpower:complexity-anti-drift-agent.

When to use

Reach for this skill when the next move is to stop complexity accretion:

  • CI reports a complexity gate failure (ESLint complexity / max-depth / max-params / max-lines-per-function / max-lines, or jscpd)
  • A request to refactor, split a function, reduce complexity, extract a helper, or fix an ESLint complexity violation
  • A PR that "just adds one more case" repeatedly
  • A function, file, nesting, params, or clone report in the diff has crossed the gates in references/thresholds.md

A one-line getter or setter, a test fixture kept complex for clarity, generated or vendored code, or a declarative config / type-only file is out of scope.

Procedure

  1. Measure the diff. Hand the diff range to arthurpower:complexity-anti-drift-agent with subagent_type: "arthurpower:complexity-anti-drift-agent". Pass: diff scope + gates in references/thresholds.md + evidence shape (file:line + PASS/FAIL/REVIEW/NOTE). Prefer the agent over measuring in the current thread. 软触发:应当派,非必须派;偶发主线程自跑属可接受降级,不视为违规. Completion: a per-metric table with file:line evidence, or equivalent linter/jscpd capture if the agent was skipped.

  2. Extract along the responsibility line. For each new offender — extract a helper, not a comment. The function stays at one abstraction level. If extraction reveals two responsibilities, split along the responsibility line, not along "what code happens to be there". Clone offenders: extract the shared logic into a function, not a duplicated-string collapse. Nesting offenders: early-return / guard-clause, not collapsing one branch. Chained ternaries, // just this once / // temporary, duplicate blocks, and comment-instead-of-extract: references/pressure-and-antipatterns.md. Completion: every new hard-gate offender is extracted or split; every new soft-trigger is extracted, split, guarded, or left as explicit REVIEW.

  3. Re-measure. Re-run the agent (or the linter/jscpd). Completion: all hard gates pass; no new unreviewed soft-trigger; git diff --stat shows extracted helpers of reasonable size.

Acceptance criteria

A complexity pass is complete when all of the following hold:

  • [ ] Diff measured against references/thresholds.md (agent table, or in-thread linter/jscpd capture)
  • [ ] Every new hard-gate offender extracted or split along the responsibility line
  • [ ] Every new soft-trigger is extracted, or left as REVIEW — not FAIL
  • [ ] Parameter counts exclude self/this
  • [ ] No chained ternary; no // just this once / // temporary beside a complex block (references/pressure-and-antipatterns.md)
  • [ ] Re-measure is green on hard gates (linter exit 0 on touched files)

References

04 同仓库更多 Skills

winter6205
winter6205/arthurpower

writing-plans

Use when turning a buildable spec into ordered tracer bullets after architecture-change-reviewer. Covers vertical slicing, dependency order, and headroom for the implementer. Triggers on 写计划, 拆任务, 任务分解, 制定方案, 跨文件改动, 计划.

★ 2
winter6205
winter6205/arthurpower

wayfinder

Use when a chunk of work is more than one agent session can hold — plan it as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.

★ 2
winter6205
winter6205/arthurpower

verification-before-completion

This skill should be used when claiming "完成" / "done" / "fixed" / "passing" / "ready to ship", before trusting a subagent success report, or when checking "对照计划" / "对照 spec" — whether this run's delivery matches its basis.

★ 2
winter6205
winter6205/arthurpower

using-agent-skills

Use when starting a new session, switching tasks, or unsure which arthurpower skill applies. Routes incoming work to the matching skill via flowchart before invoking. Activates on phrases like "which skill should I use", "skill check", "pre-task skill check", "how to start", "router", "skill routing", or when multiple competing skills could apply. Does not auto-invoke user-invoked authoring skills (skill-authoring, self-evolving-rules).

★ 2
winter6205
winter6205/arthurpower

test-driven-development

Use when implementing logic, fixing a bug, or changing behavior — write the failing test first (RED), then minimal code (GREEN), then refactor. Triggers on "write the failing test first", "Prove-It", or a bug that needs a reproduction test before the fix.

★ 2
winter6205
winter6205/arthurpower

systematic-debugging

Use when debugging a test failure, build break, unexpected runtime error, flaky test, or hanging process. Triggers on phrases like "fix this bug", "getting an error", "failing test", "flaky", "hanging", "halfway through debugging", "this used to work", "intermittent failure", "stack trace shows X", or any case where behavior does not match expectations. Prevents shotgun debugging.

★ 2