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
2 changes: 1 addition & 1 deletion .claude/commands/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Give every `Invoke-RestMethod` call `-TimeoutSec 30`, bound every download the s
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. 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`. Whatever the number of writers, the same commands are the action for each open Token-Permissions alert whose workflow, its `most_recent_instance.location.path`, and permission, the `jobLevel '<permission>'` of its `most_recent_instance.message.text`, the Token-Permissions row of the Scorecard decision record's table (`docs/decisions/project-template/0020-*.md`) lists (decision record 0086 in `docs/decisions/project-template/`); any other Token-Permissions alert, such as a top-level write or one in a workflow of the project's own, is the project's to narrow. 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, 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.
Expand Down
Loading