with one click
ln-637-test-structure-auditor
// Checks test file organization, directory layout, test-to-source mapping, domain grouping, co-location. Use when auditing test structure.
// Checks test file organization, directory layout, test-to-source mapping, domain grouping, co-location. Use when auditing test structure.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | ln-637-test-structure-auditor |
| description | Checks test file organization, directory layout, test-to-source mapping, domain grouping, co-location. Use when auditing test structure. |
| allowed-tools | Read, Grep, Glob, Bash |
| license | MIT |
| model | claude-sonnet-4-6 |
Paths: File paths (
references/,../ln-*) are relative to this skill directory.
Type: L3 Worker
Specialized worker auditing test file organization and directory structure for maintainability as the test suite grows.
MANDATORY 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
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
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
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
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
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 Structure" and checks: layout_pattern, test_source_mapping, flat_dir_growth, domain_grouping, colocation_consistency.
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 duplicateApply 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