{"id":"4f6191c6-e5e6-4230-9be4-c58582e23161","shortId":"cjpVpd","kind":"skill","title":"investigating-repository-history","tagline":"Investigate GitHub repository history before risky code changes using git blame/log, GitHub PRs, review comments, squash/rebase/cherry-pick/rename heuristics, and cited evidence. Use when asking why code exists, whether a change is safe, what PR introduced behavior, or before edi","description":"# Repository History Investigator\n\nUse this skill to reconstruct the historical intent behind code before changing it. The goal is not merely “find the blame commit”; the goal is to return a compact, cited history note explaining relevant PRs, review comments, constraints, rejected approaches, and anomalies.\n\n## Contents\n\n- [Trigger conditions](#trigger-conditions)\n- [Core rule](#core-rule)\n- [Fast path](#fast-path)\n- [Progressive disclosure](#progressive-disclosure)\n- [Investigation workflow](#investigation-workflow)\n- [Evidence confidence rules](#evidence-confidence-rules)\n- [Output template](#output-template)\n- [Gotchas](#gotchas)\n- [Available scripts](#available-scripts)\n\n## Trigger conditions\n\nUse this skill when the user asks any of these:\n\n- “Why is this code written this way?”\n- “Can I remove/simplify/change this check, constraint, branch, migration, public API, or feature flag?”\n- “Which PR introduced this behavior or regression?”\n- “Find the relevant PR/review discussion/history for this code.”\n- Before editing code that touches API compatibility, security, concurrency, persistence, migrations, performance, generated interfaces, feature flags, or unclear legacy/workaround logic.\n\nDo not use this skill for trivial new code with no dependency on existing behavior.\n\n## Core rule\n\nBefore making a risky edit, produce a **history note** answering:\n\n1. What code scope was inspected?\n2. Which commits and PRs are relevant?\n3. Which review comments or PR discussions explain intent?\n4. What constraints, risks, rejected approaches, or tests were found?\n5. Is the evidence strong, weak, contradictory, stale, truncated, or unknown?\n6. How should the implementation plan change?\n\nIf the evidence is weak, say `UNKNOWN` and lower confidence. Never invent intent from a semantic match alone.\n\n## Fast path\n\nFrom the repository working tree, run the collector first. If the skill directory is not the current directory, prefix the script path with the installed skill path and pass `--repo-dir /path/to/repo`.\n\n```bash\npython3 scripts/history_context.py inspect \\\n  --repo-dir /path/to/repo \\\n  --path path/to/file.ext \\\n  --start 120 --end 160 \\\n  --question \"Can I remove this constraint?\" \\\n  --format markdown\n```\n\nFor symbol-level questions without exact lines:\n\n```bash\npython3 scripts/history_context.py inspect \\\n  --repo-dir /path/to/repo \\\n  --path path/to/file.ext \\\n  --symbol SymbolOrFunctionName \\\n  --question \"Why does this behavior exist?\" \\\n  --format markdown\n```\n\nFor JSON suitable for deeper agent reasoning:\n\n```bash\npython3 scripts/history_context.py inspect \\\n  --repo-dir /path/to/repo \\\n  --path path/to/file.ext \\\n  --start 120 --end 160 \\\n  --symbol SymbolOrFunctionName \\\n  --question \"What PR introduced this behavior?\" \\\n  --format json \\\n  --output history-context.json\n```\n\nThen read only the relevant sections of the output. Do not paste huge raw PR/comment dumps into the final answer.\n\n## Progressive disclosure\n\nLoad these files only when needed:\n\n- `references/ANOMALIES.md` — use when exact commit→PR mapping fails, or when squash, rebase, cherry-pick, backport, revert, rename, split, generated files, or mass refactors are possible.\n- `references/GH_CLI.md` — use when the script fails or manual `gh api` calls are needed.\n- `references/DECISION_ATOMS.md` — use when converting PR/comment evidence into constraints, risks, rejected approaches, or test requirements.\n- `references/OUTPUT_SCHEMA.md` — use when producing a formal machine-readable report.\n- `references/EVALUATION.md` — use when testing or improving the skill.\n\n## Investigation workflow\n\n1. **Define scope.** Identify paths, line ranges, symbols, tests, error strings, feature flags, and any proposed diff.\n2. **Collect local history.** Use the script or manual `git blame -w -M -C -C -C`, `git log --follow`, `git log -S`, and `git log -G`.\n3. **Map commits to PRs.** Prefer exact GitHub commit→PR association. Treat it as one signal, not the entire answer.\n4. **Fetch PR evidence.** For candidate PRs, inspect PR body, files, commits, reviews, inline review comments, and issue comments.\n5. **Resolve anomalies.** If mapping is weak, apply the Provenance Mesh: commit association + patch equivalence + content/symbol lineage.\n6. **Extract decision atoms.** Convert evidence into explicit claims: constraints, compatibility requirements, security invariants, performance constraints, rejected approaches, test requirements.\n7. **Assess risk.** Downgrade confidence for semantic-only matches, path-only matches, reverted PRs, API truncation, large PRs, generated files, or missing PRs.\n8. **Produce a history note** before editing code.\n\n## Evidence confidence rules\n\nHigh confidence:\n- exact GitHub commit→PR association; or\n- patch/hunk equivalence plus path/symbol agreement; or\n- review comment remaps to the current hunk/symbol and matches the proposed change.\n\nMedium confidence:\n- same symbol/path plus relevant PR discussion, but no patch-level match.\n\nLow confidence:\n- semantic search only, title/body match only, path-only match, or stale/reverted evidence.\n\nNever claim “this was decided” unless a commit, PR body, review, review comment, issue comment, or linked issue supports it.\n\n## Output template\n\nUse this concise template in the final answer or implementation plan:\n\n```markdown\n## History note\n\nScope inspected: [paths, lines, symbols]\n\nRelevant evidence:\n- PR #[n] — [relation: exact/squash-like/rename-lineage/search], [why relevant], [confidence]\n- Commit [sha] — [what it changed], [relation]\n- Review/comment — [constraint or concern]\n\nDecision atoms:\n- [constraint/risk/rejected approach/test requirement] — [claim] — evidence: [PR/comment/commit]\n\nRisk: [low|medium|high|unknown]\nConfidence: [0.00-1.00]\nUnknowns/truncation: [none or list]\nPlan impact: [proceed|modify plan|ask human|do not change]\n```\n\n## Gotchas\n\n- `git blame` is a seed generator, not truth. Formatting commits, moves, squashes, and refactors can hide origin.\n- A PR can be relevant even if it did not introduce the current line; review comments may explain why an alternative was rejected.\n- Squash merges often require patch/hunk matching because the final commit SHA differs from PR commits.\n- File paths are not identity. Track file lineage, directory moves, symbol fingerprints, and hunk context.\n- Reverted PRs are stale evidence unless a later PR reintroduced the same decision.\n- Large `gh api` responses may be truncated by the underlying GitHub endpoints. If truncation is possible, mark evidence incomplete.\n- General PR conversation comments come from issue comments; inline review comments come from PR review comments.\n\n## Available scripts\n\n- `scripts/history_context.py` — main collector for local Git + GitHub PR evidence. Run `python3 scripts/history_context.py --help`.\n- `scripts/compact_pr.py` — fetch one or more PRs and print compact evidence. Run `python3 scripts/compact_pr.py --help`.\n- `scripts/validate_skill.py` — validate this skill’s frontmatter and basic structure.","tags":["investigating","repository","history","driven","development","codealive-ai","agent-safety","agent-skills","ai-coding","ai-driven-development","ai-safety","antigravity"],"capabilities":["skill","source-codealive-ai","skill-investigating-repository-history","topic-agent-safety","topic-agent-skills","topic-ai-coding","topic-ai-driven-development","topic-ai-safety","topic-antigravity","topic-bash","topic-claude-code","topic-codex-cli","topic-cursor","topic-developer-tools","topic-gemini-cli"],"categories":["ai-driven-development"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/CodeAlive-AI/ai-driven-development/investigating-repository-history","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add CodeAlive-AI/ai-driven-development","source_repo":"https://github.com/CodeAlive-AI/ai-driven-development","install_from":"skills.sh"}},"qualityScore":"0.483","qualityRationale":"deterministic score 0.48 from registry signals: · indexed on github topic:agent-skills · 67 github stars · SKILL.md body (7,020 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:57:06.684Z","embedding":null,"createdAt":"2026-05-08T18:58:13.670Z","updatedAt":"2026-05-18T18:57:06.684Z","lastSeenAt":"2026-05-18T18:57:06.684Z","tsv":"'-1.00':799 '/path/to/repo':329,337,367,394 '0.00':798 '1':227,514 '120':341,398 '160':343,400 '2':233,531 '3':240,557 '4':249,577 '5':259,596 '6':270,613 '7':633 '8':658 'agent':385 'agreement':681 'alon':294 'altern':852 'anomali':87,598 'answer':226,432,576,753 'api':161,185,476,649,900 'appli':603 'approach':85,254,490,630 'approach/test':787 'ask':27,141,809 'assess':634 'associ':567,608,675 'atom':616,785 'avail':128,131,933 'available-script':130 'backport':456 'bash':330,360,387 'basic':969 'behavior':39,169,214,376,408 'behind':54 'blame':66,541,816 'blame/log':15 'bodi':586,733 'branch':158 'c':544,545,546 'call':477 'candid':582 'chang':12,33,57,276,694,778,813 'check':156 'cherri':454 'cherry-pick':453 'cite':23,75 'claim':621,725,789 'code':11,29,55,148,179,182,208,229,665 'collect':532 'collector':304,937 'come':921,928 'comment':19,82,243,592,595,684,736,738,847,920,924,927,932 'commit':67,235,445,559,565,588,607,673,731,774,824,864,869 'compact':74,956 'compat':186,623 'concern':783 'concis':748 'concurr':188 'condit':90,93,134 'confid':115,119,286,637,667,670,696,710,773,797 'constraint':83,157,251,349,487,622,628,781 'constraint/risk/rejected':786 'content':88 'content/symbol':611 'context':884 'contradictori':265 'convers':919 'convert':483,617 'core':94,97,215 'core-rul':96 'current':313,688,844 'decid':728 'decis':615,784,897 'deeper':384 'defin':515 'depend':211 'diff':530 'differ':866 'dir':328,336,366,393 'directori':309,314,878 'disclosur':105,108,434 'discuss':246,702 'discussion/history':176 'downgrad':636 'dump':428 'edi':42 'edit':181,221,664 'end':342,399 'endpoint':909 'entir':575 'equival':610,678 'error':523 'even':837 'evid':24,114,118,262,279,485,580,618,666,723,766,790,889,915,943,957 'evidence-confidence-rul':117 'exact':358,444,563,671 'exact/squash-like/rename-lineage/search':770 'exist':30,213,377 'explain':78,247,849 'explicit':620 'extract':614 'fail':448,472 'fast':99,102,295 'fast-path':101 'featur':163,194,525 'fetch':578,949 'file':437,461,587,654,870,876 'final':431,752,863 'find':64,172 'fingerprint':881 'first':305 'flag':164,195,526 'follow':549 'formal':499 'format':350,378,409,823 'found':258 'frontmatt':967 'g':556 'general':917 'generat':192,460,653,820 'gh':475,899 'git':14,540,547,550,554,815,940 'github':6,16,564,672,908,941 'goal':60,69 'gotcha':126,127,814 'help':947,961 'heurist':21 'hide':830 'high':669,795 'histor':52 'histori':4,8,44,76,224,534,661,758 'history-context.json':412 'huge':425 'human':810 'hunk':883 'hunk/symbol':689 'ident':874 'identifi':517 'impact':805 'implement':274,755 'improv':509 'incomplet':916 'inlin':590,925 'inspect':232,333,363,390,584,761 'instal':321 'intent':53,248,289 'interfac':193 'introduc':38,167,406,842 'invari':626 'invent':288 'investig':2,5,45,109,112,512 'investigating-repository-histori':1 'investigation-workflow':111 'issu':594,737,741,923 'json':381,410 'larg':651,898 'later':892 'legacy/workaround':198 'level':355,707 'line':359,519,763,845 'lineag':612,877 'link':740 'list':803 'load':435 'local':533,939 'log':548,551,555 'logic':199 'low':709,793 'lower':285 'm':543 'machin':501 'machine-read':500 'main':936 'make':218 'manual':474,539 'map':447,558,600 'mark':914 'markdown':351,379,757 'mass':463 'match':293,642,646,691,708,715,720,860 'may':848,902 'medium':695,794 'mere':63 'merg':856 'mesh':606 'migrat':159,190 'miss':656 'modifi':807 'move':825,879 'n':768 'need':440,479 'never':287,724 'new':207 'none':801 'note':77,225,662,759 'often':857 'one':571,950 'origin':831 'output':121,124,411,421,744 'output-templ':123 'pass':325 'past':424 'patch':609,706 'patch-level':705 'patch/hunk':677,859 'path':100,103,296,318,323,338,368,395,518,644,718,762,871 'path-on':643,717 'path/symbol':680 'path/to/file.ext':339,369,396 'perform':191,627 'persist':189 'pick':455 'plan':275,756,804,808 'plus':679,699 'possibl':466,913 'pr':37,166,245,405,446,566,579,585,674,701,732,767,833,868,893,918,930,942 'pr/comment':427,484 'pr/comment/commit':791 'pr/review':175 'prefer':562 'prefix':315 'print':955 'proceed':806 'produc':222,497,659 'progress':104,107,433 'progressive-disclosur':106 'propos':529,693 'proven':605 'prs':17,80,237,561,583,648,652,657,886,953 'public':160 'python3':331,361,388,945,959 'question':344,356,372,403 'rang':520 'raw':426 'read':414 'readabl':502 'reason':386 'rebas':452 'reconstruct':50 'refactor':464,828 'references/anomalies.md':441 'references/decision_atoms.md':480 'references/evaluation.md':504 'references/gh_cli.md':467 'references/output_schema.md':494 'regress':171 'reintroduc':894 'reject':84,253,489,629,854 'relat':769,779 'relev':79,174,239,417,700,765,772,836 'remap':685 'remov':347 'remove/simplify/change':154 'renam':458 'repo':327,335,365,392 'repo-dir':326,334,364,391 'report':503 'repositori':3,7,43,299 'requir':493,624,632,788,858 'resolv':597 'respons':901 'return':72 'revert':457,647,885 'review':18,81,242,589,591,683,734,735,846,926,931 'review/comment':780 'risk':252,488,635,792 'riski':10,220 'rule':95,98,116,120,216,668 'run':302,944,958 'safe':35 'say':282 'scope':230,516,760 'script':129,132,317,471,537,934 'scripts/compact_pr.py':948,960 'scripts/history_context.py':332,362,389,935,946 'scripts/validate_skill.py':962 'search':712 'section':418 'secur':187,625 'seed':819 'semant':292,640,711 'semantic-on':639 'sha':775,865 'signal':572 'skill':48,137,204,308,322,511,965 'skill-investigating-repository-history' 'source-codealive-ai' 'split':459 'squash':451,826,855 'squash/rebase/cherry-pick/rename':20 'stale':266,888 'stale/reverted':722 'start':340,397 'string':524 'strong':263 'structur':970 'suitabl':382 'support':742 'symbol':354,370,401,521,764,880 'symbol-level':353 'symbol/path':698 'symbolorfunctionnam':371,402 'templat':122,125,745,749 'test':256,492,507,522,631 'title/body':714 'topic-agent-safety' 'topic-agent-skills' 'topic-ai-coding' 'topic-ai-driven-development' 'topic-ai-safety' 'topic-antigravity' 'topic-bash' 'topic-claude-code' 'topic-codex-cli' 'topic-cursor' 'topic-developer-tools' 'topic-gemini-cli' 'touch':184 'track':875 'treat':568 'tree':301 'trigger':89,92,133 'trigger-condit':91 'trivial':206 'truncat':267,650,904,911 'truth':822 'unclear':197 'under':907 'unknown':269,283,796 'unknowns/truncation':800 'unless':729,890 'use':13,25,46,135,202,442,468,481,495,505,535,746 'user':140 'valid':963 'w':542 'way':151 'weak':264,281,602 'whether':31 'without':357 'work':300 'workflow':110,113,513 'written':149","prices":[{"id":"8cb4e20a-fd12-4b81-a64f-d4abf496edc6","listingId":"4f6191c6-e5e6-4230-9be4-c58582e23161","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"CodeAlive-AI","category":"ai-driven-development","install_from":"skills.sh"},"createdAt":"2026-05-08T18:58:13.670Z"}],"sources":[{"listingId":"4f6191c6-e5e6-4230-9be4-c58582e23161","source":"github","sourceId":"CodeAlive-AI/ai-driven-development/investigating-repository-history","sourceUrl":"https://github.com/CodeAlive-AI/ai-driven-development/tree/main/skills/investigating-repository-history","isPrimary":false,"firstSeenAt":"2026-05-08T18:58:13.670Z","lastSeenAt":"2026-05-18T18:57:06.684Z"}],"details":{"listingId":"4f6191c6-e5e6-4230-9be4-c58582e23161","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"CodeAlive-AI","slug":"investigating-repository-history","github":{"repo":"CodeAlive-AI/ai-driven-development","stars":67,"topics":["agent-safety","agent-skills","ai-coding","ai-driven-development","ai-safety","antigravity","bash","claude-code","codex-cli","cursor","developer-tools","gemini-cli","hooks","mcp","multi-agent","opencode","plugins","prompt-engineering","skills","subagents"],"license":"mit","html_url":"https://github.com/CodeAlive-AI/ai-driven-development","pushed_at":"2026-05-12T20:04:46Z","description":"Practices, protocols, and skills for AI-driven software development. 18 skills + 1 Bash safety hook for Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, Antigravity, and any agent supporting the Agent Skills standard.","skill_md_sha":"4fec75be88fe5c744cade6f4f1fa7a5d409a1cb8","skill_md_path":"skills/investigating-repository-history/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/CodeAlive-AI/ai-driven-development/tree/main/skills/investigating-repository-history"},"layout":"multi","source":"github","category":"ai-driven-development","frontmatter":{"name":"investigating-repository-history","license":"MIT","description":"Investigate GitHub repository history before risky code changes using git blame/log, GitHub PRs, review comments, squash/rebase/cherry-pick/rename heuristics, and cited evidence. Use when asking why code exists, whether a change is safe, what PR introduced behavior, or before editing API, compatibility, security, concurrency, persistence, migration, or performance-sensitive code.","compatibility":"Designed for Claude Code, Codex, and similar coding agents. Requires a local git clone; bundled scripts require Python 3.9+, git, and authenticated GitHub CLI `gh` for GitHub PR evidence."},"skills_sh_url":"https://skills.sh/CodeAlive-AI/ai-driven-development/investigating-repository-history"},"updatedAt":"2026-05-18T18:57:06.684Z"}}