agentleFS
MesteriisMesteriis/Engineering-Bible-AI/skills/architecture-normalizer/SKILL.md

architecture-normalizer

Skill0 starsChanged 4 months agoMITView on GitHub

Decomposes large modules, god files, classes, or packages in reviewable steps while preserving public APIs. Not for routine refactors.

We split this skill into the rules it gives an agent

25 rules. About 0 are common, 15 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill as an architecture normalization engine, not as a general refactoring assistant.

    line 10
  2. Very specific:

    Read references/policy-format.md before creating, editing, or applying architecture policies.

    line 16
  3. Very specific:

    Read references/artifact-contract.md before generating, reviewing, or executing .architecture/ artifacts.

    line 17
  4. Very specific:

    Read references/analysis-signals.md when scoring cohesion, coupling, entropy, god files/classes/packages, split candidates, or dependency …

    line 18
  5. Very specific:

    Use scripts/repo_fingerprint.py <repo> --json for manifest repository hashes and execution preflight checks.

    line 19
  6. Very specific:

    Do not modify source files during Analysis.

    line 23
  7. Distinctive:

    Do not execute normalization without completed Analysis artifacts and explicit approval for the specific actions being executed.

    line 24
  8. Distinctive:

    Keep output deterministic: sorted paths, stable action IDs, stable artifact filenames, and stable YAML/JSON ordering where feasible.

    line 28
  9. Distinctive:

    Stop when the repository fingerprint differs from the manifest, artifacts conflict, a policy is missing or ambiguous, or validation cannot …

    line 29
  10. Distinctive:

    Do not print or store secrets.

    line 30
  11. Very specific:

    If no approved policy exists, resolve a conservative baseline policy from references/policy-format.md, write it under …

    line 36
  12. Very specific:

    Use stable IDs such as MOVE-0001, SPLIT-0001, RENAME-0001, IMPORT-0001, EXPORT-0001, and COMPAT-0001.

    line 50
  13. Very specific:

    Use generated_at: null unless a deterministic repository-derived timestamp is available, such as the HEAD commit timestamp.

    line 53
  14. Very specific:

    If a graph format cannot be produced with available tooling, create the file with a deterministic placeholder graph containing the …

    line 71
  15. Distinctive:

    Treat user edits to artifacts as authoritative unless they violate the non-negotiable contract.

    line 77
  16. Distinctive:

    Treat missing, proposed, rejected, stale, or conflicting actions as not executable.

    line 79
  17. Distinctive:

    If review changes introduce new decisions, return to Analysis and regenerate affected artifacts before execution.

    line 80
  18. Distinctive:

    Before editing source files:

    line 86
  19. Distinctive:

    Stop if the repository changed, unless the user explicitly asks to regenerate Analysis.

    line 91
  20. Distinctive:

    Prefer git mv for file moves.

    line 95
  21. Distinctive:

    Do not use wildcard exports.

    line 98
  22. Distinctive:

    Delete obsolete files only when an approved delete action exists.

    line 99
  23. Very specific:

    If a needed action is missing, stop and write .architecture/execution-blockers.yaml.

    line 100
  24. Distinctive:

    Run the validation commands declared by policy and confirmed from repository configuration when available:

    line 108
  25. Distinctive:

    import/public API validation

    line 114

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Architecture Normalizer

Purpose

Use this skill as an architecture normalization engine, not as a general refactoring assistant. Its job is to move a repository toward deterministic, high-cohesion, low-coupling module hierarchy while preserving behavior and public APIs.

The central rule: every architectural decision must be produced as an explicit reviewable artifact before any source file is changed.

Required References

  • Read references/policy-format.md before creating, editing, or applying architecture policies.
  • Read references/artifact-contract.md before generating, reviewing, or executing .architecture/ artifacts.
  • Read references/analysis-signals.md when scoring cohesion, coupling, entropy, god files/classes/packages, split candidates, or dependency risk.
  • Use scripts/repo_fingerprint.py <repo> --json for manifest repository hashes and execution preflight checks.

Non-Negotiable Contract

  • Do not modify source files during Analysis. Analysis may only create or update .architecture/ artifacts.
  • Do not execute normalization without completed Analysis artifacts and explicit approval for the specific actions being executed.
  • During Execution, never invent moves, splits, renames, import updates, exports, compatibility layers, or deletes. Execute approved artifact actions only.
  • Preserve public imports and exports whenever possible. Generate compatibility exports for moved public API paths.
  • Load policies before analysis. Do not hardcode language thresholds, layout rules, public API rules, or allowed dependency rules into the plan.
  • Keep output deterministic: sorted paths, stable action IDs, stable artifact filenames, and stable YAML/JSON ordering where feasible.
  • Stop when the repository fingerprint differs from the manifest, artifacts conflict, a policy is missing or ambiguous, or validation cannot be run.
  • Do not print or store secrets. Prefer structural evidence: imports, exported symbols, file names, non-secret config keys, tests, and public APIs.

Phase 0: Policy Loading

  1. Inspect repository structure and dependency/config files enough to identify languages and tooling.
  2. Load existing policies from .architecture/policy.yaml or .architecture/policies/*.yaml when present.
  3. If no approved policy exists, resolve a conservative baseline policy from references/policy-format.md, write it under .architecture/policies/<language>.yaml with status: proposed, and mark all execution actions unapproved.
  4. Record the resolved policy files and versions in .architecture/manifest.yaml.

Execution is forbidden when the relevant policy is only proposed, rejected, missing, or internally inconsistent.

Phase 1: Architecture Analysis

Analysis is read-only for repository source files. It must generate deterministic artifacts inside .architecture/.

Required analysis behavior:

  • Compute the repository fingerprint with scripts/repo_fingerprint.py.
  • Detect single-responsibility violations, multiple public types, god files, god classes, god packages, cyclic imports, dead code candidates, duplicate models/DTOs/enums/errors, forbidden generic names, large files/classes/functions, hidden public APIs, layer violations, dependency violations, feature envy, and architecture entropy.
  • Generate explicit remediation artifacts for every proposed change.
  • Use stable IDs such as MOVE-0001, SPLIT-0001, RENAME-0001, IMPORT-0001, EXPORT-0001, and COMPAT-0001.
  • Sort actions by normalized source path, action kind, then destination path.
  • Include evidence and rationale for every action. Evidence should cite files, symbols, imports, exported APIs, tests, or dependency edges.
  • Use generated_at: null unless a deterministic repository-derived timestamp is available, such as the HEAD commit timestamp.

Required artifact set:

  • .architecture/manifest.yaml
  • .architecture/analysis.md
  • .architecture/entropy.json
  • .architecture/dependency-graph.graphml
  • .architecture/package-layout.graphml
  • .architecture/move-plan.yaml
  • .architecture/split-plan.yaml
  • .architecture/rename-plan.yaml
  • .architecture/imports-plan.yaml
  • .architecture/exports-plan.yaml
  • .architecture/compatibility-plan.yaml
  • .architecture/risk-report.yaml
  • .architecture/validation-plan.yaml

If a graph format cannot be produced with available tooling, create the file with a deterministic placeholder graph containing the nodes/edges that were derived and record the tooling gap in risk-report.yaml.

Phase 2: Human Review

Artifacts are the review boundary.

  • Treat user edits to artifacts as authoritative unless they violate the non-negotiable contract.
  • Execute only actions with status: approved or with an explicit current user instruction approving the exact action set.
  • Treat missing, proposed, rejected, stale, or conflicting actions as not executable.
  • If review changes introduce new decisions, return to Analysis and regenerate affected artifacts before execution.

Phase 3: Architecture Execution

Execution reads approved artifacts only. It must not perform fresh architectural analysis.

Before editing source files:

  1. Recompute the repository fingerprint.
  2. Compare it with .architecture/manifest.yaml.
  3. Inspect git status --short and avoid overwriting unrelated user changes.
  4. Stop if the repository changed, unless the user explicitly asks to regenerate Analysis.

During execution:

  • Prefer git mv for file moves.
  • Apply approved moves, splits, renames, import updates, public exports, and compatibility layers in dependency-safe order.
  • Preserve public APIs through explicit exports: Python __init__.py, TypeScript/JavaScript index.ts or index.js, Rust pub use, Go exported symbols, C/C++ public headers.
  • Do not use wildcard exports.
  • Delete obsolete files only when an approved delete action exists.
  • If a needed action is missing, stop and write .architecture/execution-blockers.yaml.

Execution must be idempotent. Running it twice against the same approved artifacts should produce no further source changes.

Phase 4: Validation

Validation is mandatory after execution.

Run the validation commands declared by policy and confirmed from repository configuration when available:

  • formatter
  • linter
  • compiler or type checker
  • unit and integration tests
  • import/public API validation
  • architecture layout validation

Record validation commands and results in .architecture/validation-results.yaml. Report failure exactly; do not claim success unless commands were run and passed.

Output Discipline

When reporting results:

  • Separate Analysis, Review, Execution, and Validation status.
  • List generated or changed artifacts.
  • List source files changed only after Execution.
  • Include exact validation commands and outcomes.
  • State when execution was refused because approval, policy, fingerprint, or validation gates were not satisfied.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.