shadow-frog-update
Update the shadow knowledge base after code changes and from conversational insights. Detects what changed via git diff, refreshes per-file shadows, captures knowledge shared by the user during the session, and updates cross-cutting discoveries. Invoke manually with /shadow-frog-update; the preToolUse hook will remind the agent when the shadow is behind HEAD.
- License 许可
- MIT
- 最近更新
- 2026-11-05
- Stars
- ★ 33
- Forks
- 9
01 前言 Front Matter
- name
- shadow-frog-update
- description
- Update the shadow knowledge base after code changes and from conversational insights. Detects what changed via git diff, refreshes per-file shadows, captures knowledge shared by the user during the session, and updates cross-cutting discoveries. Invoke manually with /shadow-frog-update; the preToolUse hook will remind the agent when the shadow is behind HEAD.
03 SKILL.md 正文
ShadowFrog Update
Updates .shadow/ from two sources: code changes (git diff) and conversational
knowledge (what the user said during the session). Prerequisite: .shadow/ exists.
Triggers
- Hook reminder:
preToolUseinjects a staleness warning when.shadow/_meta/state.json#last_commitdiffers from HEAD. The hook only reminds — it does NOT auto-run update. - Manual: user invokes
/shadow-frog-update
Phase 1: Detect Changes
# Read last_commit defensively: it may be missing, or the literal "none"
# when init ran without git (e.g. inside a container). `git diff none HEAD`
# would abort with "fatal: bad revision 'none'", and a missing key would
# make $LAST_COMMIT empty so `git diff HEAD` silently reports the wrong set.
LAST_COMMIT=$(python3 -c "import json,sys; print(json.load(sys.stdin).get('last_commit','none'))" < .shadow/_meta/state.json 2>/dev/null || echo "none")
if git rev-parse --verify "$LAST_COMMIT" >/dev/null 2>&1; then
git diff --name-only "$LAST_COMMIT" HEAD # committed changes since last update
else
echo "WARNING: state.json has no usable last_commit — falling back to a full re-scan."
fi
git diff --name-only HEAD # uncommitted changes
git diff --name-only --cached # staged changes
Categorize: modified, added, deleted, renamed.
Phase 2: Update Per-File Shadows (Symbol-Level)
Use the same extraction interface as init, rather than inventing a separate symbol scanner. From the project root:
python .github\skills\shadow-frog-init\shadow-init.py --symbols-only
# Claude Code: use .claude\skills\shadow-frog-init\shadow-init.py instead.
This prints JSON without changing .shadow/. It inherits the optional
symbol_backend configuration from _meta/state.json (absent means regex).
For Astred, run python install-astred.py (Linux: python3) from the
ShadowFrog checkout once; setup defaults to latest stable, with optional
--version <exact-version>. The executable is discovered from per-user setup
configuration. SHADOWFROG_ASTRED_COMMAND or --astred-command override it;
do not store its path in shared metadata. Unchanged Python files reuse
_meta/symbols.json; changed Python files are batched through the pinned backend.
C/C++ uses the recorded build-derived Astred project (or --astred-project).
Native projects are always reparsed, even without source diffs, because headers
can change declarations in unchanged translation units. Keep the configured
compiler environment, includes, defines, and forced headers available; setup
alone does not generate an OS build project. Other languages explicitly use
regex. Stop on extraction failure; a failed inventory does
not mean that all symbols disappeared. Use each record's qualified_name for
file::symbol references and heading for Markdown headings.
When adopting Astred, upgrading its release/normalizer, or changing the native
project/compile settings, first run
--preview-migration --symbol-backend astred with the intended executable.
Treat all affected shadow files as changed, even without a source diff.
Also compare freshly extracted native symbols for unchanged source files
after header changes; source hashes alone are insufficient.
Review scope-change candidates; do not assume same-leaf names prove identity.
Preserve unmatched/ambiguous sections and their discoveries as history until
resolved. Apply only confirmed mappings, updating Also involves: and _cross/
**Refs**: consistently, without changing trust metadata or citation scores.
Never use --reset to migrate. This is a reviewed agent workflow, not an
automatic knowledge-rewriting command.
For each changed file, update its shadow at the symbol level:
| Symbol change | Action |
|---|---|
| Added | Add the appropriate ##/### heading |
| Removed | Mark the section REMOVED; keep discoveries for history |
| Renamed | Move discoveries to the updated heading |
| Modified | Check whether discoveries still hold |
Only mark source: user discoveries stale if the symbol is completely removed.
Lightweight update (auto/hook): re-extract symbols, update headings, flag stale. Deep update (manual/dream): read diffs, generate new discoveries, verify existing ones.
Phase 3: Capture Conversational Knowledge
When the user shares knowledge during the session, write it immediately. Do not batch for later.
Capture warnings, gotchas, design intent, history, deprecations, contracts, and conventions. Representative examples:
| Signal | Example | Category |
|---|---|---|
| Warning | "Don't change the retry logic, it's subtle" | warning |
| Design intent | "We use this pattern because the API is unreliable" | intent |
| Convention | "Always use the helper in utils.py, not raw SQL" | convention |
Write as:
- <user's words, as close to verbatim as possible>
_(verified, source: user, citation_score: 0)_
For knowledge emerging from collaborative work (debugging, refactoring, test failures):
- <what was discovered and how>
_(verified, source: interaction, citation_score: 0)_
Anchor to the specific file::symbol. source: user and source: interaction
are always verified.
Auto-Placement
Users will not specify where to store their knowledge. You must find the correct location. Procedure:
- Parse the user's statement for code references — file names, function names, class names, module names, variable names, error messages, CLI flags.
- If the knowledge is a project-wide preference or convention with no code
references (e.g., "always use snake_case", "no backward compatibility",
"prefer small PRs") → write to
_prefs.md. - If explicit references found → look up those
file::symbolpaths in_index.mdand the corresponding shadow files. - If no explicit references → use context:
- What file is the user currently viewing or editing?
- What files were recently modified in this session?
- Search shadow files:
grep -rl "<keyword>" .shadow/ --include="*.md"
- If multiple candidate locations → pick the most specific symbol that the
knowledge applies to. Prefer a single
file::symbolover file-level. - If the knowledge spans 3+ files → create a
_cross/<slug>.mdentry and add back-pointers to each involved file's## Cross-References. For 2-file discoveries, use per-file entries withAlso involves:instead. - If no matching location exists (e.g., the user mentions a concept not yet in
the shadow) → place at the file-level
## File-Levelsection of the most relevant file, or create a new_cross/entry for repo-wide knowledge.
Never ask the user "where should I put this?" — always resolve placement yourself.
Phase 4: Extract Session Insights
At session end or manual trigger, review the session for:
- Files modified and why
- Patterns revealed by the changes
- Unrecorded conversational knowledge (user statements not yet shadowed)
- Cross-cutting discoveries (create in
_cross/<slug>.mdif 3+ files involved)
Phase 5: Handle Structural Changes
Added files:
- Check
.shadow/.shadowignore— skip if the file matches an ignore pattern - Create
.shadow/<path>/<file>.mdwith symbol-organized template - Add
## Cross-Referencessection - Add to
_index.md
Deleted files:
- Add
ORPHANEDmarker to shadow header - Keep shadow (discoveries explain history)
- Mark
[REMOVED]on any_cross/refs pointing to this file - Update
_index.md
Renamed files:
- Move
.shadow/<old>.mdto.shadow/<new>.md - Update all
_cross/**Refs**:entries (old path → new path) - Update all
Also involves:in other per-file shadows - Update
_index.md - Preserve all discoveries
Phase 6: Verify and Dedup
Follow the dedup and writing rules in /shadow-frog — read before
write, merge or update existing entries, fix bad format in place.
Verify exploration discoveries using the observe-based or do-based
methods in /shadow-frog § Verification. source: user and
source: interaction → always verified; only re-verify if the
underlying code changes.
Phase 7: Verify Reference Integrity
Check the five core invariants (full 7-invariant set in /shadow-frog):
- Every
_cross/<slug>.mdref has a back-pointer in per-file## Cross-References - Every
## Cross-Referencesentry has a corresponding_cross/<slug>.md - No duplicate cross-cutting filenames
- All
Also involves:usefile::symbolnotation - No duplicate discoveries (same behavioral claim at same symbol)
Repair any violations before proceeding.
Phase 8: Update Metadata
Preserve dream_cycles_completed from the existing state — only dream-reconcile.py increments it.
Also preserve optional symbol_backend metadata. After a successful update,
save the validated extraction inventory (without its optional migration
section) to _meta/symbols.json; refresh fallback_languages from that report.
For a reviewed backend/version migration,
adopt the report's symbol_backend only after all affected headings and
references are reconciled. Never publish new backend metadata or replace a
good cache after a failed extraction or incomplete migration.
{
"version": 1,
"initialized_at": "<preserved>",
"last_update_at": "<now ISO>",
"last_commit": "<full 40-char HEAD SHA>",
"last_update_type": "init|auto|manual|dream|meditate",
"total_files": N,
"total_symbols": N,
"total_discoveries": N,
"dream_cycles_completed": <preserved>
}
Refresh _index.md with current counts.
Discovery Writing Rules
See /shadow-frog § Discovery Format for the verbatim per-file,
cross-cutting, and preference formats. Rules to keep in mind during
update sessions:
- Start new claims/preferences with
citation_score: 0; preserve the score when updating the same knowledge. Citation-only edits do not add discoveries. - Record deliberately consulted existing entries once per task using the core
shadow-cite.pyhelper, not a retrieval requirement or a second hidden store. - Be behavioral: "silently returns None on expired tokens" not "handles token expiration"
source: userandsource: interaction→ alwaysverified, use user's own wordssource: exploration→ markuncertainunless verified by code reading or tests- If 3+ files involved → create in
_cross/<slug>.mdinstead, add back-pointers - If project-wide preference with no file reference → write to
_prefs.md - Slug naming: kebab-case derived from title (e.g., "Token expiry config split" →
token-expiry-config-split.md)
04 同仓库更多 Skills
shadow-frog
Use a shadow knowledge base to understand any codebase. The .shadow/ directory mirrors the source tree with markdown files containing behavioral insights — known bugs, edge cases, implicit contracts, and user preferences. Always check the shadow before editing, debugging, or investigating code. When the user shares important context, write it to the shadow immediately. Invoke shadow-frog-init to create it, shadow-frog-update to refresh it, shadow-frog-dream for autonomous experiments, shadow-frog-nap for lightweight feature-task ideation, shadow-frog-meditate for shadow hygiene, or shadow-frog-viewer for user-facing browsing and visualization.
shadow-frog-viewer
Help users browse and visualize the shadow knowledge base: overview, search for files or symbols or text, view preferences, or see recent discoveries. Invoke when the user wants to see what's in the shadow, get an overview, or find specific knowledge.
shadow-frog-nap
Generate grounded software feature-task briefs with a small, bounded ideation budget instead of implementing every idea. Read focused source and optional shadow/dream evidence, grow or resume a persistent proposal tree, and obtain independent shortlist judgments. Run only decision-changing probes of existing behavior. Use mode=coherent to connect each child to its parent's findings or design while encouraging diverse siblings. Use for lightweight ideation, nap runs, or preparing SWE implementation tasks; use shadow-frog-dream for full implementation-backed experiments.
shadow-frog-meditate
Clean and consolidate the shadow knowledge base. Scans all shadow files for duplicate discoveries (same claim, different wording), near-duplicates (one extends another), and conflicting entries (contradicting claims). Merges duplicates, resolves conflicts by investigating the code, and asks the user only when resolution is unclear. Invoke periodically to keep the shadow focused and free of noise.
shadow-frog-init
Initialize a shadow knowledge base for any codebase. Creates a .shadow/ directory that mirrors the source tree with markdown files for AI-discovered insights. Run this once per repo before using other shadow-frog skills. Refuses to overwrite an existing .shadow/ unless --reset is passed.
shadow-frog-dream
Run autonomous experimentation while the user is AFK. Uses 6 investigation categories (investigation, bug hunting, feature design, refactoring, optimization, security audit) to systematically discover non-obvious behaviors. Every task is an experiment — implement in worktrees, commit to persistent dream branches, and push to the configured remote. Dreams compound across sessions: future experiments branch from prior dream branches, building a tree of progressively deeper work. Invoke when the user is AFK or asks for a dream run. Use mode=coherent to ground each child in its parent while encouraging diverse siblings, challenges, and alternatives.