/foundation:fa-foundation-optimize-directory-treefrom foundation
Bootstraps a Gaia context layer (CLAUDE.md + MEMORY.md topic store) onto an existing directory tree, or re-derives one from source. Use when a code/research/ops tree lacks context or has stale claims.
Ships in foundation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill to put the Gaia context layer onto a directory tree that has none, and to keep an existing one true. A scope is any directory carrying the pair — its instruction file (CLAUDE.md or AGENTS.md) plus a memory/ topic store and the MEMORY.md index derived from it; a grouping directory is one whose only job is holding scopes (projects/, packages/, apps/, services/), a term with no industry usage and therefore defined here rather than assumed.
Depth is earned, never mechanical: a directory gets a pair when it has working rules an agent would otherwise get wrong — so a single repository with no sub-projects is a legitimate degenerate partition of exactly one scope, written by the caller rather than dispatched to a branch.
Use this skill when:
Do not use this skill when:
fa-foundation-context-authoring, or fa-foundation-memory-maintenance where the store is structurally sound and merely stalefa-foundation-context-auditfa-foundation-registry-auditdocs/architecture/ is the deliverable — that is fa-engineering-architecture, which owns those documents and their templatesfoundation alone establishes the context layer, and retrospective design documentation additionally requires the engineering plugin installeddocs/ file the tree already carries, read end to end before any of them is touchedmemory/ topic and re-read by every later run to detect its own modefa-foundation-context-audit, and re-validation hands per-scope content drift to that skill rather than reimplementing it.fa-foundation-context-authoring; if that scope's store is sound and merely stale, it is fa-foundation-memory-maintenance. This skill creates memory stores where none exist and never deep-refreshes one.fa-foundation-registry-audit. This skill establishes the registry once from the frozen partition map; re-validation mode calls that skill for everything after.docs/architecture/ is the deliverable, that belongs to fa-engineering-architecture — this skill owns the analysis that makes writing them possible and hands it over. Where the engineering plugin is absent, record a question topic and continue; never invent a substitute template.analysis-depth: pending entries → continue; root pair present and every entry deep → re-validation; re-validation returning no source drift → sweep, the terminal steady state a healthy tree spends most of its life in.
Enumerate candidates from cheap filesystem markers only and cap the list before applying judgement, or a large tree exhausts the caller's context before anything reaches disk; give every scope a writer and an analysis-depth; cap concurrent dispatch at 8 per wave and stage analysis depth above 25 analysable projects, giving each deferred scope a minimal pair so it does not fire MISSING-PAIR against the layer this run just built. Write the map as a root memory/ topic — type: reference, opening with a do-not-delete line naming this skill's mode detection as its reader — and generate the MEMORY.md index above it in the same action with --fix-index, never by hand, splitting the map by grouping above roughly forty entries so each file stays inside the topic size caps.<ROOT_PATH>/.tmp/pre-bootstrap/<relpath> any pre-existing instruction or memory file whose current content is not recoverable from HEAD — unversioned, untracked, or dirty — and record every repository as clean-before or dirty-before.
Root's rules are held in the caller's context so every branch has a parent to compute its delta against; they land on disk at step 7, because a root file asserting rules no leaf implements reads as a completed bootstrap. The roster is written last, from what the branches found..gitignore edits, the write allow-list, whether builds will run — stated in every run; only the blocking go-ahead is waived by step 1, because one misfiring predicate otherwise produces an unannounced multi-hundred-file write.
Dispatch one general-purpose subagent per disjoint subtree, in a single dispatch, pasting the body of references/analysis-brief.md verbatim with exactly three substituted tokens — <ROOT_PATH>, <SCOPE_PATH> and <MODE> — plus a "parent rules in effect" block; never dispatch fa-foundation-context-auditor, which carries its own method and converts a briefed branch into an unbriefed one that looks identical. Give the judgement-heavy branches the strongest model and highest reasoning effort the session offers — a tier, never a model name. Each branch drains its report to <ROOT_PATH>/.tmp/reports/ and returns a pointer plus its registry row. Where subagents do not exist, the partition, the one brief and the report contract still bind: run one scope at a time and reconcile root last.fa-engineering-architecture inside its own scope.
Two gates, both the branch's: the project must have an executable surface — build file, entrypoint, routes, schema, deployable artifact — and the four templates are gated individually, user-interface-template.md only where a human-facing interface exists in source. A template judged inapplicable is one line in a decision topic, not a file. Where a branch wrote docs from scratch, a second subagent gets the same pasted brief with the verify-doc token and returns only citation failures, aspiration in the present tense and unmarked inference; the caller applies them at step 7, never the branch that wrote the doc.writer field makes the split checkable from either end.
A pre-existing instruction file is read whole, its state-bearing sentences split into the new memory store, and only missing sections appended; anything not confidently classifiable becomes a question topic rather than a deletion, and an existing AGENTS.md or CLAUDE.md is never deleted or renamed. This skill owns coverage; fa-foundation-context-authoring owns each file's shape.python3 ${CLAUDE_PLUGIN_ROOT}/scripts/context-audit.py --scope <dir> --scope <dir> … --fix-index, which also regenerates every index the branches' topic files derive to — with --registry only where the tree carries a full markdown registry, and --instruction-file where the tree chose AGENTS.md.
Assemble the change manifest by concatenating the reports' files written blocks, never by re-walking the tree, which cannot tell what this run wrote from what was already there. Apply the sweep's proposed deletions and the verify pass's findings here. Where a hosted memory store holds entries for this tree, recall them, reconcile toward local, and record every contradiction as a question topic — the tree's own memory is the source of truth; hosted tooling is used alongside it, never instead of it. Propose capability adoptions — plugin capabilities a level should now name, a docs/ layer to point at, a manifest the registry could defer to — as decision topics carrying their rationale, and never install a plugin, edit a settings file, add a hook or enable a tool.This is the only content nobody else owns, and everything downstream inherits it. Slop here does not look like laziness — it looks like a well-structured document about a system that does not exist. All six evidence rules live verbatim in references/analysis-brief.md, because the branch reads the brief and never reads this file. Two of them are the caller's, enforced at reconciliation:
watch-worthy finding.The four the brief carries alone: never write aspiration in the present tense · mark inference inline · a directory of loose files is not a system, so say what it actually is in one honest sentence · confirm the project is alive first, because dormancy is one paragraph and a dated state topic, not a document set.
Plus the standing prohibition, which binds the caller exactly as it binds a branch: never transcribe a credential, token or connection-string value. Name the variable and where it is sourced; a secret found committed is a watch topic describing the location without reproducing the value.
| Failure mode | Recovery | Owner | Escalation |
|---|---|---|---|
| interview skipped under an autonomy instruction | take every filesystem default and record each inference as a question topic, owner unassigned | caller | owner reviews the questions before the layer is trusted |
| a branch fails, times out, or returns off-contract | roll its scope back from the discarded report's files written block, re-run once, then demote to watch | caller | never re-run a scope whose report has no files written block — flag it for human review first |
| engineering plugin absent | record the gap as a question topic and continue; never invent a substitute template | caller | owner installs engineering and re-runs in re-validation mode |
| pre-existing instruction file found | adopt it, split its state into the new store, append only what is missing | branch | caller, for anything not confidently classifiable |
| script reports findings this run itself created | classify as bootstrap residue against the expected-findings list, and do not chase them | caller | none — a dirty tree per repository is the intended terminal state |
.tmp/, naming .tmp/pre-bootstrap/ as the only undo path for content not recoverable from HEADfa-foundation-session-close's local-commit step is suppressed here, and the reason is stated rather than left for an auditor to file as a defectfa-engineering-architecture the doc-versus-source disagreements and any README contradictions the branches returned, as follow-ups rather than side effectsfa-foundation-context-audit and fa-foundation-registry-audit a tree they can now run against, and fa-foundation-create-skill any local skill the sweep proposed adding, rewriting or deletingdocs/architecture/ has gone stale against its code — that is fa-engineering-architecture, and a single scope's pair drifting is an authoring or an audit job.memory/ topic, and every scope in it carries a writer and an analysis-depthMEMORY.md was generated from its topic files rather than hand-written, and the residue is listed as expected findings rather than chasedWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub frostaura/technologies.fa.gaia --plugin foundation10 skills in this plugin
/fa-foundation-context-auditProvides the whole-repository context-layer drift sweep — every instruction file, every MEMORY.md and topic store, and every skills directory reconciled against inspected reality rather than against what the files claim. Use it when the periodic sweep is due, after a long dormancy, before any decision that depends on the context layer or the registry being literally true, when more than one scope looks untrustworthy at once, or when a previous sweep's findings need verifying rather than re-deriving. It checks what those files and registries claim against what is on disk; it never re-derives what they should say from a project's source — a tree with no context layer, or one to rebuild from source, is `fa-foundation-optimize-directory-tree`'s./fa-foundation-context-authoringProvides cascade-aware authoring for a scope's instruction file (CLAUDE.md or AGENTS.md) and its MEMORY.md topic store, keeping timeless rules strictly separate from dated state and holding every scope to its own delta over its parent. Use it when creating, rewriting or restructuring either file at a single scope whose surrounding cascade already exists, when a nested scope restates content it already inherits, when an instruction file has started asserting status, versions or progress, or when a memory store has no memory/ directory, carries malformed topic frontmatter, or has a hand-written index instead of one generated from its topic files.Other plugins' skills for the same job