ShadowFrog
CLAUDE.md28 starsChanged 2 months agoMITView on GitHub
ShadowFrog is a suite of AI coding agent skills that build and maintain shadow knowledge bases for any codebase. It consists of 7 skills (shadow-frog, shadow-frog-init, shadow-frog-update, shadow-frog-dream, shadow-frog-nap, shadow-frog-meditate, shadow-frog-viewer) and associated hooks. Nap's proposals remain separate from .shadow/ discoveries. This is a distributable skills package — users install it into their own projects via install.sh or install.ps1.
In this repository7 other files it gives its agents.
- shadow-frog-dreamSkill
- shadow-frog-initSkill
- shadow-frog-meditateSkill
- shadow-frog-napSkill
- shadow-frogSkill
- shadow-frog-updateSkill
- shadow-frog-viewerSkill
The file
We split this claude.md into the rules it gives an agent
12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 120
Keep one visible nonnegative integer citation_score in Markdown metadata, after optional labels.
- Distinctive: line 127
Keep scores when rewording/moving the same claim, and use max rather than sum when combining duplicates or inherited branch state.
- Distinctive: line 133
Do-based: write and run a short test/script to confirm or refute.
- Distinctive: line 137
Before writing, read existing discoveries at the target symbol.
- Very specific: line 139
If _No discoveries yet._ placeholder → replace it.
- Very specific: line 154
Use Refs: with file::symbol entries
- Distinctive: line 248
Use concrete progression questions in selected-path review, not a fixed tree-wide goal or a quota of steps.
- Very specific: line 311
Use python3 -c "import json,sys.
- Distinctive: line 312
Keep hooks fast (< 5 second timeout)
- Distinctive: line 342
Test by running skills in Copilot CLI / Claude Code
- Very specific: line 344
Use install.sh --project <repo> (with --agent copilot|claude) to copy skills, hooks, and context into a project repo
- Distinctive: line 347
After any format change, audit ALL files for consistency (skills, examples, hooks, README, claude.md)
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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.
Files
ShadowFrog — AI Agent Guidelines
Project Overview
ShadowFrog is a suite of AI coding agent skills that build and maintain shadow knowledge bases for any codebase. It consists of 7 skills (shadow-frog, shadow-frog-init, shadow-frog-update, shadow-frog-dream, shadow-frog-nap, shadow-frog-meditate, shadow-frog-viewer) and associated hooks. Nap's proposals remain separate from .shadow/ discoveries. This is a distributable skills package — users install it into their own projects via install.sh or install.ps1.
Repository Structure
ShadowFrog/
skills/
shadow-frog/SKILL.md Main entrypoint (docs, reference system, search)
shadow-frog/_coherence.py Shared structural parent-connection validation
shadow-frog/_citations.py Visible score metadata and safe per-file increments
shadow-frog/shadow-cite.py Record exact consulted claims after native reads
shadow-frog-init/ First-time setup (create .shadow/)
SKILL.md Init instructions + fallback steps
shadow-init.py Python helper script
shadow-frog-update/SKILL.md Incremental update (after changes)
shadow-frog-dream/ Autonomous exploration + experimentation (AFK mode)
SKILL.md Dream instructions + pipeline phases
dream-tools.py Pins current tooling outside historical code checkouts
dream-setup.py Worktree + branch creation
dream-validate.py Pre-push artifact validation
dream-reconcile.py Merge dream branches into main's shadow
dream-coverage.py Exploration coverage map
dream-cleanup.sh Safe per-worktree cleanup (replaces inline snippet)
dream-gc.sh Orphan-worktree sweep (defense-in-depth)
_dream_namespace.py Shared setup/reconcile namespace resolution
_worktree_paths.py Shared worktree-root and path identity helpers
_worktree_safety.py Shared safety gate for rm-rf paths
shadow-frog-nap/ Implementation-free feature-task ideation
SKILL.md Bounded ideation, evidence, and task export instructions
nap.py Portable record validator, parent context, and exporter
shadow-frog-meditate/SKILL.md Dedup, merge, and resolve conflicting discoveries
shadow-frog-viewer/ Browse and query the shadow knowledge base
SKILL.md Query instructions + shell fallbacks
shadow-viewer.py Python helper script
dream-lineage.py Dream lineage visualization
hook-templates/
shadow-frog-hooks.json Copilot CLI hook config (sessionStart, preToolUse)
claude-settings.json Claude Code hook config (.claude/settings.json: SessionStart, PreToolUse)
scripts/
shadow-frog-check-init.sh Session-start: check .shadow/ exists
shadow-frog-pre-tool.sh Pre-tool: shadow awareness + knowledge capture reminder
examples/
coupon-demo/ Example of what `.shadow/` looks like (3 source files + .shadow/)
cart.py Cart logic (coupon lookup + total calculation)
inventory.py Coupon validation (cross-file case mismatch)
test_cart.py Passing tests for existing coupons
README.md Tour of the .shadow/ for this demo
.shadow/ Agent-discovered knowledge base (init + dream)
eval/ Systematic eval — see eval/README.md
README.md Methodology + results
results_dashboard.html Interactive results dashboard
swesmith/manifests_canonical/ SWE-Smith stacked-bug task manifests
agent-context.md Always-on context for project instructions
install.sh Install skills + hooks into a project repo (bash)
install.ps1 Windows/PowerShell port of install.sh (no python3 dep)
README.md User-facing documentation
claude.md This fileKey Principles
- General-purpose — ShadowFrog works with any codebase, any language. Skills and examples must be language-agnostic. Never assume Python, JS, or any specific stack.
- Discoveries, not descriptions — Shadows contain behavioral insights (edge cases, implicit contracts, non-obvious interactions), NOT code summaries or descriptions. Write "silently returns None on expired tokens" not "handles token expiration".
- Two sources of knowledge — The shadow captures knowledge from autonomous code analysis (
source: exploration) AND from user-agent conversations (source: user,source: interaction). User-shared knowledge is the highest-trust source — capture it immediately, anchored to the exact file and symbol. - Symbol-level granularity — Shadows mirror the codebase at the symbol level, not just file level. Every class, function, and method has a
##section in its shadow file. This enables precise bidirectional lookup: code→shadow and shadow→code. - Bidirectional references are the core mechanism — The entire system rests on robust, accurate references between code and shadow. The canonical format is
file::symbol(e.g.,src/auth.py::UserAuth.validate). Seven invariants must hold (seeshadow-frog/SKILL.md). When editing skills, never break reference integrity. - Trust hierarchy —
source: user(always verified) >source: interaction(always verified) >verifiedexploration >uncertain>refuted. - Cross-cutting is critical —
_cross/discoveries span multiple files and are stored once. Per-file shadows have## Cross-Referencesback-pointers. Always maintain both directions. - No backward compatibility — When refactoring, only keep the latest code. No re-exports, deprecation wrappers, or compatibility shims.
Important Conventions
Discovery Format
Canonical formal spec: /shadow-frog. The shapes below are the minimum an agent needs to write a valid discovery from claude.md alone.
Per-file discovery (anchored by file::symbol heading; labels and Also involves: are optional):
- <behavioral statement>
_(<verified|uncertain|refuted>, source: <exploration|user|interaction>[, labels: [bug, security]], citation_score: 0)_
Also involves: `file::symbol`, `file::symbol`Cross-cutting (_cross/<slug>.md, slug = kebab-case from title, e.g. "DB connection lifecycle" → db-connection-lifecycle.md):
# <Title>
**Category**: <pattern|behavior|edge-case|contract|performance|intent|warning|history|convention>
**Refs**:
- `file::symbol`
**Discovery**: <behavioral statement>
_(<verified|uncertain|refuted>, source: <exploration|user|interaction>, citation_score: 0)_Preference (_prefs.md — project-wide, no file/symbol anchor):
- <preference or convention>
_(source: <user|interaction>, citation_score: 0)_- Labels (lowercase, comma-separated):
bug,performance,security,feature-gap,tech-debt. Only for actionable discoveries. Also involves:always usesfile::symbol, never bare file paths.Dream report: _dreams/<dream-id>/is optional — only for experiment-derived discoveries.
Citation Scores
- Keep one visible nonnegative integer
citation_scorein Markdown metadata, after optional labels. New entries start at 0; omitted scores also mean 0. - Agents read files/symbols directly and explicitly cite consulted entries once
per task. Use core
shadow-cite.pyfor serialized exact-claim increments; no database, opaque IDs, or required retrieval service. - Score updates must not change discovery prose, provenance, references, or counts. Coordinate ordinary edits with citation writes; only helper calls share its lock.
- Keep scores when rewording/moving the same claim, and use max rather than sum when combining duplicates or inherited branch state. Scores are approximate, not a global audited count or a trust/confidence value.
Verification
- Observe-based: read source at
file::symbol, trace logic, confirm claim. - Do-based: write and run a short test/script to confirm or refute.
source: userandsource: interaction→ alwaysverified.
Dedup
- Before writing, read existing discoveries at the target symbol.
- Same claim → update existing. Extends existing → merge. Contradicts → keep both, mark weaker
refuted. - If
_No discoveries yet._placeholder → replace it. If discoveries already exist → append after them.
Shadow File Headings
- Top-level symbols:
##heading with symbol in backticks - Nested symbols:
###heading with symbol in backticks
Examples:
## `authenticate_user`
## `class UserAuth`
### `UserAuth.validate`## Cross-Referencesat the bottom of every per-file shadow
Cross-Cutting Files (_cross/<slug>.md)
- Use
**Refs**:withfile::symbolentries - Category field values: pattern, behavior, edge-case, contract, performance, intent, warning, history, convention
state.json Schema (canonical)
{
"version": 1,
"initialized_at": "<ISO timestamp>",
"last_update_at": "<ISO timestamp>",
"last_commit": "<full 40-char HEAD SHA>",
"last_update_type": "init|auto|manual|dream|meditate",
"total_files": 0,
"total_symbols": 0,
"total_discoveries": 0,
"dream_cycles_completed": 0
}total_discoveries counts per-file discoveries only (excludes _cross/
and _dreams/). Cross-cutting discoveries are tracked separately via
ls .shadow/_cross/*.md | wc -l.
Dream Reports (_dreams/)
Dream experiment reports are archived in _dreams/ for compounding knowledge
across dream sessions. Each experiment gets a folder named YYYYMMDD-HHMMSSZ-slug.
Report frontmatter (YAML):
---
dream_id: "20250417-183012Z-retry-logic"
category: feature design
verdict: useful | dead_end
base_commit: abc1234def5678
branch: "dream/myproject/20250417-183012Z-retry-logic"
parent_branch: "main"
remote: "origin"
related_symbols:
- "src/http.py::HttpClient.send"
builds_on: []
---Note: tip_commit is NOT stored in the report (chicken-and-egg problem).
The reconciler derives it via git rev-parse origin/$BRANCH and records
it in _dreams/_index.md.
_dreams/_index.md— table of all experiments (dream_id, category, verdict, title, branch, parent, tip_commit). Theparentcolumn is a branch name (the parent dream's branch, ormainif rooted at the base branch) — never a dream_id. Both the reconciler (writer) anddream-lineage.py(reader) treat it as a branch name; meditate's index repair resolves to and writes the parent row's branch._dreams/<dream-id>/report.md— structured report with frontmatter (mirrored from dream branch)_dreams/<dream-id>/patch.diff— code-only diff againstbase_commit(excludes.shadow/)_dreams/<dream-id>/manifest.json— machine-readable discovery manifest (on dream branch)- Per-file discoveries cross-reference with
Dream report: _dreams/<dream-id>/ _dreams/is excluded from discovery counts and viewer file listings
SKILL.md Format
Dream/Nap Modes and Proposal Records
broadremains the default.coherentregularizes parent-child connections, not a whole tree's goal. Children have their own goals; diverse siblings may work on the same files. Do not add sibling-similarity or file-disjointness gates.- The canonical
parent_connectionschema is inskills/shadow-frog/SKILL.mdand checked by_coherence.py. Structure is not proof of semantic relevance. - Dream mode must reach planning, child prompts, artifacts, and the pinned
validation command.
dream-tools.pysnapshots current helpers/instructions outside code repositories and verifies hashes before dispatch; never use a historical worktree's installed helpers or manually bypass cleanup checks. - Cleanup retains coherent branches through canonical index parent edges, including repaired/fallback lineage. Unreadable metadata raises an actionable error and the CLI exits nonzero before deleting branches.
- Broad exploration uses its initial snapshot; coherent descendants receive an orchestrator-refreshed parent ref/tip after the parent is pushed. Siblings share that refreshed snapshot, without independent fetches.
- Nap has a version-2 JSON tree with revision, pinned source, limits, nodes,
append-only review receipts, and selected ready tasks. Managed init/add/review/
select operations use locking and atomic writes.
@baseis the virtual code root; proposals do not require Git branches or implemented parent APIs. Its Python helper checks budgets, lineage, source references, and judgments bound to exact semantic inputs; it never calls a model or executes probes. Its expected mode defaults to broad; coherent runs must pass--mode coherent. Depth is uncapped by default (max_depth: null); explicit user depth limits still apply. Node/probe budgets and cycle checks remain mandatory. Probes observe existing behavior, while candidate implementations/prototypes belong in Dream or downstream work. - The host provides a strong independent judge in a fresh context. No self-rating
may impersonate an independent review.
readyrequires a current accepted receipt with no blockers; the helper checks association, not model authenticity or semantic truth. Revisions append children rather than rewrite parents. - Nap exports default to a planning dossier;
--audience implementationis a concise handoff with the same required behavior and preserved commitments. Optional taskconstraintsare binding;design_suggestionsare not.implementation_risksmay remain after planning approval, while blockingopen_questionsmay not. Readiness metadata never claims implemented or runtime-validated behavior. - Use concrete progression questions in selected-path review, not a fixed tree-wide goal or a quota of steps. Atomic tree publication file-syncs data where supported, but does not promise portable power-loss durability.
- Store nap artifacts outside
.shadow/, or in an initialized.shadow/_meta/naps/. Never initialize a partial shadow just to store a nap, increment dream counters for naps, or treat proposals as verified discoveries. - Export final active requirements, not superseded ancestor designs or unrelated siblings. Idea lineage is separate from actual implementation dependencies.
- New helpers must be cross-platform Python: no Bash/Unix-only dependencies, shell-export/eval handoffs, or hard-coded temporary roots. Use native paths, explicit UTF-8, argument-list subprocesses, and the shared cleanup safety gate.
Skill Frontmatter
Each skill has a SKILL.md with YAML frontmatter:
---
name: skill-name
description: >-
One-paragraph description. This is what the agent matches
against to decide when to load the skill.
scripts: # optional — list script filenames in this directory
- my-script.py
---
# Skill Title
Markdown instructions for the agent.The description field is critical — it determines when the agent auto-loads the skill. Make it specific and action-oriented.
The scripts field (optional) lists executable scripts bundled with the skill. Scripts live in the same directory as SKILL.md. With a project install, agents can find them via:
python3 .github/skills/<skill-name>/<script>.py
# or, for Claude Code:
python3 .claude/skills/<skill-name>/<script>.pyHook Format
Two agent platforms, two hook-config shapes, one set of shared scripts:
Copilot CLI — hook-templates/shadow-frog-hooks.json (installed to
.github/hooks/hooks.json):
sessionStart/preToolUseevents; handler usesbash:+timeoutSec- Reads context from the top-level
additionalContextoutput key. ForpreToolUse, support foradditionalContextis undocumented in the 2026 hooks reference but explicitly confirmed in the copilot-cli v1.0.24 changelog. If Copilot ever removes this, thesessionStartreminder remains; only the pre-edit injection silently no-ops.
Claude Code — hook-templates/claude-settings.json (merged into
.claude/settings.json):
SessionStart/PreToolUseevents (PascalCase), matcher-group nesting,command:+timeout, scripts referenced via${CLAUDE_PROJECT_DIR}- Reads context from the nested
hookSpecificOutput.additionalContextkey
Shared script contract (both check-init.sh and pre-tool.sh):
- Receive JSON on stdin; parse both camelCase (Copilot
toolName/toolInput) and snake_case (Claudetool_name/tool_input) field names - Emit JSON carrying BOTH output shapes so one payload drives both agents
- Use
python3 -c "import json,sys; ..."for JSON parsing (not grep/cut) - Keep hooks fast (< 5 second timeout)
Fail-open — the hooks are advisory and MUST always exit 0. Copilot CLI ≥ 1.0.57 denies the tool call when a
preToolUsecommand hook exits non-zero. The scripts therefore use a multi-layer defense (interactive scripts likeinstall.shanddream-setup.pyare the opposite — they fail-fast):- No
set -e/-u/pipefail— failing sub-steps don't abort the script. - Trap pyramid — separate
trap 'exit 0' EXITANDtrap 'exit 0' TERM HUP INT. EXIT alone returns 143/-15 under SIGTERM (empirically verified on bash 3.2 macOS / bash 5+ Linux), which the runner'stimeoutSecenforcement triggers; the TERM trap converts it to 0. - Every external call bounded —
git,python3, and viewer subprocesses MUST run inside Pythonsubprocess.run(timeout=...)wrappers. Bash queues signals while waiting for a foreground child, so the trap pyramid cannot save us from an unbounded hang. Total bounded work budget is ~3.5s, leaving ≥1.5s headroom under the hook's 5stimeoutSec. The previously-unboundedgit rev-parse --show-toplevelin pre-tool.sh was reproduced as a 31s hang in production. state.jsonread inside Python (json.load(open(...))) rather than a shell< redirect, so a missing file is a caught exception instead of an stderr leak.- Static enforcement —
hook-templates/check-hook-failopen.pyblocks changes that re-introduce any of: short/long-form strict-mode flags,source/.of external files, missing EXIT or TERM trap, comment-masquerading-as-trap, or unboundedgitcalls at bash level.
- No
Development
- SKILL.md files ARE the product — edit them directly
- Test by running skills in Copilot CLI / Claude Code
- Hook scripts are bash with python3 for JSON — keep them simple and fast
- Use
install.sh --project <repo>(with--agent copilot|claude) to copy skills, hooks, and context into a project repo - The
examples/coupon-demo/.shadow/must stay consistent with skill docs (same formats, same field names, matching counts) - After any format change, audit ALL files for consistency (skills, examples, hooks, README, claude.md)
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
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.

