plugins/codebase-audit-suite/skills/ln-637-test-structure-auditor/SKILL.md
Audits test maintainability and structure: layout drift, orphan tests, fragmented duplicates, test-to-source mapping, and domain grouping. Use when auditing test suite organization.
npx skillsauth add levnikolaevich/claude-code-skills ln-637-test-structure-auditorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Paths: File paths (
references/,../ln-*) are relative to this skill directory.
Type: L3 Worker
Specialized worker auditing test file organization, orphan tests, fragmented duplicates, and layout drift for maintainability as the test suite grows.
MOVE, MERGE, or DELETE_ORPHANMANDATORY READ: Load references/audit_worker_core_contract.md.
Receives contextStore with: tech_stack, testFilesMetadata (ALL types -- both automated and manual), codebase_root, output_dir, domain_mode, all_domains.
Note: Unlike other workers that receive type-filtered metadata, this worker receives ALL test files because directory structure analysis requires the full picture of where both automated and manual tests are placed.
Detection policy: use two-layer detection (candidate scan, then context verification); load references/two_layer_detection.md only when the verification method is ambiguous.
src/, app/, lib/) to build source domain/module treereferences/templates/audit_worker_report_template.md, write to {output_dir}/ln-637--global.md in single Write callWhat: Detect which test organization pattern the project uses and check for unintentional mixing
Detection:
src/users/users.test.ts)tests/users/users.test.ts mirrors src/users/)tests/ or __tests__/)tests/manual/ (informational, not flagged)Layer 2:
tests/automated/integration/). Check if deviation correlates with test typeSeverity: MEDIUM if hybrid without clear type-based rule (>30% of same-type tests deviate from dominant pattern)
Recommendation: Standardize test placement -- choose one pattern per test type and document in testing guidelines
Action: MOVE
Effort: L
What: Detect orphaned test files (source file deleted but test remains) and mismatched paths
Detection:
users.test.ts -> users.ts or users/index.tstest_payments.py -> payments.pyLayer 2:
test_utils.ts, test_helpers.py)Severity: MEDIUM for orphaned tests (dead code), LOW for path mismatches
Recommendation: Delete orphaned tests or update to match current source structure
Action: DELETE_ORPHAN when the source behavior no longer exists; otherwise MOVE
Effort: S
What: Detect test directories with excessive file count that would benefit from subdirectory grouping
Detection:
node_modules, dist, build)test_auth_*.py -> auth/ subdirectory)Layer 2:
tests/manual/ (manual test structure has separate conventions)Severity: MEDIUM (>20 files), LOW (15-20 files)
Recommendation: Group tests into subdirectories by domain/feature. Suggest specific grouping based on file name analysis:
# Before (flat):
tests/test_auth_login.py, tests/test_auth_tokens.py, tests/test_users_crud.py, ...
# After (grouped):
tests/auth/test_login.py, tests/auth/test_tokens.py, tests/users/test_crud.py, ...
Effort: M
Action: MOVE
What: Check whether test directory grouping mirrors source domain structure
Detection:
all_domains or scanned src/) with test directory namestests/{domain}/ directory existssrc/{domain}/Layer 2:
domain_mode="global" or <2 source domains)Severity: MEDIUM for domains with >5 source files but no test group, LOW otherwise
Recommendation: Create test directory/group for domain to maintain structural alignment
Effort: M
Action: MOVE
What: Detect which co-location pattern the project uses and flag inconsistencies
Detection:
Layer 2:
Severity: MEDIUM if >20% of same-type tests deviate from dominant placement pattern
Recommendation: Consolidate test placement -- move deviating tests to follow the project's dominant pattern
Effort: M-L
Action: MOVE
What: Detect duplicate or near-duplicate tests scattered across files where one canonical test would be easier to maintain
Detection:
Layer 2:
ln-632; this worker only owns structural fragmentationSeverity: MEDIUM when duplicate structure increases maintenance cost, LOW for small localized duplication
Recommendation: Merge duplicate tests into one canonical location or shared helper when it preserves product signal
Effort: S-M
Action: MERGE
MANDATORY READ: Load references/audit_scoring.md.
Severity mapping:
MANDATORY READ: Load references/templates/audit_worker_report_template.md.
Write JSON summary per references/audit_summary_contract.md. In managed mode the caller passes both runId and summaryArtifactPath; in standalone mode the worker generates its own run-scoped artifact path per shared contract.
Write report to {output_dir}/ln-637--global.md with category: "Test Maintainability" and checks: layout_pattern, test_source_mapping, flat_dir_growth, domain_grouping, colocation_consistency, fragmented_duplicates.
Return summary per references/audit_summary_contract.md.
When summaryArtifactPath is absent, write the standalone runtime summary under .hex-skills/runtime-artifacts/runs/{run_id}/evaluation-worker/{worker}--{identifier}.json and optionally echo the same summary in structured output.
Report written: .hex-skills/runtime-artifacts/runs/{run_id}/audit-report/ln-637--global.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
Apply the already-loaded references/audit_worker_core_contract.md.
.test. vs .spec.) is out of scope -- do not duplicateMOVE, MERGE, or DELETE_ORPHAN.Apply the already-loaded references/audit_worker_core_contract.md.
{output_dir}/ln-637--global.md (atomic single Write call)Version: 1.0.0 Last Updated: 2026-03-15
testing
Audits architecture config boundaries: typed settings, scattered env reads, config leakage, and layer ownership. Use for config architecture.
tools
Finds architecture-level modernization opportunities: obsolete custom mechanisms, overbuilt extension points, and simplifiable architecture. Use when auditing architecture evolution.
development
Builds dependency topology, detects cycles, validates import rules, and calculates coupling metrics. Use when auditing architecture topology.
testing
Checks layer, resource ownership, and orchestration boundaries. Use when auditing architecture boundary enforcement.