diff --git a/.agents/skills/declscope-adoption/SKILL.md b/.agents/skills/declscope-adoption/SKILL.md index 3449812..c11ef37 100644 --- a/.agents/skills/declscope-adoption/SKILL.md +++ b/.agents/skills/declscope-adoption/SKILL.md @@ -3,14 +3,14 @@ name: declscope-adoption description: Adopt declscope on an existing Go codebase and drive its diagnostics to zero. Read this when introducing declscope to a repository, when choosing its configuration, when running declscope shrink for the first time, or when clearing a declscope baseline. Covers sizing each rule before enabling it, reading the diagnostics as structure, the remedy for each shape, and the measurement traps that produce false confidence. For writing new code in a repository that already runs declscope, use declscope-authoring. license: MIT x-embedded-by: declscope -x-embedded-version: 0.24.2 -x-embedded-at: "2026-11-05T22:53:00Z" -x-embedded-digest: "sha256:f18505e995e9ce41734e28044012b0fbe3e961e0434de31beaf2ae615dfc6e95" +x-embedded-version: 0.24.3 +x-embedded-at: "2026-11-07T03:12:19Z" +x-embedded-digest: "sha256:f99d90326a7db71fe55758c24a93d49bd45e47414a9d23156700813056a15885" --- # Adopting declscope -Written against **declscope 0.24.2**. Check the version first with `declscope -V=full`: this describes how that release behaves, not how an older one does. +Written against **declscope 0.24.3**. Check the version first with `declscope -V=full`: this describes how that release behaves, not how an older one does. **Read [the README](https://github.com/mpyw/declscope#readme) before the first decision.** This skill covers what to do about the diagnostics. What each directive means, and what the config accepts, is there. @@ -54,6 +54,8 @@ Each file's patterns are read against **its own** directory, and anchor there wh **Ask before any config change**, as [declscope-authoring](../declscope-authoring/SKILL.md#do-not-hide-a-report) says. That includes the first config file. Wait for an answer before changing any code, too. +**When nobody can answer, as in a non-interactive run, do not wait.** Adopt the minimum below, with no config file, and make the changes this skill describes. Say in your report what you chose, and which settings the owner may still want to switch on. + **The minimum is no config file at all.** `boundary`, `surplus: strict` and `unused: strict` are on. They check reach and whether directives still change anything; the naming rule checks a convention. Adopting this much is a complete adoption. **Size the default `surplus` findings before changing code.** `loose` judges a `//declscope:shared` as a whole, so one reached declaration keeps the whole directive quiet. The default `strict` also reports each declaration the directive widens for nothing, and one `declscope -fix` run inserts every `//declscope:private` it asks for. If the owner wants the narrower check, set `surplus: loose` explicitly. @@ -122,7 +124,7 @@ This happened when declscope held itself to `shrink`. The fix unexported twelve | 4. Read what the analyzer now reports | `declscope ./...` | | 5. State or move each new crossing | See [What each shape means](#what-each-shape-means) | -Ask before step 2, the same as any other change. The fix renames every identifier naming the declaration, all inside its own package, and the doc comment that opens with the name. +Ask before step 2, the same as any other change. When nobody can answer, apply the fix if the request allows changing exported names, as a request to clear the findings or to refactor does. `shrink` judges only under `internal/`, so no importer outside the module breaks. Otherwise, baseline what it reports, as the next paragraph says. The fix renames every identifier naming the declaration, all inside its own package, and the doc comment that opens with the name. **When the owner cannot settle `shrink` yet, baseline it.** `declscope baseline ./...` records `shrink`'s reports with the analyzer's, and `shrink` then passes on them in CI. It is the same deferral as any baseline, and [the same rules](#a-baseline-is-for-arriving-not-for-staying) apply. A repository that does not run `shrink` passes `-shrink=false`, which skips the extra load. diff --git a/.agents/skills/declscope-authoring/SKILL.md b/.agents/skills/declscope-authoring/SKILL.md index 3a9f6df..7968bbe 100644 --- a/.agents/skills/declscope-authoring/SKILL.md +++ b/.agents/skills/declscope-authoring/SKILL.md @@ -3,14 +3,14 @@ name: declscope-authoring description: "Write or change Go code in a repository that runs declscope, which shows as a .declscope.y*ml or baseline file, //declscope: comments, or declscope in CI. Read this before adding, naming or moving a declaration, a helper that several files use, or a test. Read it too before splitting a file, writing a //declscope: directive, or acting on a declscope diagnostic. Covers where code belongs, naming it accurately, and fixes that hide a problem." license: MIT x-embedded-by: declscope -x-embedded-version: 0.24.2 -x-embedded-at: "2026-11-05T22:53:00Z" -x-embedded-digest: "sha256:43e21045fe8b3065a93166e19e8c406ef64c9777046e873c5fd8bbb531e303d6" +x-embedded-version: 0.24.3 +x-embedded-at: "2026-11-07T03:12:19Z" +x-embedded-digest: "sha256:72a3d979255b4a98442850042cbb90b6b9dc073ffd4f0f7ce9ce59a832a922f7" --- # Writing code under declscope -Written against **declscope 0.24.2**. Check the version first with `declscope -V=full`: this describes how that release behaves, not how an older one does. +Written against **declscope 0.24.3**. Check the version first with `declscope -V=full`: this describes how that release behaves, not how an older one does. This skill is for everyday work in a repository that already runs declscope. Introducing it, choosing its configuration, and clearing the whole repository's baseline are in [declscope-adoption](../declscope-adoption/SKILL.md), installed beside this one. Changing one package whose findings are baselined, including clearing its entries, is in [Changing a package that has a baseline](#changing-a-package-that-has-a-baseline). What each directive and config key means is in [the README](https://github.com/mpyw/declscope#readme). @@ -60,7 +60,7 @@ In this skill, the owner is the user you are working for. Handle a proposal to t | The situation | Do this | | --- | --- | -| Your change cannot pass the check without an answer | Ask in the chat, and wait. Do not finish with a failing check, a bent name or an ignore. When nobody can answer, as in a non-interactive run, leave that part undone. Finish the rest only when it works without it. When it does not, change nothing. Put the question in your report | +| Your change cannot pass the check without an answer | Ask in the chat, and wait. Do not finish with a failing check, a bent name or an ignore. When nobody can answer, as in a non-interactive run, do not stop. Carry out the option you would recommend, and say in your report what you chose and why. That is still never a bent name, an ignore, or a config change other than a vocabulary entry | | The owner declines | Ask the owner to choose between two, and wait as above. One is a new file named in the package's convention, with its own `//declscope:namespace`. In a package that keeps a layer in one file, name it after that file, such as `parser_function_call.go`. Name the new file and its namespace in the question. A file the owner chose is not one made just to satisfy a name. The other is `//declscope:ignore qualify // ` on the name. `qualify` is the naming rule's name. An ignore the owner chose is a decision | | Your change passes without it | Write it in your report, and finish | @@ -86,7 +86,7 @@ The package's files may follow another plan. Some packages keep a layer in one f | Keeps one layer in one file, such as every parse function in `parser.go` | Put the new functions in that file. A method goes in its type's file, as [Common changes](#common-changes) says. The new names carry the file's namespace, as for any file. When no natural name carries the namespace, propose a namespace for the file, as [Fixing an existing file's namespace](#fixing-an-existing-files-namespace) explains | | Already has a file for the concept you add | Put the new code there, even when that file's existing declarations are baselined. Its names carry that file's namespace. When no natural name does, propose a namespace for the file, as in the row above | -In every row, the new code may use a private declaration of another file. When declscope reports that use, write `//declscope:shared // ` on that declaration, such as `// parser.go builds these`. Leave the declaration where it is. When it states its own `//declscope:private`, ask the owner instead. +In every row, the new code may use a private declaration of another file. When declscope reports that use, write `//declscope:shared // ` on that declaration, such as `// parser.go builds these`. Leave the declaration where it is. When it states its own `//declscope:private`, ask the owner instead. When nobody can answer, the table at the top of this section applies. A directive a declaration states is a decision, so the option you recommend never flips it. Here is a new file for the first row. `parser.go` calls `newFunctionCallExpr`. Its test file, `ast_function_call_expr_test.go`, takes the same directive. @@ -108,7 +108,7 @@ func newFunctionCallExpr( /* ... */ ) *FunctionCallExpr { /* ... */ } Sometimes a new name cannot carry an existing file's namespace. `parseAttribute` in `parser.go` does not carry `parser`. A function in `ast_attribute.go` rarely carries `astAttribute`. Then propose to fix the file's namespace, such as `//declscope:namespace parse` on `parser.go`: -1. Ask the owner. Say that every baselined finding of the file comes back, and that you will fix them. The check fails without the answer, so wait +1. Ask the owner. Say that every baselined finding of the file comes back, and that you will fix them. The check fails without the answer, so wait. When nobody can answer, the table at the top of this section applies 2. When the owner agrees, treat that file as a refactoring the user asked for. [Refactoring a part of the package](#refactoring-a-part-of-the-package) applies to it, `-merge` included. That run also drops the package's other entries that match nothing, which is fine. The diff still only removes lines 3. When the owner declines, go to the declined row of the table above @@ -265,7 +265,7 @@ Use it for a word that names what the namespace names: another form of it, or th | Spells a different word, which describes the thing better | The file may be named wrong, or the declaration may be in the wrong file. See [An ill-fitting prefix](#an-ill-fitting-prefix-means-the-declaration-is-in-the-wrong-file) | | Would need a long list of words | Split the file. A long list means the file declares things it is not about | -A vocabulary entry is a config change, so ask first. List the word the name actually spells. Do not list a stem you guessed: `trac` would also carry `track`. +A vocabulary entry is a config change, so ask first. When nobody can answer, add it and say so in your report: it only widens what carries one namespace. List the word the name actually spells. Do not list a stem you guessed: `trac` would also carry `track`. ## Directives @@ -457,7 +457,7 @@ A bare `//declscope:ignore` does not reach `overexported`. Name the rule. Names | Regenerating the baseline over new findings | Records your new crossing as if it were old | | `//declscope:ignore` without a reason | The next reader cannot tell a decision from a shortcut | -**Config changes are the owner's decision.** Ask before writing or changing one. +**Config changes are the owner's decision.** Ask before writing or changing one. When nobody can answer, a vocabulary entry is the only config change to make. Never change a rule's mode, the filter or the baseline path on your own. ## Traps diff --git a/mise.toml b/mise.toml index 270f982..762ec69 100644 --- a/mise.toml +++ b/mise.toml @@ -1,3 +1,3 @@ [tools] -"github:mpyw/declscope" = "0.24.2" +"github:mpyw/declscope" = "0.24.3" golangci-lint = "2.15.0"