name: "repo-state-diagnosis"
description: "Use to classify the current Git repository state and route to the correct Git skill before action."
maturity-level: "L3"
risk-scope: "R0-R1"
version: "1.0.0"
Repo State Diagnosis
Core Question
What is the current repository state, and which skill should own the next safe action?
When To Use
Use this skill when:
- the user asks what state the repo or branch is in
- another skill needs read-only orientation before mutation
- the repository may be dirty, conflicted, detached, diverged, missing upstream, or in an operation state
- the correct Git skill is unclear
When Not To Use
Do not use this skill when:
- executing branch sync, commit, recovery, or conflict resolution
- creating commits or tags
- running destructive cleanup
- publishing or pushing remote refs
Route to:
- commit planning routes to
atomic-commits - message-only work routes to
conventional-commits - branch update or upstream work routes to
sync-branch or branch-workflow - conflicts route to
resolve-conflicts - abort/recovery routes to
undo-recover
Required Evidence
Before action, inspect or establish:
git status --short --branch- current branch and HEAD mode
- staged, unstaged, and untracked path groups
- upstream, ahead, and behind state
- operation state markers for merge, rebase, cherry-pick, and revert
- recent log or graph only when needed for state explanation
No-evidence rule:
- Do not make strong claims without observed evidence.
- State assumptions when proceeding under incomplete evidence.
- Stop when missing evidence affects safety, correctness, user work, remote state, or irreversible action.
Operating Contract
You MAY:
- inspect relevant repository state and project files.
- generate a plan, report, or local artifact within the declared risk scope.
- route to another skill when the requested action is outside this skill's owner boundary.
You MUST:
- inspect before acting.
- keep the task within the declared owner boundary.
- classify state and risk before any meaningful action.
- preserve unrelated user work.
- verify outcomes proportional to risk.
- report evidence, assumptions, actions, verification, and residual risk.
You MUST NOT:
- invent project policy.
- expose secrets or sensitive values.
- mutate unrelated files or refs.
- perform destructive, remote, shared, history-rewriting, or irreversible actions without explicit action-specific confirmation.
- continue after unexpected destructive output.
State / Risk Table
| State | Evidence | Risk | Default Action | Confirmation | Verification |
|---|
| Clean repository | status shows no local changes | R0 | Report clean state and safe routes | no | state summary |
| Staged changes present | cached diff or staged names | R0/R1 | Report staged boundary and route commit tasks to atomic-commits | no | staged list summarized |
| Dirty unstaged or untracked work | status path groups | R0/R1 | Report excluded work and route by requested action | no | path groups summarized |
| Operation in progress | merge/rebase/cherry-pick/revert markers | R0/R1 | Route to resolve-conflicts or undo-recover | no | operation state named |
| Diverged or missing upstream | branch upstream evidence | R0/R1 | Route to sync-branch or branch-workflow | no | ahead/behind or upstream state |
Workflow
- Identify the user goal and current owner boundary.
- Inspect required evidence.
- Classify repository/task state.
- Classify risk using the declared scope.
- Choose the minimal sufficient action or route.
- Execute only allowed actions, if any.
- Verify outcome or self-check the artifact.
- Report result, evidence, verification, assumptions, and residual risk.
Decision Rules
- Classify current state before interpreting broad user wording.
- Prefer current-state ownership over intent wording when the repository is in a special state.
- Do not infer permission to mutate from a diagnosis request.
- Report unknown evidence instead of guessing branch/upstream policy.
- May run read-only Git inspection commands.
- Must not run commands that change refs, index, working tree, stashes, or remotes.
- Must not fetch unless the user explicitly asks for remote freshness; route remote refresh to
sync-branch.
Verification
Minimum verification:
- Compare reported state against status, branch/upstream, and operation markers.
- Verify route recommendation names an existing skill.
- State any evidence not inspected.
Risk-based floor:
- R0-R1: evidence inspected and output self-checked.
- R2: inspect resulting diff or local state.
- R3: verify local state and report recovery limits.
- R4-R5: require explicit confirmation, preflight evidence, and post-action verification where this skill owns the action.
Output Contract
Final response must include:
## Result
- Decision, action, or artifact produced.
## Evidence
- Files, commands, diffs, refs, or assumptions used.
## Verification
- Checks performed and their result.
## Risks / Limitations
- Remaining uncertainty, blocked actions, or routed next steps.
Stop / Confirmation Rules
Stop when the repository state is dirty, conflicted, diverged, missing required evidence, or ambiguous in a way that could overwrite user work, invalidate the requested scope, or require a gated action.
Require explicit action-specific confirmation for:
- destructive local mutation.
- remote/shared mutation.
- history rewriting.
- security/secret/data impact.
- irreversible or hard-to-recover operation.
Broad approval such as "do whatever" is not enough for R4-R5 actions.
Lazy-load References
Load references/state-catalog.md when:
- the task needs the detailed guidance described by the file name.
- the state/risk table identifies an ambiguous or high-risk path.
Load references/routing-map.md when:
- the task needs the detailed guidance described by the file name.
- the state/risk table identifies an ambiguous or high-risk path.
Load references/graph-explain.md when:
- the task needs the detailed guidance described by the file name.
- the state/risk table identifies an ambiguous or high-risk path.