Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .claude/commands/address-feedback.md

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions .claude/commands/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ Give every `Invoke-RestMethod` call `-TimeoutSec 30`, bound every download the s
- cryptography, network and TLS: the map's `git grep` commands; read each hit and judge it;
- outbound URLs: `git grep -n -I -o -E "https?://[^ )\"'>]+" -- . ":!*.md" ":!docs/"`; list each host, and each plain `http://` address other than localhost;
- a build: whether the build command makes files users run;
- regression tests: the changelog's `### Fixed` entries and the merged pull requests (GitHub) or merge requests (GitLab) of the last six months whose titles say they fix a bug; name each fix and the test file it adds or changes;
- regression tests: the changelog's `### Fixed` entries and the merged pull requests of the last six months whose titles say they fix a bug; name each fix and the test file it adds or changes;
- closed code scanning alerts (GitHub): `gh api "repos/<owner>/<repo>/code-scanning/alerts?state=dismissed&per_page=100"`; list each alert's rule, location and `dismissed_reason` and `dismissed_comment`; when the read fails, leave `static_analysis_fixed` open and say why.
3. List the commits `git log origin/<default branch>..HEAD --name-only` that add or change a file serving as evidence for a row (tests, `SECURITY.md`, workflows, docs). Say which answers they would change once merged, and recommend running this command again after the merge. Evidence found only there is never linked or answered Met.
4. Answer each row of the map's tables: start from its default; turn a Check into Met, Unmet or N/A only where a check or a file shows it, with a link `<web address>/blob/<default branch>/<path>#L<line>` where a line shows it; leave the rest open. Keep the Person rows Unmet unless the request above confirms them.
5. Resolve every link you write: the path exists on the default branch (`git cat-file -e origin/<default branch>:<path>`) and has that line (`git show origin/<default branch>:<path>` has at least that many lines). Fix or drop a link that doesn't resolve.
6. Compare the answers with the evidence: every `static_analysis_fixed` justification must name each alert dismissed as won't fix with its rationale (never 'none dismissed' while one exists), `regression_tests_added50` must name each fix with its test and not be N/A while a fix exists, and every release criterion agrees with the releases (`gh api repos/<owner>/<repo>/releases?per_page=5`); fix each answer that disagrees and say so.
7. When `best_practices_project` is unset, read `https://www.bestpractices.dev/projects.json?url=<web address, URL-encoded with [uri]::EscapeDataString>` with `Invoke-RestMethod`, never the `/en/` form (it redirects to HTML) and never `?q=` (it matches names only). A result with an entry whose `repo_url` equals the web address means registered: use its `id` as the number, use the update prompt, and end the reply with the `.\.template\Update-Project.ps1 -Data @{ best_practices_project = '<number>' }` line. No match means not registered. Say which source the number came from. When `best_practices_project` is set, read `https://www.bestpractices.dev/projects/<number>.json` with `Invoke-RestMethod`: each `<id>_status` and `<id>_justification`, `badge_level`, and `badge_percentage_0`, `_1` and `_2`. List each saved answer that no longer matches: an Unmet or `?` whose evidence now exists, a Met whose evidence is gone, and a justification with a link that step 5 can't resolve.
8. Report the OpenSSF Scorecard gaps. Skip this step on GitLab and say so. Read `https://api.scorecard.dev/projects/<host>/<path>` with `Invoke-RestMethod`. On a 404 say Scorecard has published no result (a private repository, or before `scorecard.yml` first ran) and go on. Report `score`, `date`, the run's commit (`repo.commit`) and whether `origin/<default branch>` has moved since. Count the people with write access: the entries whose `type` is `User` in `gh api "repos/<owner>/<repo>/collaborators?affiliation=all&permission=push&per_page=100"`; when the read fails, say why and recommend nothing below that depends on the count. Read the Scorecard alerts with `gh api "repos/<owner>/<repo>/code-scanning/alerts?tool_name=Scorecard&per_page=100"`, where an alert's `rule.name` is its check's name. A check under 10 with a dismissed alert and no open one is accepted: give its `dismissed_reason` and `dismissed_comment` as its action and `accepted` as who, instead of its row's action below. With one writer, Branch-Protection, CII-Best-Practices and Contributors can't reach 10 (decision record 0035 in `docs/decisions/project-template/`): for each of them with an open alert, the action is `.\tools\Dismiss-ScorecardAlerts.ps1 -Repo <owner>/<repo> -WhatIf`, run from a project-template clone, which lists the alerts it dismisses as won't fix and their reason, then the same without `-WhatIf`. For each check whose `score` is under 10 (a score of -1 is skipped, never reported), give its `details` lines and the action, in this order of rows:
8. Report the OpenSSF Scorecard gaps. Read `https://api.scorecard.dev/projects/<host>/<path>` with `Invoke-RestMethod`. On a 404 say Scorecard has published no result (a private repository, or before `scorecard.yml` first ran) and go on. Report `score`, `date`, the run's commit (`repo.commit`) and whether `origin/<default branch>` has moved since. Count the people with write access: the entries whose `type` is `User` in `gh api "repos/<owner>/<repo>/collaborators?affiliation=all&permission=push&per_page=100"`; when the read fails, say why and recommend nothing below that depends on the count. Read the Scorecard alerts with `gh api "repos/<owner>/<repo>/code-scanning/alerts?tool_name=Scorecard&per_page=100"`, where an alert's `rule.name` is its check's name. A check under 10 with a dismissed alert and no open one is accepted: give its `dismissed_reason` and `dismissed_comment` as its action and `accepted` as who, instead of its row's action below. With one writer, Branch-Protection, CII-Best-Practices and Contributors can't reach 10 (decision record 0035 in `docs/decisions/project-template/`): for each of them with an open alert, the action is `.\tools\Dismiss-ScorecardAlerts.ps1 -Repo <owner>/<repo> -WhatIf`, run from a project-template clone, which lists the alerts it dismisses as won't fix and their reason, then the same without `-WhatIf`. For each check whose `score` is under 10 (a score of -1 is skipped, never reported), give its `details` lines and the action, in this order of rows:
- Fuzzing: write property tests with the stack's property-test library, for .NET `FsCheck.Xunit` with `[Property(Replay = <fixed seed>)]` and a `using FsCheck` Scorecard detects; suggest `/plan-tests`. Who: a person writes them, the template adds nothing.
- Signed-Releases: Scorecard counts only the releases with assets among the five newest (`gh api repos/<owner>/<repo>/releases?per_page=5`, each release's `immutable` and `assets`) and averages them. From Scorecard v5.7.0 (the result's `scorecard.version`) an immutable release scores 10 and needs no signature or provenance asset; otherwise a release with a `*.intoto.jsonl` provenance file scores 10, one with only a signature (`.asc`, `.minisig`, `.sig`, `.sign`, `.sigstore` or `.sigstore.json`) 8, and any other 0. When the result's Scorecard is older than v5.7.0, say that a `scorecard.yml` pinning `ossf/scorecard-action` v2.6.0 or later, which a template update brings, counts immutable releases. When the releases are mutable and no workflow attaches files to a published release, name `.\tools\Set-RepositoryBaseline.ps1 -Repo <repo> -WhatIf`, run from a project-template clone, which shows it turning immutable releases on. For mutable releases that get their files after publishing, such as a .NET library's, list which have no `*.intoto.jsonl` or signature. Two options: wait for newer releases to push the old ones out of the five, or a person deletes the old unsigned assets (packages stay on the registry). `release-provenance.yml`'s `workflow_dispatch` can backfill only while the Publish run's `packages` artifact is kept (14 days). Never attest packages downloaded from a registry: that claims a build the workflow never ran.
- Branch-Protection: compare the `Warn:` lines with `gh api repos/<owner>/<repo>/rulesets` and `.../rulesets/<id>` (`required_approving_review_count`, `require_last_push_approval`), with whether `.github/workflows/code-review.yml` passes `approve: true`, and with the count of people with write access. NCode Review's approver is set up when `.github/workflows/code-review.yml` passes `approve: true` and a non-empty `approver-private-key:`, and `gh secret list --env code-review --repo <owner>/<repo>` lists `NCODE_REVIEW_APPROVER_PRIVATE_KEY` (decision record 0036 in `docs/decisions/project-template/`). With one writer and no approver set up, never recommend a required approval or approval of the last push: GitHub counts no approval from the author or from NCode Review's own app, so either blocks every merge, and decision record 0034 expects neither; when the ruleset has either, name `.\tools\Set-RepositoryBaseline.ps1 -Repo <repo> -WhatIf`, run from a project-template clone, which shows it turning them off. Where the approver is set up, whatever the number of writers, the NCode Review Approver's approval meets a required approval, and decision record 0036 expects one approval and last-push approval; with two writers or more, ADR-0022 expects them where `code-review.yml` passes `approve: true`. When the ruleset lacks what decision record 0036 or ADR-0022 expects, name the same command, which shows what it would set. When the ruleset has what ADR-0022 and decision records 0034 and 0036 expect and Scorecard still warns, say the run may predate the change and to compare the next run.
- Branch-Protection: compare the `Warn:` lines with `gh api repos/<owner>/<repo>/rulesets` and `.../rulesets/<id>` (`required_approving_review_count`, `require_last_push_approval`), with whether `.github/workflows/code-review.yml` passes `approve: true`, and with the count of people with write access. NCode Review's approver is set up when `.github/workflows/code-review.yml` passes `approve: true` and a non-empty `approver-private-key:`, and `gh secret list --env code-review --repo <owner>/<repo>` lists `NCODE_REVIEW_APPROVER_PRIVATE_KEY` (decision record 0036 in `docs/decisions/project-template/`). With one writer and no approver set up, never recommend a required approval or approval of the last push: GitHub counts no approval from the author or from NCode Review's own app, so either blocks every merge, and decision record 0034 expects neither; when the ruleset has either, name `.\tools\Set-RepositoryBaseline.ps1 -Repo <repo> -WhatIf`, run from a project-template clone, which shows it turning them off. Where the approver is set up, whatever the number of writers, the NCode Review Approver's approval meets a required approval, and decision record 0036 expects one approval and last-push approval; with two writers or more, ADR-0022 expects them where `code-review.yml` passes `approve: true`. When the ruleset lacks what decision record 0036 or ADR-0022 expects, name the same command, which shows what it would set. When the ruleset has what ADR-0022 and decision records 0034 and 0036 expect, Branch-Protection scores 8 where it requires one approval and 4 where it requires none, as the Branch-Protection row of the Scorecard decision record's table (`docs/decisions/project-template/0020-*.md`) says: at 8 the `Warn:` lines `required approving review count is 1` and `codeowners review is not required` are expected, since only tier 4's two approvals and code owners' review clear them, so give that row's Needs-a-person text for them, and with one writer never recommend requiring two approvals, which blocks every merge, since only the approver's approval counts. When it has what they expect and scores lower, say the run may predate the change and to compare the next run.
- CII-Best-Practices: the score after registering at each level (in progress 2, passing 5, silver 7, gold 10); this command writes the prompt for it. With one writer, passing is the most one person reaches: silver needs a second owner.
- Contributors, Code-Review, Maintained: need people; give the Needs-a-person text of the Scorecard decision record's table (`docs/decisions/project-template/0020-*.md`).
- Any other check under 10: its `details` lines and the `reason`.
9. Write the prompt, as plain text, to `best-practices-prompt.txt` at the repository root:
- not registered: the map's registration prompt, with OWNER/REPO replaced by the repository's path, SHA by the recorded commit's, and under ANSWERS one line per verified answer, `<level> <id>: <Met, Unmet or N/A> - <justification with its link>`;
- registered: the map's update prompt, with one block per saved answer from step 7 that changes;
- on GitLab, where the map has no prompt: the verified answers, one line each, grouped by level.
- registered: the map's update prompt, with one block per saved answer from step 7 that changes.
The file is never committed: when `git check-ignore -q best-practices-prompt.txt` exits non-zero, append the line `best-practices-prompt.txt` to `info/exclude` in the folder `git rev-parse --path-format=absolute --git-common-dir` prints.
10. Reply with the file's path; per level, how many answers are Met, Unmet, N/A and open; first any SUGGESTED criterion still `?` that keeps passing below 100%; and every MUST criterion that keeps a level from being earned, the Person ones first, with why and the repository change that would clear it. Keep `require_2FA` and `secure_2FA` Unmet and ask me to confirm the organization's two-factor setting; autofill's Met is not evidence. Add the Scorecard table (check, score, action, who). End with these next steps, in this order:
1. Land the repository changes.
Expand Down
Loading