Assess PR and Issues
The end-of-run half of /assess. The report (.assess/assess-report.md), the complexity heatmap, and the doc graph are written. This step runs the optional end-of-run offers - in order - then closes the loop:
Windows: run the bash blocks below in Git Bash, which ships with Git for Windows. Installs, PATH notes and the make-free commands are in the Windows setup guide.
- Open a PR with the report (Step 5).
- Track the Top 3 Actions in the user's issue tracker (Step 6).
- Freeze the assessment into a CI gate (Step 6.5).
- Tool feedback (Step 7) - surface anomalies and offer to file feedback.
- Uninstall
/assess(Step 8) - the escape hatch: remove everything this run wrote.
Each offer is independent (uninstall excepted - it's mutually exclusive with the write-back offers): a user can accept any subset. The step references back into the written assess-report.md artifact (notably the Top 3 Actions table's Issue column), not into the scoring prose, so it stays decoupled from how the report was produced.
Phase 2: ask once, batched (and the non-interactive contract)
These are the write-back phase of the consent lifecycle (Phase 2; Phase 1 was the tool installs, Phase 3 the mutation pass - see the assess SKILL.md). Do not serialise them into back-to-back modals. Present them as one batched, multi-select AskUserQuestion: "Now that the report is written, which of these should I do?" with the options (open a PR, track the Top 3 Actions, freeze a CI gate, file feedback, and - the mutually-exclusive escape hatch - uninstall /assess from this repo), pre-filtered by feasibility:
- Drop the PR option when the push-capability / remote check below (Step 5) shows no direct or fork PR is possible. On a read-only target (READ / TRIAGE) that takes contributions and has issues enabled, lead with the upstream-issues variant instead (it replaces the generic issue-tracking option below, so the batch lists it once and records it under
issue_tracking): file the Top 3 Actions as issues upstream, each linking the full report hosted in the user's fork (Step 5's upstream-issues flow, then Step 6). Offer the fork snapshot PR against upstream only as a separate, explicit secondary option, noting that maintainers often decline committed generated output. When the target states it takes no contributions (Step 5's no-contributions scan), offer the no-contributions variant instead on a read-only target (READ / TRIAGE) or in a clone of the user's own fork: a PR inside the user's fork, never one against upstream. A user who can push to the non-fork repo itself keeps the direct PR option, with the statement quoted. - Drop the CI gate option when the workflow could never run (no GitHub remote).
- Keep issue tracking and feedback always (feedback needs no repo write). On a read-only target that takes contributions, issue tracking appears as the upstream-issues option above.
- Uninstall (Step 8) always appears: it removes what this run wrote. It doesn't compose with the write-back offers (no point opening a PR and deleting the report), so treat selecting it as "skip the others and clean up".
Then execute the accepted offers in order (PR → issues → gate → feedback), because the later ones cross-link to the PR the first may have opened. Uninstall, if chosen, runs instead of the others. The per-step detail below is the execution recipe for each accepted offer; the asking happens once, here.
Non-interactive contract (headless / CI). When run-context.json .interactive is false, make no AskUserQuestion call at all - every write-back offer is already recorded as {type, status: "skipped", reason: "non-interactive"} in run-context.json .offers (pr, issue_tracking, ci_gate, feedback, uninstall). Write nothing back, open no PR, create no issues, emit no gate, file no feedback, uninstall nothing; the run ends with the local .assess/ artifacts only. A headless /assess completes with zero prompts.
jq '{interactive, offers}' "$REPO_ROOT/.assess/run-context.json"
Step 5: Ask Whether to Open a PR
After writing the files, first check whether a direct PR is even possible before offering one. A user on READ or TRIAGE access can't push a branch to the target repo, so an unconditional "open a PR?" offer is infeasible and wastes a turn.
# Detect push capability. `gh` returns viewer fields for the current user.
# Push capability is derived from `viewerPermission` (one of ADMIN |
# MAINTAIN | WRITE | TRIAGE | READ | NONE) - GitHub's GraphQL Repository
# type has no `viewerCanPush` field, so don't request it (the CLI errors
# and the whole call returns empty, silently degrading every write-
# accessible repo to the "leave local" branch).
PUSH_INFO=$(gh repo view --json viewerPermission,viewerCanAdminister,nameWithOwner,isFork,owner,hasIssuesEnabled 2>/dev/null || true)
PERM=$(echo "$PUSH_INFO" | jq -r '.viewerPermission // empty')
case "$PERM" in
ADMIN|MAINTAIN|WRITE) CAN_PUSH=1 ;;
*) CAN_PUSH=0 ;;
esac
# A clone of the user's own fork reports ADMIN, so CAN_PUSH alone cannot tell
# the upstream's maintainer from an outsider working in their fork.
IS_FORK=$(echo "$PUSH_INFO" | jq -r '.isFork // false')
# Gates the read-only upstream-issues offer: no issues list, no upstream issues.
HAS_ISSUES=$(echo "$PUSH_INFO" | jq -r '.hasIssuesEnabled // false')
# isFork says the repo has a parent, not whose fork it is: a collaborator with
# push access to someone else's fork also sees isFork=true and WRITE. The
# current repo counts as the user's own fork only when the viewer owns it.
VIEWER_LC=$(gh api user 2>/dev/null | jq -r '.login // empty' | tr '[:upper:]' '[:lower:]')
OWNER_LC=$(echo "$PUSH_INFO" | jq -r '.owner.login // empty' | tr '[:upper:]' '[:lower:]')
if [ "$IS_FORK" = true ] && [ -n "$VIEWER_LC" ] && [ "$VIEWER_LC" = "$OWNER_LC" ]; then
IS_OWN_FORK=true
else
IS_OWN_FORK=false
fi
# If the command failed (no remote, no gh, not a GitHub repo, unauthenticated),
# $PUSH_INFO is empty and $PERM stays empty - fall back to the local-branch
# flow with the reason. Never silently assume push works.
# Detect remote-to-gh redirect: GitHub follows transfers/renames, so gh may
# resolve a different owner/repo than the configured remote implies.
REMOTE_URL=$(git remote get-url origin 2>/dev/null || true)
if [ -n "$REMOTE_URL" ]; then
# Normalise SSH and HTTPS forms (and GitHub Enterprise hosts) to owner/repo.
# SSH: git@host:owner/repo.git -> owner/repo
# HTTPS: https://host/owner/repo/ -> owner/repo
# Strip protocol, any user@, the host (not just github.com), a trailing .git,
# and a trailing slash - so a GHE host or a trailing slash can't masquerade as
# a redirect.
REMOTE_SLUG=$(echo "$REMOTE_URL" \
| sed -e 's|^[a-zA-Z]*://||' -e 's|^[^@/]*@||' -e 's|^[^/:]*[:/]||' -e 's|\.git$||' -e 's|/$||')
else
REMOTE_SLUG=""
fi
GH_SLUG=$(echo "$PUSH_INFO" | jq -r '.nameWithOwner // empty')
# Compare case-insensitively: GitHub treats owner/repo as case-insensitive, so a
# pure case difference is not a redirect and must not emit a spurious notice.
REMOTE_SLUG_LC=$(echo "$REMOTE_SLUG" | tr '[:upper:]' '[:lower:]')
GH_SLUG_LC=$(echo "$GH_SLUG" | tr '[:upper:]' '[:lower:]')
if [ -n "$REMOTE_SLUG" ] && [ -n "$GH_SLUG" ] && [ "$REMOTE_SLUG_LC" != "$GH_SLUG_LC" ]; then
REDIRECT_NOTICE="Note: origin (\`$REMOTE_SLUG\`) redirects to \`$GH_SLUG\`; the offers below target the redirected repo."
else
REDIRECT_NOTICE=""
fi
Then check whether the target turns away outside contributions. A fork PR against a repo whose README or CONTRIBUTING says "do not send a pull request" is noise for its maintainers, so the scan runs before any upstream offer is framed:
# no-contributions scan: start
# Sets NO_CONTRIBUTIONS (1/0) plus the first matching file (relative to the
# repo root) and line, so the offer can quote the statement back to the user.
NO_CONTRIBUTIONS=0
NO_CONTRIBUTIONS_SOURCE=""
NO_CONTRIBUTIONS_STATEMENT=""
# The pattern is built from named parts so every branch shares one noun and one
# boundary. _nc_noun ends at a non-letter (_nc_end), so "prs?" cannot match the
# start of "promise", "process" or "private"; the passive branch also needs a
# non-letter before the noun. _nc_neg has no leading boundary on purpose: it
# must match the tail of "cannot".
_nc_neg="(not|n't|n’t|unable to)"
_nc_noun="(contributions|pull requests?|prs?)"
_nc_end="([^a-z]|$)"
# Three refusal phrasings:
# accept: "does not accept (community) contributions", "not accepting PRs"
# imperative: "do not send a pull request" - the clause must end right after
# the noun, so "do not open a PR for typo fixes" (a house rule
# for contributors, not a refusal) stays out
# passive: "pull requests are not accepted"
_nc_accept="${_nc_neg} ([a-z-]+ )?accept(ing)? ([a-z-]+ )?${_nc_noun}${_nc_end}"
_nc_imperative="${_nc_neg} (send|open|submit) (a |any |us )?${_nc_noun}[[:space:]]*([.;!)]|$)"
_nc_passive="(^|[^a-z])${_nc_noun} (are|is|will) not (be )?accepted"
_nc_re="${_nc_accept}|${_nc_imperative}|${_nc_passive}"
# Qualifiers: a matched line that carries one ("PRs are not accepted without an
# issue") is a condition on contributing, not a refusal, and is dropped. This
# errs towards 0, which keeps today's fork-to-upstream offer.
_nc_cond="(^|[^a-z])(${_nc_noun}|accepted) (without|until|unless|before|directly|against|that|which)"
for _nc_doc in "$REPO_ROOT/README.md" "$REPO_ROOT/CONTRIBUTING.md" "$REPO_ROOT/.github/CONTRIBUTING.md" "$REPO_ROOT/docs/CONTRIBUTING.md"; do
[ -f "$_nc_doc" ] || continue
_nc_line=$(grep -Ei -e "$_nc_re" "$_nc_doc" | grep -Eiv -e "$_nc_cond" | head -n 1)
if [ -n "$_nc_line" ]; then
NO_CONTRIBUTIONS=1
NO_CONTRIBUTIONS_SOURCE=${_nc_doc#"$REPO_ROOT"/}
NO_CONTRIBUTIONS_STATEMENT=$(printf '%s\n' "$_nc_line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
break
fi
done
# no-contributions scan: end
Interpret the result:
CAN_PUSH=1(viewerPermission isWRITE/MAINTAIN/ADMIN, or the remote is a push-eligible fork): offer the direct PR flow below. Two cases whenNO_CONTRIBUTIONS=1. WithIS_FORK=truethe user is working in a clone of a fork (their own reportsADMIN; a collaborator on someone else's fork seesWRITE); they are the outsider the statement addresses, and a baregh pr createthere targets the parent, so offer the no-contributions flow instead (below; its fork step reuses the current repo only whenIS_OWN_FORK=true). WithIS_FORK=falsethe user maintains the repo itself: the statement addresses outsiders, not them, and GitHub will not fork a repo into the account that owns it, so keep the direct flow. In both cases quote$NO_CONTRIBUTIONS_STATEMENTand name$NO_CONTRIBUTIONS_SOURCEbeside the offer so the user decides knowingly.CAN_PUSH=0, viewerPermission isREAD/TRIAGE, andNO_CONTRIBUTIONS=0: name the constraint, then offer, in this order (withHAS_ISSUES=falsedrop option (1): the offers are the fork-based PR flow and "leave local", with issue tracking going to the fork or a personal tracker as in Step 6): (1) the upstream-issues flow, the default ("file the Top 3 Actions as issues on<owner>/<repo>, each linking the full report in your fork?"), which proposes no.assess/file for upstream; (2) the fork-based PR flow as an explicit opt-in ("also open a snapshot PR against<owner>/<repo>from your fork? Maintainers often decline committed generated output: the.assess/files are a dated snapshot that goes stale with the next commit."); (3) "leave local". Do not offer the direct flow. The findings are what a maintainer you do not work with acts on; issues carry them, a snapshot PR mostly does not.CAN_PUSH=0, viewerPermission isREAD/TRIAGE, andNO_CONTRIBUTIONS=1: the target says it takes no contributions, so never offer a PR against<owner>/<repo>. Quote$NO_CONTRIBUTIONS_STATEMENTand name$NO_CONTRIBUTIONS_SOURCE, then offer the no-contributions flow instead: "open the PR inside your fork, against the fork's default branch, and share the link?" Pair it with the Actions hint (see the flow below).ghunavailable / not a GitHub remote / not authenticated ($PUSH_INFOempty), whateverNO_CONTRIBUTIONSsays: skip every PR offer (direct, fork, and no-contributions) and surface only the "leave local" outcome, naming the reason ("no GitHub remote detected" / "ghnot authenticated").
If $REDIRECT_NOTICE is non-empty, output it verbatim on its own line before the batched Phase 2 question.
The push-capability result decides how the PR option appears in the batched Phase 2 question (it is not a separate prompt): use "open a PR in this repo" on a push-capable target, "file the Top 3 Actions as upstream issues linking the report in your fork" first (when HAS_ISSUES=true) and "fork and open a snapshot PR from your fork" second (two separate options) on a read-only target, "open a PR inside your fork and share the link" when NO_CONTRIBUTIONS=1 on a read-only target or with IS_FORK=true, and drop the PR option entirely when no GitHub remote is detected. Frame the batched question with the written artifacts, e.g. _"Wrote .assess/assess-report.md, .assess/complexity-heatmap.svg, and .assess/doc-graph.svg in <repo-name>. Which of these should I do?"_ followed by the feasible offers.
If the user selected the PR offer (direct flow, CAN_PUSH=1):
- Create a branch in the target repo:
assess/snapshot-<YYYY-MM-DD>(use the existing worktree workflow if<repo>-main+worktree/layout is present; otherwise branch in place). - Stage and commit the report, the complexity heatmap, and the doc graph. Commit message:
docs: Add AI-readiness assessment + complexity and doc-navigability snapshots. - Push the branch and open a PR. Title:
docs: Codebase assessment - <YYYY-MM-DD>.
If the user selected the PR offer (fork flow, CAN_PUSH=0 on the upstream, NO_CONTRIBUTIONS=0):
gh repo fork <owner>/<repo> --clone=false --remote=true(creates the fork under the user's account and adds it as a remote namedoriginor similar; the upstream becomesupstreamif the original was alreadyorigin).- Create the branch as above, push to the fork (
git push -u <fork-remote> <branch>), and open the PR viagh pr create --repo <owner>/<repo>(head defaults to the fork). - Commit message, PR title, and body are unchanged from the direct flow.
If the user selected the upstream-issues offer (read-only flow, CAN_PUSH=0 on READ / TRIAGE, NO_CONTRIBUTIONS=0): host the report in the fork, then file the issues upstream. Nothing under .assess/ is proposed for upstream.
- Resolve the fork and push the snapshot branch to it exactly as in step 1 of the no-contributions flow below (
FORK_SLUGfrom the forks endpoint, the retry, the branch push), and stop there. Skip the rest of that step: do not align the fork with the assessed commit (noBASE_SHAcomparison, noassess/base-<YYYY-MM-DD>branch push), write no PR body file, and open no PR, neither against upstream nor inside the fork. - Build the report link from the pushed branch:
REPORT_URL="https://<host>/$FORK_SLUG/blob/<branch>/.assess/assess-report.md"(<host>is the GitHub host the remote uses). Confirm it resolves withgh api "repos/$FORK_SLUG/contents/.assess/assess-report.md?ref=<branch>"before quoting it. - Run Step 6 with the upstream repository (
$GH_SLUG) as the tracker, using$REPORT_URLas each item's full-report link. If hosting was declined or failed, file the issues anyway: each body stands on its own without the link. - Suggest disabling Actions on the fork, as in step 3 of the no-contributions flow.
If the user selected the PR offer (no-contributions flow, NO_CONTRIBUTIONS=1 with either CAN_PUSH=0 on READ / TRIAGE or IS_FORK=true): the PR stays inside your fork; nothing is opened against upstream.
- Resolve the fork. With
IS_OWN_FORK=trueandCAN_PUSH=1the current repo is the user's own fork:FORK_SLUG="$GH_SLUG", and push toorigin. Otherwise (including any clone of someone else's fork, whatever the permission) fork as in step 1 of the fork flow, then read the fork's real name back (GitHub returns the existing fork for a repeat request, and appends a suffix when the account already owns a repo of that name, so never assemble it by hand):FORK_SLUG=$(gh api -X POST repos/<owner>/<repo>/forks | jq -r '.full_name'). Fork creation is asynchronous: ifgh repo view "$FORK_SLUG"fails straight after, retry it a few times, a few seconds apart, before giving up. Create the branch and push it to the fork as in the first half of the fork flow's step 2; do not run that step's upstreamgh pr create. Write the PR body template (below the flows) to a temp file and use it as<body-file>, with the direct flow's PR title as<title>. Open the PR against the fork's default branch instead:FORK_BRANCH=$(gh repo view "$FORK_SLUG" --json defaultBranchRef | jq -r '.defaultBranchRef.name'). A fork made earlier can sit behind or ahead of the checkout that was assessed, and a PR onto it would then carry every commit in between. So compareBASE_SHA=$(git rev-parse "<branch>^")(the commit the snapshot branch was cut from) withgh api "repos/$FORK_SLUG/branches/$FORK_BRANCH" | jq -r '.commit.sha'; if they differ, push the assessed commit to the fork as its own base (git push <fork-remote> "$BASE_SHA:refs/heads/assess/base-<YYYY-MM-DD>", where<fork-remote>is the remote the branch went to), setFORK_BRANCH=assess/base-<YYYY-MM-DD>, and tell the user the PR is based on that branch because the fork's default branch does not match what was assessed. This leaves the fork's existing branches untouched. Then create the PR through the fork's own pulls endpoint, which cannot resolve to the parent repo:gh api -X POST "repos/$FORK_SLUG/pulls" -f head=<branch> -f base="$FORK_BRANCH" -f title="<title>" -F body=@<body-file> | jq -r '.html_url'. - Share the link: print the fork PR's URL (the
html_urlabove; its path must end with/$FORK_SLUG/pull/<number>, whatever the host, so a GitHub Enterprise URL passes) so the user can pass it on to whoever wants the assessment. - Suggest disabling Actions on the fork: the fork carries the upstream's workflow files, so if the user ever enables Actions there, this PR and later pushes would start CI runs the fork's owner pays for on a private fork or self-hosted runners. Disabling them up front keeps the fork an inert place to share the report. Offer the command, never run it unasked:
gh api -X PUT "repos/$FORK_SLUG/actions/permissions" -F enabled=false. - Commit message, PR title, and body are unchanged from the direct flow.
Every PR flow (direct, fork, and no-contributions): the PR body leads with the findings and ends with the plugin reference so reviewers can install the tool that generated the report. The Readiness line and the Top 3 table come from assess_actions_render.py, which reads .assess/actions.json and .assess/run-context.json (relative to the repo root) and never the report, so the report's Top 3 section can change shape without changing the PR body. Pass --assess-dir "$REPO_ROOT/.assess/<slug>" for a --scope run:
<!-- chat-replace:uv-actions-render -->
RENDER="${CLAUDE_SKILL_DIR}/../assess/scripts/assess_actions_render.py"
uv run "$RENDER" "$REPO_ROOT" readiness # the Readiness value
uv run "$RENDER" "$REPO_ROOT" table # the Top 3 table, one row per actions.json entry in rank order
A missing or unreadable actions.json exits 1 with a message: say so in the PR body in place of the table, and never rebuild the table from the report. Use this body template:
```markdown
## Summary
Snapshot of this codebase's AI-agent readiness, complexity hotspots, and doc navigability as of <YYYY-MM-DD>.
- Readiness: <the output of
assess_actions_render.py <repo> readiness, verbatim> - Hotspot leader:
<top hotspot path>(<loc> LOC, ccn <N>, <M> commits in window) - writeccn ~<N> (approximate)when the row is scc-only (sourcescc,max_fn_ccnnull), andccn ~<N> (unreliable)when its path is instats_summary.complexity_unreliable - Top lying map:
<top stale-hub doc>(<N>d stale, subject churn <M>)
## Top 3 Actions
<the output of assess_actions_render.py <repo> table, verbatim>