بنقرة واحدة
index-repo-docs
Fetch and distill a repo's wiki, docs, and issues into a focused reference doc
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Fetch and distill a repo's wiki, docs, and issues into a focused reference doc
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Absorb staged changes into the correct commits in the current stack
Restructure a range of commits into a clean, atomic stack ordered by concern
Break a large commit into a reviewable stack of small atomic commits
Sync stack with main, run tests, and submit all branches to remote
Run tests or formatters across all commits in a stack
| name | index-repo-docs |
| description | Fetch and distill a repo's wiki, docs, and issues into a focused reference doc |
| 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 the global claude config references directory.
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: home/<user>/features/cli/code/ai/claude/claude-config/references/<name>.md
Where <user> is determined from the repo path (check git config user.name
or the directory structure). <name> is the short name 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>
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, 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-fetchissues-indexed:
gh api "repos/${owner}/${repo}/issues?sort=reactions-+1&state=all&per_page=1&since=${issues_indexed}T00:00:00Z" \
--jq 'length'
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)
git clone --depth 1 "https://github.com/${owner}/${repo}.wiki.git" "$tmp_dir/wiki" 2>/dev/null || true
Fetch the README and docs:
gh api "repos/${owner}/${repo}/readme" --jq '.content' | base64 -d > "$tmp_dir/README.md"
# Also check for docs/ directory
gh api "repos/${owner}/${repo}/contents/docs" --jq '.[].name' 2>/dev/null | while read f; do
gh api "repos/${owner}/${repo}/contents/docs/$f" --jq '.content' | base64 -d > "$tmp_dir/docs-$f"
done
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.
total_issues=$(gh api "repos/${owner}/${repo}" --jq '.open_issues_count')
total_closed=$(gh api "repos/${owner}/${repo}/issues?state=closed&per_page=1" \
--jq '.[0].number // 0')
For each label in the cached value-labels list, fetch all matching issues:
# Paginate to get all issues with this label
gh api "repos/${owner}/${repo}/issues?labels=${label_name}&state=all&per_page=100${since_param}" \
--paginate --jq '.[] | "## 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[]' >> "$tmp_dir/keyword-discussions.json" 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 api "repos/${owner}/${repo}/issues?sort=reactions-+1&state=all&per_page=100${since_param}" \
--paginate --jq '.[] | {number, title, body, 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 everything between <!-- BEGIN LOCAL NOTES --> and
<!-- END LOCAL NOTES --> (inclusive of the markers). Store it verbatim —
this block 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>
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/<name>-index/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 --> markers during
regeneration. Extract before rewriting, splice back verbatim.### <short title> with the problem, solution, and context.