Materialize

From woditschka/agentic-coding-reference · View interactive version

Materialize is an AI agent skill from the GitHub repository woditschka/agentic-coding-reference. Install or upgrade a project's harness by completely replacing its harness-owned runtime with the current /harness. Auto-detects the stack (Go, Java Spring Boot, or the generic fallback) from the build marker, scaffolds project-owned files via /init when they are missing, replaces the runtime, remov

How to use this skill

Skill file

Materialize

Bring a project's harness to the current /harness by completely replacing its harness-owned runtime. This is the "out" leg of the steady-state loop — materialize out → evolve in the project → harvest back. Runs from the monorepo root; /harness is the source (in future, the installed plugin — same flow, different source).

Usage: /materialize <project-path> (e.g., /materialize ../widget, or samples/go for a sample).

When invoked with no argument, print this block and stop:

/materialize <project-path> — install or upgrade a project's harness by
completely replacing its harness-owned runtime with the current /harness.

  <project-path>   path to the target project (required). The stack is
                   detected from the target's build marker — the init
                   skill's marker table; code home harness/registry.py.

What it does:
  • detects the stack from the build marker
  • scaffolds project-owned files via /init when missing (greenfield)
  • replaces the runtime, removes stale orphans, keeps project extensions
    (asks when unsure)
  • folds a legacy CLAUDE.md into AGENTS.md (one rename, content unchanged;
    two authored files stop the run for a merge)
  • refreshes the harness-managed chapters in AGENTS.md from the single
    source — found by heading, no prompt
  • runs the installed test suites once (a failure means the runtime is
    broken on this host), then runs the doctor

Options live in the target's scripts/layout.toml [harness] table; /init resolves
them on a new project, and /materialize respects them on an upgrade:
  • channel = "copy"        (runtime committed into the repo — the default)
             | "manifest"    (runtime materialized + gitignored, not committed)
             | "marketplace" (tool surfaces ship as a plugin; only the engine
                              sliver materializes project-side, gitignored)
    Resolved by /init (detected, not asked); /materialize never flips it.
    Marketplace is declaration-only — never inferred (its tree mirrors manifest).
  • tools = ["claude", ...]   surfaces installed; claude always on, copilot,
            opencode optional — never added on upgrade
  • extensions = [paths]      project-owned skills/agents/scripts kept, never pruned

Preview only: add --dry-run (or --show-plan) to print the plan — files to
create or overwrite, surfaces excluded, extras kept — and write nothing.

Examples:
  /materialize ../my-service      onboard or upgrade a project
  /materialize samples/go         re-materialize a sample (idempotent)

Complete replacement makes three moves. It installs the current harness runtime. It removes orphans — files an older harness installed that the current one no longer produces. It keeps extensions — files the project added that the harness never owned. The runtime is the only thing replaced. Beyond the runtime, harness-owned content inside project-owned files is kept current in two layers — the deterministic step-4 refresh and the advisory diff-check of steps 8–9. § Project-owned files and version drift holds that contract; this section is a pointer, not a second statement of it.

Precondition: detect the stack

The stack is detected from the target's build marker — the same detection /init and materialize-samples.sh use. The marker table (including the ask-on-multiple-markers and generic-fallback rows) lives in /init's "Precondition" section; the code home is detect_stack in harness/registry.py. The ask-on-multiple rule is this skill's judgment layer — detect_stack itself resolves by order and never asks. No recognized marker is not an error: generic, the technology-free stack, binds its build in scripts/stack.sh.

Process

  1. Read the target from $ARGUMENTS. If no path is given, print the Usage block above verbatim and stop — never guess a target or operate on the current directory. Otherwise verify the path exists and detect the stack (table above).
  1. Scaffold if needed. Three states mean the project-owned files are missing or predate the [harness] table. The target has neither AGENTS.md nor a legacy CLAUDE.md. Its scripts/layout.toml is absent or has no [harness] table. It has no scripts/backlog.sh. Run /init <target> first. /init scaffolds the committed files and asks which tool surfaces to install (claude always on; copilot, opencode optional). It also resolves the channel without prompting — detected from the project's git state, defaulting a greenfield target to copy (runtime committed). Both are written to the [harness] table. A fully set-up project skips this step. A target that still carries CLAUDE.md gets no second rules file from /init; step 4 renames the one it has.
  1. Read the channel and tools from scripts/layout.toml [harness]. channel (copy, manifest, or marketplace) governs orphan removal (step 6); marketplace behaves like manifest (runtime gitignored, not committed). tools is the surface set; on an upgrade materialize.py installs only these (or auto-detects the present surfaces when the key is absent) and never adds a tool the project lacks. To add or drop a tool, edit [harness] tools and re-run.
  1. Replace the runtime. Preview first when the overwrite matters: harness/materialize.py <stack> <target> --dry-run prints the plan — files to create or overwrite, surfaces excluded, extras kept, the rules-file migration, the managed-chapter refresh — and writes nothing. On a gitignored-runtime channel it is the only preview of the overwrite, since no git diff exists. Then run the install:

```bash

harness/materialize.py <stack> <target>

```

It copies core ∪ stacks/<stack> for the resolved tools (overwriting harness-owned files = the "replace") and prints tools=…. It then prints an extras block: files under the harness-owned runtime directories — plus scripts/, minus the project-owned layout.toml and backlog.sh and, on the generic stack, stack.sh — that this install did not produce. Each path prints on its own line between --- extras: N … --- and --- end extras ---; a path the cumulative retired-paths manifest (harness/retired-paths.txt) covers carries the [retired — harness/retired-paths.txt] annotation. The script never deletes an extra; classification is yours.

Before the refreshes the script runs the rules-file migration (harness/rules-file/migrate-rules-file.py) and prints one rules file: line per change. Claude Code reads CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in place of AGENTS.md whenever one exists, so exactly one authored rules file may remain:

For a product workspace, the rules file: lines name each declared member that still carries CLAUDE.md; the script renames in the umbrella only. Propose the rename in each named member. A rules file: line also names a CLAUDE.md above the project: propose the root import stub.

After a rename, the rules file: lines name the title and each docs/ line that still carries the old name. List any other with git grep -n 'CLAUDE\.md', outside the runtime, and propose each fix; never rewrite them silently.

The script also runs three deterministic, marker-free refreshes of harness-owned content inside project-owned files, each reporting its own line (watch materialize.py's output):

The install ends with verification: it runs the test suites it just copied and prints verified: N vendored suite(s) pass on this host. A failure prints its cause plus the error tail and exits 1 — verify: scripts/tests suite run FAILED for the scripts suites, verify: <suite> FAILED per hook suite. The installed runtime is broken on this host (broken copy, python incompatibility). Re-run the materialize; a persistent failure is a harness defect to report upstream, never the project's brief debt. The suite list is the install's own file set, so a project-authored test_*.py is never run as a suite. (--no-verify skips the run; it exists for harness-internal callers only.)

All three refreshes are ensure-present and additive. Harness-owned lines and keys are matched against the shipped template — no markers, no baseline. A project's own ignores, keys, hooks, and chapters are never rewritten, and nothing is removed. Removals and deeper divergence are what step 8's diff-check exists to catch — the residual an additive pass cannot safely decide.

  1. Classify each extra. Check the declared extensions first, then the retired-paths manifest; harness history is the fallback for whatever the manifest predates:

The current harness unit set is harness/core ∪ harness/stacks/<stack>; the former set is that plus the retired-paths manifest, plus what harness history shows was renamed or removed before the manifest existed. A name in the former-but-not-current set is an orphan, not an extension.

  1. Record extensions, then apply removals.

```bash

git -C <target> rm -r --ignore-unmatch <orphan paths>

```

This stages the deletion for the project's next commit; declared extensions are not in the orphan set, so they are untouched. Warn on any local runtime modifications (git status on the orphan paths) before deleting, so the user does not lose hand-edits unknowingly.

  1. Propose removing harness-originated docs (migration). A project migrating from an older harness often carries handbook docs an earlier harness copied into docs/. That content now ships with the harness — as installed skills, or as reference-only docs. The docs/ copies are stale duplicates, and they are why a freshly migrated project's doctor reports handbook-refs failures. Detect and propose their removal (never auto-delete — docs/ is project-owned):

List each candidate with its new harness home and ask the user to remove them. The roster briefs (prd.md, system-design.md, ubiquitous-language.md, testing-principles.md, architecture-principles.md, security-principles.md, adr/) are never proposed. When the user agrees, delete the files and clean the now-dangling references the doctor's handbook-refs check flags. Remove or reword them in the citing briefs and ADRs — that prose is project-owned, so confirm the edits or hand them to /audit-docs.

  1. Diff-check every template-seeded file against its shipped template (advisory). Step 4's deterministic refreshes already made the harness-owned additions current — the .gitignore runtime paths and the .claude/settings.json keys. This step is the completeness backstop over the same diffs: it catches what an additive pass cannot safely decide, and covers the files step 4 does not touch at all. For each template-seeded file, diff the shipped harness template against the project's file, classify every delta, and propose each change — applying it only on the user's OK. What the diff-check surfaces beyond step 4:

Classify each delta by intent, and protect both sides. No markers are written and no version is stamped — the shipped template on disk is the reference, and model judgment stands in for a baseline. For every difference between the template and the project's file, decide which of three it is:

The rule runs both ways: never silently revert a deliberate project change, and never silently drop a harness migration. Without a baseline the classification cannot be proven — a project's coherent customization and a stale generic default can look alike. So the approval step, not an algorithm, is the safeguard, and a genuine collision always goes to the human. This is the same generic-vs-project call step 5 makes for orphan-vs-extension.

| Project file | Shipped template to diff against | Harness-owned in it |

|---|---|---|

| .gitignore | harness/init/core/gitignore-runtime.txt | the runtime-path lines (.claude/skills/*, scripts/*, …) and the .scratch/ ledger; the project's own ignores and the !<extension>/ re-includes are theirs |

| .claude/settings.json | harness/init/core/.claude/settings.json | the env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS flag and the hook entries, under any event, whose command is a .claude/hooks/*.py this install delivered (a legacy *.sh matcher is harness-era residue this diff-check proposes to prune); every other key and hook is the project's |

| scripts/layout.toml | harness/init/stacks/<stack>/scripts/layout.toml | the [harness] table structure, any new keys, and the guiding comments (spec_version is a harness contract value the doctor checks); the classification data — globs, module rules, extensions — is the project's |

| docs/*.md roster briefs | harness/core/.claude/skills/doctor/templates/<brief>.md, with the stack's <brief>.realization.md (when it ships one) as the ## Language Realization section | the skeleton structure — required headings, new sections, and the stack's realization of the section; the filled-in prose is the project's |

Declines are not persisted. A proposal the user turns down is simply left alone. It re-surfaces on the next /materialize — acceptable for an occasionally-run upgrade, and it re-offers a change the user may since have reconsidered. An idempotent re-materialize (no template change, no divergence) finds no delta and proposes nothing, so the only thing that re-appears is a genuine, still-open divergence. If that repetition ever proves irritating, a declined_reconciliations skip-list in [harness] is the pre-authorized next step (ADR generalized-template-reconciliation) — deferred until the friction is real rather than assumed.

  1. Review the materialized AGENTS.md (advisory). Step 4's refresh is deterministic: it overwrites each managed chapter from its heading to the next ## . That is correct for the chapter's doctrine, but a heading-bounded overwrite cannot see what else the edit did to the file. Review the result before moving on. On a tracked AGENTS.md, git diff -- AGENTS.md is the precise signal — read it, and read the whole file once. If the diff is empty (an idempotent re-materialize), there is nothing to review; skip. Otherwise check five things and propose every fix — AGENTS.md is project-owned, so confirm before editing, the same contract as steps 7–8:

Absent headings (legacy migration). A chapter step 4 reported absent had a renamed or missing heading, so the deterministic replace had no target. Locate the equivalent section, propose inserting the matching chapter from harness/rules-file/managed-chapters.md under its canonical heading (placed to match skeleton order), and remove the old copy. Preserve genuine divergence: project-rewritten text stays as its own chapter; stack-specific skills (an IDE oracle) belong in ## Stack-specific skills, not inside a managed one.

This review is advisory and never gates the doctor. A proposal the user declines is not persisted — it re-surfaces next upgrade (step 8's "Declines are not persisted"). Ongoing — outside an upgrade — /audit-docs can run the same checks. It is also the forward edge of /harvest. Harvest pulls a generic improvement up from one project into the source. The managed chapters push it back down to every project automatically once the headings are in place; steps 8–9 propose the rest.

  1. Validate and summarize. Run the doctor from the target:

```bash

( cd <target> && python3 scripts/doctor.py check )

```

Then print a tools / changed / preserved / removed summary:

Project-owned files and version drift

Beyond wholesale replacement of the runtime, materialize keeps harness-owned content inside project-owned files current in two layers. Deterministic refresh (step 4) makes the harness-owned lines of three project-owned files current in place, marker-free: the AGENTS.md doctrine chapters, the .gitignore runtime paths, and the .claude/settings.json harness keys. It is ensure-present and additive, so it reliably delivers a new path or hook but never removes or rewrites. The rules-file migration in the same step is the one move: it renames a legacy CLAUDE.md and removes a symlink between the two names, and changes no content. Advisory diff-check (steps 8–9) is the completeness backstop: it diffs every template-seeded file against its shipped template and proposes each remaining delta, applying each only on approval. The deltas are the removals the additive pass left, plus scripts/layout.toml data, the docs/ briefs, and the non-doctrine AGENTS.md chapters. A declined proposal is not persisted; it re-surfaces on the next upgrade (a declined_reconciliations skip-list is the pre-authorized escape hatch if that ever chafes). There is no version stamp and no stored baseline; the shipped template is the reference, and model judgment separates a missing improvement from a deliberate divergence. Contract drift — a brief-required section, or a new [harness] key — still surfaces in the doctor too, so a skipped proposal is caught again at the gate. The doctor's required-chapter check fails if any managed chapter is missing or empty.

What materialize does NOT do

Relationship to other skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.