一键导入
index-repo-docs
Use when you need to create or update a reference doc from a repo's wiki, docs, and issues. Fetches and distills into a focused reference.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when you need to create or update a reference doc from a repo's wiki, docs, and issues. Fetches and distills into a focused reference.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when you need a multi-perspective review of this repo. Spawns 6 specialized reviewers (git expert, agentic UX, human UX, nix expert, FP/DRY expert, consistency auditor). Aggregates findings, deduplicates, respects recorded decisions, and proposes changes with human approval.
Use when you need to fix, correct, or update content in an earlier commit. Absorbs staged changes into correct stack commits INSTEAD of running git absorb or git commit --fixup via Bash. Prevents: missed dry-run preview, leftover staged changes going unnoticed, forgetting to restack. Falls back to guided manual amend when absorb cannot route hunks.
Use when you need to plan commits, restructure a stack, or commit uncommitted work as organized atomic commits. Builds a stack from a description, uncommitted work, or existing commits INSTEAD of manual git rebase -i, git reset --soft, or ad-hoc git move sequences. Prevents: wrong commit ordering, forward references, git move -F panics, untested intermediates.
Use when you need to break up, split, or decompose a large commit into smaller atomic commits. Use INSTEAD of manual git rebase -i + edit or git reset HEAD^. Prevents: non-working intermediate commits, wrong split ordering, missed downstream restack.
Use when you need to push, submit, or create pull requests for a commit stack. Syncs, validates, and pushes INSTEAD of manual git sync + git submit + PR/MR creation. Handles branch creation, stacked PR/MR creation with correct base branches, and sentinel commit exclusion.
Use when you need to audit, analyze, or review stack quality before restructuring. Produces a structured summary with per-commit classification, philosophy audit, and violation flags. Output feeds directly into /stack-plan restructure mode. Use INSTEAD of manual git log inspection.
| name | index-repo-docs |
| description | Use when you need to create or update a reference doc from a repo's wiki, docs, and issues. Fetches and distills into a focused reference. |
| argument-hint | <name-or-url|all> (e.g. git-branchless, git-absorb, all) |
| disable-model-invocation | true |
Fetch documentation from a repository and distill it into a practical reference
doc with concrete recipes and patterns. The output goes to references/ in the
repo root.
Use this lookup table to resolve short names to repos. If $ARGUMENTS doesn't
match a known name, treat it as a GitHub URL or owner/repo.
| Name | Repo | Focus |
|---|---|---|
git-branchless | arxanas/git-branchless | Wiki, README, key issues on workflows |
git-absorb | tummychow/git-absorb | README, man page, usage patterns |
git-revise | mystor/git-revise | README, docs, interactive usage |
If $ARGUMENTS is all or empty (no arguments), iterate through every entry
in the table above and run the full indexing process for each one, skipping
repos that are up to date.
Write to: references/<name>.md in the repo root.
<name> is the short name from the lookup table or the repo name from the URL.
The generated reference doc includes frontmatter with per-source indexing metadata. Each source tracks its own date so partial re-indexing is possible and so it's clear which sources have actually been fetched:
---
repo: owner/repo
repo-head: <commit-sha>
repo-indexed: 2026-03-21
wiki-head: <commit-sha or null>
wiki-indexed: 2026-03-21
issues-indexed: 2026-03-21 # null if never fetched
discussions-indexed: 2026-03-21 # null if repo has no Discussions or never fetched
labels-indexed: 2026-03-21
label-head: <sha256 of sorted label name list>
doc-sources: # discovered doc files and external links
- path: "Documentation/git-absorb.adoc"
type: repo-file
relevance: "man page with authoritative flag/option reference"
- path: "docs/ARCHITECTURE.md"
type: repo-file
relevance: "internal design docs for understanding behavior"
- url: "https://git-branchless.readthedocs.io/"
type: external
relevance: "official hosted documentation site"
reachable: true
exclude-issue-patterns:
- "renovate"
- "dependabot"
- "bump version"
value-labels:
- name: "answered"
reason: "confirmed solutions from maintainers"
- name: "has workaround"
reason: "practical alternatives users can follow"
---
A null date means that source has never been properly indexed — treat it
as needing a full fetch regardless of other source states.
On re-run:
repo_head=$(gh api "repos/${owner}/${repo}/commits?per_page=1" --jq '.[0].sha')
wiki_head=$(git ls-remote "https://github.com/${owner}/${repo}.wiki.git" HEAD 2>/dev/null | cut -f1 || echo "")
label-head against frontmatter to detect label changes.repo-head changed → re-fetch README/docs, re-discover doc tree, full regenerationwiki-head changed → re-fetch wiki, full regenerationissues-indexed is null or new issues exist since that date → fetch issuesdiscussions-indexed is null or new discussions since that date → fetch discussionslabel-head changed → re-assess labels, may trigger issue re-fetchdoc-sources entries with reachable: false → re-check, prune if stale 3+ runsdoc-sources external URLs → spot-check reachability on full regenerationissues-indexed:
gh api "search/issues?q=repo:${owner}/${repo}+type:issue+updated:>=${issues_indexed}T00:00:00Z&per_page=1" \
--jq '.total_count'
discussions-indexedrepo-head or wiki-head
changed (the prose/structure source material changed). When only
issues-indexed or discussions-indexed is stale, the existing doc text
is the baseline — add new gotchas, recipes, and anti-patterns from issues
without rewriting or condensing existing sections. Never drop existing
content to make room; the 500-line limit applies to the final result, so
if the doc is already near the limit, integrate only the highest-value
issue insights.The exclude-issue-patterns list in frontmatter filters out noise from
issues/discussions. On the first run, initialize it with common bot patterns:
renovate, dependabot, bump version, release v.
During indexing, if an issue title matches any pattern (case-insensitive),
skip it. If you encounter a new category of noise issues during distillation,
add the pattern to exclude-issue-patterns for future runs.
Every repo has different labels. Instead of hardcoding which labels matter, discover and assess them dynamically.
Fetch all labels (runs every time, even on incremental updates):
gh api "repos/${owner}/${repo}/labels" --paginate \
--jq '.[] | "\(.name)\t\(.description // "")\t\(.color)"'
Compute label-head — a hash of sorted label names to detect changes:
label_head=$(gh api "repos/${owner}/${repo}/labels" --paginate \
--jq '[.[].name] | sort | join("\n")' | sha256sum | cut -d' ' -f1)
Assess which labels have value by classifying each into one of:
Do NOT hardcode label names. Read the actual label names and descriptions,
then use judgment to classify them. Every repo is different — git-branchless
has "has workaround" and "answered", another repo might have "solved" or
"recipe".
Cache the assessment in the value-labels frontmatter field. Each entry
records the label name and a short reason why it's valuable. On subsequent
runs, if label-head hasn't changed, reuse the cached assessment. If labels
changed, re-assess and update the cache.
Resolve the repo from $ARGUMENTS using the lookup table above, or
parse as owner/repo or full URL.
Check for incremental update as described above. If up to date, skip.
Fetch the wiki (if it exists):
tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/claude-repo-index.XXXXXX")
git clone --depth 1 "https://github.com/${owner}/${repo}.wiki.git" "$tmp_dir/wiki" 2>/dev/null || true
Discover and fetch documentation:
Documentation lives in different places across repos. Use a multi-pass
discovery approach and track what was found in doc-sources frontmatter.
gh api "repos/${owner}/${repo}/readme" --jq '.content | @base64d' > "$tmp_dir/README.md"
Fetch the repo tree and filter for documentation files. Don't hardcode directory names — search broadly: First, get the default branch:
default_branch=$(gh api "repos/${owner}/${repo}" --jq '.default_branch')
gh api "repos/${owner}/${repo}/git/trees/${default_branch}?recursive=1" \
--jq '.tree[] | select(.type=="blob") | .path' \
| grep -iE '\.(md|adoc|rst|txt)$' \
| grep -iE '^(docs?/|documentation/|man/|guide|readme|contributing|changelog|faq|usage|tutorial)' \
> "$tmp_dir/doc-paths.txt"
Also catch top-level doc files that aren't README:
gh api "repos/${owner}/${repo}/git/trees/${default_branch}?recursive=1" \
--jq '.tree[] | select(.type=="blob") | .path' \
| grep -iE '^[^/]*\.(adoc|rst)$' \
>> "$tmp_dir/doc-paths.txt"
Fetch each discovered file:
while read -r doc_path; do
encoded=$(printf '%s' "$doc_path" | jq -sRr @uri)
gh api "repos/${owner}/${repo}/contents/${encoded}" --jq '.content | @base64d' \
> "$tmp_dir/repo-$(echo "$doc_path" | tr '/' '-')" 2>/dev/null || true
done < "$tmp_dir/doc-paths.txt"
Scan the README and any fetched docs for links to external documentation sites (readthedocs, GitHub Pages, gitbook, wiki URLs, etc.):
grep -ohE 'https?://[^ )">]+' "$tmp_dir"/*.md "$tmp_dir"/*.adoc 2>/dev/null \
| grep -iE '(readthedocs|gitbook|github\.io|wiki|docs\.)' \
| sort -u > "$tmp_dir/external-links.txt"
For each external link, fetch the page content if it's reachable and
appears to be documentation (HTML or markdown). Use WebFetch for
HTML pages. Record each in doc-sources with type: external.
If the existing frontmatter has doc-sources, compare:
reachable: false, keep
the entry but note it's gone (the content may still be relevant if
the file was moved or renamed)reachable: false for 3+ consecutive runsThe doc-sources list persists across runs as the "memory" of what
documentation exists for this repo. Each entry includes a relevance
note explaining why it matters — this helps future runs prioritize.
Discover and fetch issues/discussions using multiple search signals.
The goal is a thorough sample of usage-relevant content — not just the top 10. Fetch greedily, deduplicate, and only prompt the user if volume is unmanageable.
Use the search API to get accurate issue counts (the REST issues endpoint
and open_issues_count both include pull requests):
total_open=$(gh api "search/issues?q=repo:${owner}/${repo}+type:issue+state:open&per_page=1" \
--jq '.total_count')
total_closed=$(gh api "search/issues?q=repo:${owner}/${repo}+type:issue+state:closed&per_page=1" \
--jq '.total_count')
total_issues=$((total_open + total_closed))
For each label in the cached value-labels list, fetch all matching issues:
# Paginate to get all issues with this label, filtering out PRs
encoded_label=$(printf '%s' "$label_name" | jq -sRr @uri)
gh api "repos/${owner}/${repo}/issues?labels=${encoded_label}&state=all&per_page=100${since_param}" \
--paginate --jq '.[] | select(has("pull_request") | not) | "## Issue #\(.number): \(.title)\n\(.body)\n"'
Search issues/discussions for usage-pattern keywords. These surface "how do I...?" and "can I...?" questions that reveal practical workflows:
Important: gh search issues returns a JSON array per call. Pipe each
call through jq individually to emit JSONL — do NOT append raw arrays
with >> (creates invalid JSON when concatenated).
keywords=("how" "can I" "workflow" "workaround" "example" "recipe" "pattern")
for kw in "${keywords[@]}"; do
gh search issues "${kw}" --repo "${owner}/${repo}" --sort reactions \
--json number,title,body,labels,reactions --limit 50 2>/dev/null \
| jq -c '.[] | {number, title, body: (.body // "" | .[0:2000]), labels: [.labels[].name]}' \
>> "$tmp_dir/keyword-issues.jsonl" 2>/dev/null || true
done
For repos with Discussions enabled, also search discussions:
for kw in "${keywords[@]}"; do
gh api graphql -f query='
query {
search(query: "repo:'"${owner}/${repo}"' \"'"${kw}"'\" is:discussion",
type: DISCUSSION, first: 50) {
nodes {
... on Discussion {
number title body url
answer { body }
labels(first:10) { nodes { name } }
}
}
}
}' --jq '.data.search.nodes[] | @json' >> "$tmp_dir/keyword-discussions.jsonl" 2>/dev/null || true
done
Also fetch top most-reacted issues as a catch-all for popular content that keyword and label searches might miss:
gh search issues --repo "${owner}/${repo}" --sort reactions --order desc --state all \
--limit 100 --json number,title,body,labels,reactions \
--jq '.[] | {number, title, body: (.body // "" | .[0:2000]), labels: [.labels[].name], reactions: .reactions.total_count}'
Merge all fetched issues/discussions by number. Remove duplicates. Apply
exclude-issue-patterns to titles (case-insensitive). The final set is what
gets distilled into the reference doc.
For each issue/discussion, capture: number, title, body, labels, and reaction count. Issues with answers (from Discussions) or resolution comments from maintainers are especially valuable — note the resolution.
Extract Local Notes from the existing reference doc (if it exists).
Parse all lines from the one that starts with <!-- BEGIN LOCAL NOTES through
the one that starts with <!-- END LOCAL NOTES (inclusive of those full marker
lines, which may include trailing text and the closing -->). Store this block
verbatim — it must be spliced back into the regenerated doc unchanged.
Read all fetched content and distill into a reference doc with this structure:
---
repo: owner/repo
repo-head: <sha>
repo-indexed: <date>
wiki-head: <sha or null>
wiki-indexed: <date or null>
issues-indexed: <date or null>
discussions-indexed: <date or null>
labels-indexed: <date>
label-head: <sha256 of sorted label names>
doc-sources:
- path: "<relative path in repo>"
type: repo-file
relevance: "<why this file matters>"
- url: "<external URL>"
type: external
relevance: "<why this link matters>"
reachable: true
exclude-issue-patterns:
- "renovate"
- "dependabot"
- "bump version"
- "release v"
value-labels:
- name: "<label>"
reason: "<why this label surfaces useful content>"
issue-stats:
total-fetched: <n>
from-labels: <n>
from-keywords: <n>
from-reactions: <n>
after-dedup: <n>
---
# <Tool Name> Reference
Distilled from <repo URL>, updated <date>.
## Overview
<1-2 paragraph summary of what the tool does and why>
## Installation & Setup
<How to install, configure, prerequisites>
## Core Concepts
<Key mental models needed to use the tool effectively>
## Command Reference
<Commands with practical examples, grouped by workflow>
## Recipes
<Concrete step-by-step patterns for common tasks, written as numbered
procedures. These should be copy-pasteable workflows, not abstract
descriptions. Focus on:
- The happy path for each common operation
- How to recover from mistakes
- Integration with other tools (git-branchless + git-absorb, etc.)>
## Anti-Patterns
<Common mistakes and what to do instead>
## Integration
<How this tool works with the other stacked workflow tools>
<!-- BEGIN LOCAL NOTES — preserved across regeneration -->
## Local Notes
Hard-won lessons, workarounds, and patterns discovered through actual usage.
This section is never overwritten by index-repo-docs. Add entries here when
you solve a pain point or discover undocumented behavior.
<!-- END LOCAL NOTES -->
Write the draft to a temp file — never directly to the reference doc.
# e.g. ${tmp_dir}/draft.md
Present a change summary for user review. Do NOT write the final doc until the user approves. Show, in this order:
#NNN) count old vs newIf there are removals, explain why each one was dropped. The user may reject the draft or ask for revisions. Only proceed to step 10 after explicit approval.
Write the approved doc to the reference file path.
Clean up:
rm -rf "$tmp_dir"
Report what was generated (full/incremental/skipped), how many source files were read, and the output path.
exclude-issue-patterns across runs — never shrink itvalue-labels across runs — only remove a label if it
no longer exists in the repoissue-stats in frontmatter help the user understand coverage on future
runs — always keep them accurate<!-- BEGIN LOCAL NOTES and <!-- END LOCAL NOTES
during regeneration. Extract before rewriting, then splice the original block back
verbatim.### <short title> with the problem, solution, and context.