Bootstrap directory README.md files across a repository subtree.
npx skills add https://github.com/google/elephant-goldfish-model --skill egm-bootstrap
egm-bootstrap)This skill automates the creation, correction, formatting, and correctness
verification of Elephant-and-Goldfish Model (EGM) compliant README.md files
across a directory tree. It establishes clear architectural contracts
(interfaces, invariants, and side effects) for both human developers and AI
assistants.
contracts.
contracts into high-altitude indexes.
A Goldfish runs in a fresh context with no conversation history. Spawn each
subagent with your harness's subagent tool (Antigravity: invoke_subagent;
Gemini CLI: subagents). Each subagent is defined in agents/<file>.md, and its
frontmatter name (for example egm-zoom-out) is the subagent type to request
where your harness registers named subagents. Otherwise spawn a general-purpose
subagent and tell it to read that persona file first. Pass the prompt verbatim
and wait for the report. If your harness cannot nest subagents,
use direct dispatch instead of the synthesizer. See docs/harnesses.md.
If your harness has no subagent tool, run the scout steps inline.
path: The target root directory path to bootstrap (Required).is_worker: Internal parameter. true if executing as a workerSub-Orchestrator (Optional, default: false).
sub_tree_root: Internal parameter. The root path of the assignedsubtree partition (Optional).
target_filename: Target contract filename to generate or update(Optional, default: "README.md"). Supports alternate blueprint filenames
such as "EGM.md" when pre-existing human-maintained READMEs must not be
modified.
write or refactor any functional source code.
git commit,git add). All filesystem changes must be written locally using standard
file-writing tools. Tracking
and submitting is deferred to the human user.
perform all status tracking, check-pointing, and log writing in independent,
worker-specific directories outside the project repository workspace.
generation. Adhere to clean Markdown formatting directly during generation
(standard headers, tables, and fenced code blocks). If a project markdown
formatter (e.g. npx prettier --write) is explicitly configured in the
repository, it may optionally be invoked.
subdirectories, you MUST immediately request user approval (using a structured question tool, if your harness has one, or plain chat) before proceeding with full-tree execution
or unbounded subagent spawning.
--------------------------------------------------------------------------------
package.json -> npm test (or pnpm test / yarn test)Cargo.toml -> cargo testgo.mod -> go test ./...pyproject.toml / pytest.ini / setup.py -> pytestMakefile -> make testBUILD / BUILD.bazel -> bazel test ...<test-command>VerificationCommand to populate generated README contracts.--------------------------------------------------------------------------------
is_worker input parameter.is_worker is true, jump directly to **Step 4: Sub-Orchestrator WorkerFlow** to process the assigned sub_tree_root.
is_worker is false or unset, proceed as the Root Orchestrator toStep 2: Incremental Scoping & Safety Gate.
--------------------------------------------------------------------------------
path tree level-by-level(BFS) using a directory queue, listing one directory level at a time. (CRITICAL: never run a recursive search such as find or ls -R.)
.git, .antigravity, node_modules,venv, dist, build, third_party).
.gitignore and .egmignore (if present) and ignore matching glob patterns.package.json, Cargo.toml,go.mod, pyproject.toml, Makefile, BUILD) in the discovery map
to extract verification targets later.
loop, if the total running count of discovered directories exceeds 15,
immediately pause discovery and request user approval (using a structured question tool, if your harness has one, or plain chat) to warn the user and request approval
for full-tree execution:
question: "The target directory tree contains more than 15subdirectories. This is a large execution scope. Do you want to proceed
with full-tree bootstrapping?"
options: `["Yes, proceed with full tree bootstrapping","No, abort execution"]`
response before continuing or spawning any workers).
walk the mapped tree bottom-up (leaves to root). Filter out non-code and
test-only directories:
contract extensions:
.c, .cc, .cpp, .cxx, .h, .hh, .hpp,.rs, .go, .zig, .lean
.java, .kt, .scala, .cs, .fs.py, .rb, .php, .lua, .sh, .bash.ts, .tsx, .js, .jsx, .mjs, .cjs, .swift,.m, .dart
.sql, .proto, .graphql, .gql,.thrift, .prisma
.tf, .hcl, .cue(Excludes build manifests, lockfiles, test fixtures, documentation, and
generic data dumps like .csv, .tsv, .parquet).
test code (e.g. named tests, testing, testdata, or containing only
files matching *_test.*, *Test.*, test_*.*, or *.spec.*).
files AND contains no subdirectories with code. Retain empty
intermediate folders only if they have child directories that contain
code.
to Step 3: Execution Strategy Selection.
--------------------------------------------------------------------------------
documentation directly in the current thread.
Orchestrator as the worker for the entire path), and then proceed to
Step 5: Root Compilation & Termination.
received explicit user approval before proceeding. If not yet approved,
request approval immediately and wait for the user's response before
spawning workers).
Adaptive Depth Partitioning Algorithm:
depth = 1.current depth.
depth is between 3 and 5: select thesenodes as subtree partition roots.
depth < 3: increment depth (up to a maxof 3) and repeat step 2.
depth > 5: group the largest branches (bytotal nested folder count) into 3-4 separate partitions, combine the
remaining small branches into a single fallback partition subtree,
and select these as partition roots.
depth reaches 3 and count is still < 3, select theimmediate children of the root (or fall back to sequential
execution).
use your harness's subagent tool to spawn a parallel worker:
egm-bootstrap-orchestrator (agents/bootstrap_orchestrator.md) (or a general-purpose subagent)Prompt: "Run egm-bootstrap with path=[path],is_worker=true, sub_tree_root=[partition_root],
target_filename=[target_filename]."
artificial concurrency limits (as authorized by the user during the
safety gate).
index payloads. Jump to Step 5: Root Compilation & Termination.
--------------------------------------------------------------------------------
goldfish-explorer scout. Where your harness supports defining subagents at runtime, register it with:name: goldfish-explorerdescription: Read-only codebase explorer scout.system_prompt: >- You are a read-only codebase explorer. Your task isto analyze the source files in the target directory and return a
concise, factual summary. Do not write or modify any files. Return a
JSON object containing the directory's public symbols (interface),
invariants, and side effects matching schema: {"interface": [],
"invariants": [], "side_effects": []}.
enable_write_tools: falseenable_subagent_tools: falsesub_tree_root (or path) inpost-order (deepest leaves first). For each directory D:
target_filename (default:README.md) already exists in D.
target_filename exists, do not overwrite it completely. Instead,read its existing content.
target_filename exists or not,always scan the source code using the goldfish-explorer scout
for D to compile the true code symbol boundary.
target_filename exists, call thereasoning LLM with prompt: > "Analyze the following unstructured
documentation content. Extract all public symbol names, classes,
interfaces, invariants, and side effects. Format your response
strictly as a JSON object matching the following schema: {
\"interface\": string[], \"invariants\": string[], \"side_effects\":
string[] }." Merge these extracted symbols with the scout's code
symbols. Use your file-editing tool (or your file-writing tool) to correct
and update the existing contract file to be EGM compliant while preserving
developer notes and descriptions.
goldfish-explorer for D.bytes. Read implementation and schema files up to 300 lines**
per file. If directory size exceeds 50KB, select files using this
priority:
.h, .hh, .hpp,.proto, .graphql, .gql, .thrift, .prisma, .sql
schema/DDL definitions, interface classes) read completely.
main.*, index.*, lib.*, mod.*,__init__.py, or files matching directory name) read up to 300
lines.
read up to 300 lines until cap.
production and test files, ensure the scout filters out test files
(*_test.*, *Test.*) and ignores their symbols.
warning, use placeholder values `["(Details pending/documentation
failed)"]`, and continue execution.
P,retrieve the compiled interface summaries of its immediate child
subdirectories.
interface directly from the in-memory execution cache.
merged legacy extraction symbols.
P'sexplorer scout.
using the discovered VerificationCommand.
BUILD file existsin D or the nearest ancestor, referencing bazel test / bazel build.
package.json, Cargo.toml,go.mod, pyproject.toml, Makefile), populate with the corresponding
test runner command.
target_filename using your file-writing tool or your file-editing tool based on
D's classification.
D contains direct source codefiles. Use the Component Package README Template. (If it also
has child subdirectories, include relative links to their contracts
in the Interface section).
D contains no direct source codefiles, but contains subdirectories with code contracts. Use the
Intermediate Blueprint README Template.
hybrid link formatting approach to balance portability and clarity:
(e.g., ./child/${target_filename} or ../sibling/${target_filename}) for child
contracts and sibling file references within the same codebase
subsystem. (CRITICAL: Only generate Child
links for child directories that exist in the pruned
subtree_index and contain an actual ${target_filename}. If a child
directory contains a SKILL.md or other non-contract asset, link
directly to ./child/SKILL.md or format it as an unlinked
bullet point. Never output speculative links to non-existent
contract files).
for referencing files outside the package subsystem (e.g.,
cross-package dependencies).
target_filename in D, ensure clean markdown formatting (valid headers,
tables, and code fences). If a project markdown formatter (e.g. npx prettier --write)
is configured in the repository, you may execute it on target_filename.
the subtree_index array containing the path, summary, interface,
invariants, and side_effects for every processed directory.
is_worker is true, return this JSON payload (matching the `WorkerReturn Interface Schema`) to the Root Orchestrator and terminate. If
is_worker is false (sequential mode), proceed directly to **Step 5: Root
Compilation & Termination**.
--------------------------------------------------------------------------------
subtree_index payloadsreturned by all parallel Sub-Orchestrators.
warning, insert a placeholder warning link (`[Subtree Root]
(Documentation failed / Subagent execution timeout)`) in the root
Blueprint's subdirectory index, and complete the remaining compilation.
(Worker failures leaving partial files are handled as an incremental
progress feature; the Correction Policy allows resuming on subsequent
runs).
directories sitting between the root path and the partitioned subtree
roots.
returned by the workers.
Blueprint contract file.
path of the execution is*always* classified as the Repository Root (Blueprint / Hay).
target_filename already exists in path. If present, apply theCorrection & Modification Policy to read and retain the existing
title, metadata, and architectural overview at the top of the root
contract file.
path itself contains any direct source files. If present,spawn a goldfish-explorer scout for path to extract local symbols
and invariants, appending them under the optional `## Local Interface &
Invariants` section.
target_filename using the **Repository Root BlueprintTemplate**, rolling up all top-level subdirectory boundaries.
target_filename using your file-writing tool.verification pass across ALL created and modified contract files in the
subtree_index (including all child package contracts like pkg1/${target_filename}
and pkg2/${target_filename}) as a correctness check before concluding work. You
MUST explicitly read every single created or modified contract file
to verify its content. Do not skip any child contract files. Verify:
Interface, Invariants, and Side Effectssections exist and are populated.
sibling links use valid relative paths (./subdir/${target_filename} or
./subdir/SKILL.md), and explicitly verify that every referenced target
file actually exists on the filesystem. Remove or correct any broken
relative references.
a structured question tool, if your harness has one, or plain chat) to offer running a drift report
on the generated documentation updates:
question: "Do you want to run the EGM Drift Report on the generatedcontract updates to check for consistency with the codebase?"
options: `["(Recommended) Yes, run drift report on modified contracts","No, skip drift review"]`
egm-drift-report skill targetingthe modified contracts to verify that the documentation accurately
reflects the current codebase state. (Note: While egm-drift-report is
often used for design documents, it can be applied to EGM-compliant
contracts as a variant).
--------------------------------------------------------------------------------
# [Component Name]
## Overview
[Prose overview of the component's architectural role and goals]
## Interface
- [Public classes, functions, and symbols]
- [Subdirectories list and relative links to their contracts (e.g., `./subdir/README.md` or `./subdir/${target_filename}`)]
## Invariants
- [State and call invariants that must be preserved by developers/agents]
## Side Effects
- [State mutations, network calls, disk access, locks, or external side effects]
## Verification
- Run: `<test-command>`
# [Repository Name] Blueprint
## System Overview
[High-altitude architectural overview of this subsystem]
[Optional section if the root directory contains direct source files]
## Local Interface & Invariants
- [Direct symbols, invariants, and side effects of files in the root folder]
## Subdirectories & System Boundaries
- [Subdirectory Name]: [Relative link to existing child contract file (e.g., `./subdir/README.md` or `./subdir/${target_filename}`) or `./subdir/SKILL.md`] - [Summary of child contract/role]
## Global Invariants
- [System-wide constraints that cross component boundaries]
## Global Side Effects
- [Shared resources, databases, or external integrations affected by this subsystem]
## System Verification
- Run: `<test-command>`
# [Directory Name]
## Overview
[Factual overview of the subdirectories and systems grouped under this directory path]
## Subdirectories & Boundaries
- [Subdirectory Name]: [Relative link to existing child contract file (e.g., `./subdir/README.md` or `./subdir/${target_filename}`) or `./subdir/SKILL.md`] - [Summary of child contract/role]
--------------------------------------------------------------------------------
{
"type": "object",
"properties": {
"subtree_index": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"summary": { "type": "string" },
"interface": { "type": "array", "items": { "type": "string" } },
"invariants": { "type": "array", "items": { "type": "string" } },
"side_effects": { "type": "array", "items": { "type": "string" } }
},
"required": ["path", "summary"]
}
}
},
"required": ["subtree_index"]
}
Take google/egm-bootstrap from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side โ one of them will be ignored.
The instructions reference npx.
Without those the skill loads but fails at the first command.