@ikon85/agent-workflow-kit 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: census-update
3
+ description: "Build, refresh, or check an optional project-local census. Use when a user invokes census-update, asks to establish a counted surface census, or needs to reconcile census drift; scan facts in the current repository, guide only ambiguous decisions, and activate a verified candidate transactionally."
4
+ ---
5
+
6
+ # Census Update
7
+
8
+ Build and maintain the current repository's consumer-owned census through the
9
+ public API in `scripts/census/index.mjs`. Keep this skill a thin coordinator:
10
+ do not copy, rename, or reimplement the scanner, state, delta, fingerprint, or
11
+ transaction logic.
12
+
13
+ ## Boundaries
14
+
15
+ - Work only in the current repository. Never inspect another project, aggregate
16
+ cross-project findings, learn shared recipes from other repositories, or
17
+ propose an upstream kit change.
18
+ - Treat code as the source of facts. Never ask the user which files, paths, or
19
+ patterns exist.
20
+ - Ask only for one genuinely ambiguous decision at a time. Include a concise
21
+ recommendation and the evidence behind it.
22
+ - Keep generated scanners, tests, profiles, decisions, and the active census in
23
+ the consumer repository. Do not add a dependency without explicit approval.
24
+
25
+ ## Public mechanism
26
+
27
+ Import only the stable exports from `scripts/census/index.mjs`:
28
+ `scanCensus`, `serializeCensus`, `fingerprintCensus`,
29
+ `CENSUS_BUILDER_VERSION`, `diffCensus`, `CENSUS_STATES`, `CENSUS_VERDICTS`,
30
+ `resolveCensusState`, `activateCensus`, and `CensusTransactionError`.
31
+
32
+ ## Consumer files
33
+
34
+ First adopt an existing, explicitly documented census path convention when the
35
+ repository has one. Otherwise use `.census/profile.json` for the consumer-owned
36
+ profile and `.census/active.json` for the verified snapshot. A missing default
37
+ profile is not an error: report `bootstrap` and stage it only after facts and
38
+ decisions are ready rather than silently enabling a gate.
39
+
40
+ The deterministic profile schema is:
41
+
42
+ ```json
43
+ {
44
+ "schemaVersion": 1,
45
+ "enabled": true,
46
+ "decisions": [
47
+ { "family": "name", "status": "verdict", "evidence": "fact", "justification": "required when not relevant" }
48
+ ],
49
+ "localScanners": [
50
+ { "surface": "family", "module": "repo-relative path", "export": "function", "test": "repo-relative test path" }
51
+ ],
52
+ "overrides": [
53
+ { "scope": "this change", "reason": "visible display-only reason" }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ Keep all three arrays present and order their records by family or surface, then
59
+ path. Preserve extra consumer-owned keys when rewriting an adopted profile.
60
+ Pass `decisions` to `scanCensus` as `behaviorFamilies` after mapping `family` to
61
+ `name`. Put the unchanged decision, local-scanner, and override records in a
62
+ visible `profileReport` beside the scanned snapshot. Derive snapshot state with
63
+ `resolveCensusState`; never assign `current` as a literal shortcut.
64
+
65
+ Local-scanner records configure the verifier passed to `activateCensus`: run
66
+ the named focused test, import the named repository-local export, and require
67
+ its result to include the recorded surface. Both `module` and `test` must be
68
+ repository-relative, contained regular files; reject absolute paths, `..`
69
+ escapes, and symlinks before executing or importing either one. Compare surface
70
+ families with the previous active snapshot; a new family without that passing
71
+ proof is still open for state resolution even when Git tracking lets the base
72
+ scan enumerate it. Overrides are report input only and are never passed into
73
+ scanning, fingerprinting, verification, or state resolution.
74
+
75
+ ## Workflow
76
+
77
+ 1. **Check.** Read the local profile and active census, if present. Report a
78
+ missing profile as `bootstrap`; otherwise derive one
79
+ of `disabled`, `bootstrap`, `current`, `refresh_required`, `updating`, or
80
+ `failed` through the public API. An explicit opt-out is disabled. Do not
81
+ write during this step.
82
+ 2. **Scan facts.** Call `scanCensus` once with the current repository root.
83
+ Product code and production configuration form the surface denominator;
84
+ tests and docs remain evidence. Let the scanner exclude secrets, ignored,
85
+ generated, and vendored content. Never read excluded content to explain a
86
+ result.
87
+ 3. **Show the delta.** For an active census, call `diffCensus` and show only
88
+ added, changed, removed, and open names. Do not dump the full scan unless the
89
+ user asks. For bootstrap, show the discovered families and counts.
90
+ 4. **Resolve ambiguity.** Recommend a decision for each ambiguous behavior or
91
+ surface and ask separately. Record the user's decision with its evidence.
92
+ `nicht relevant` requires a durable justification. Never infer it silently. <!-- language-census: ok -->
93
+ 5. **Handle unknown patterns locally.** Keep an unknown surface `offen`. It can
94
+ become `abgedeckt` only after this repository contains a small local scanner
95
+ and a focused passing test for that pattern. Run that test before rescanning.
96
+ 6. **Verify a candidate.** Build the candidate from the fresh scan and recorded
97
+ decisions. Fail verification when any surface or behavior remains `offen`,
98
+ when a required local scanner test fails, or when the candidate fingerprints
99
+ do not describe the current repository.
100
+ 7. **Activate.** Call `activateCensus` with a real verifier so it stages, verifies,
101
+ and atomically swaps under its local lock. On `CensusTransactionError`, report
102
+ `updating` or `failed` and keep the previous active census authoritative.
103
+ 8. **Prove the result.** Report surface coverage as `X of Y`, then render the
104
+ behavior overview separately. State the resulting census state and the
105
+ builder version.
106
+
107
+ ## Decision rules
108
+
109
+ - Store a justified `nicht relevant` verdict as a visible decision beside the <!-- language-census: ok -->
110
+ candidate; do not erase the family from the overview.
111
+ - A change-local override may suppress a known mechanical false-positive in
112
+ the displayed delta only when its reason and scope are visible. It must not
113
+ alter scanner facts, fingerprints, `offen` verdicts, or state resolution, so
114
+ real drift can never become `current` through an override.
115
+ - Any unexpected product area stays `offen` and therefore prevents `current`,
116
+ even if every known area is covered.
117
+ - Facts discovered after a decision invalidate that decision's stale premise;
118
+ rescan and ask again only if the remaining choice is genuinely ambiguous.
119
+
120
+ ## No-write and recovery proof
121
+
122
+ Before activation, compare the fresh candidate with the active census using
123
+ the public fingerprints and deterministic `serializeCensus` output. If the
124
+ repository and decisions are unchanged and the derived state is `current`,
125
+ report `current` and do not call `activateCensus` or write any file.
126
+
127
+ If scanning, a local test, verification, or activation fails, report `failed`,
128
+ discard the candidate when safe, and confirm that the previous active census
129
+ bytes are unchanged. Never manufacture `current` after an error.
130
+
131
+ ## Final report
132
+
133
+ Return only the useful audit trail:
134
+
135
+ - state and builder version;
136
+ - compact delta;
137
+ - surface coverage `X of Y`;
138
+ - separate behavior overview;
139
+ - visible `nicht relevant` justifications and active override, if any; <!-- language-census: ok -->
140
+ - local scanner tests run and the transaction/no-write result.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: setup-workflow
3
- description: "Scaffolds the project layer the portable workflow skills assume — issue tracker, triage labels, domain-doc layout, GitHub-Projects board field-IDs, spec-self-critique + spec-completeness seeds, workflow overview, and the deploy target. Writes `docs/agents/*`, `docs/conventions/spec-completeness.md`, and the `## Workflow` / `## Agent skills` / `## Prod` blocks in CLAUDE.md/AGENTS.md. Idempotent: a re-run reconciles per file/section and never overwrites filled content. Run once after installing the skills (or `npx <pkg> init`), or when a skill reports missing project-layer context. Adapted from Matt Pocock's `setup-matt-pocock-skills` (MIT)."
3
+ description: "Scaffolds the project layer the portable workflow skills assume — issue tracker, triage labels, domain-doc layout, board field IDs, spec seeds, workflow overview, optional census choice, and deploy target. Writes `docs/agents/*`, `docs/conventions/spec-completeness.md`, and the `## Workflow` / `## Agent skills` / `## Prod` blocks in CLAUDE.md/AGENTS.md. Idempotent: a re-run reconciles per file/section and never overwrites filled content. Run once after installing the skills (or `npx <pkg> init`), or when a skill reports missing project-layer context. Adapted from Matt Pocock's `setup-matt-pocock-skills` (MIT)."
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
@@ -25,6 +25,7 @@ This is a prompt-driven skill, not a deterministic script. Explore, present what
25
25
  | `## Workflow` in CLAUDE.md **and** AGENTS.md | generic entry-point map seeded from [workflow-overview.md](./workflow-overview.md) (Section F + Write) |
26
26
  | `## Agent skills` + `## Prod` in CLAUDE.md **and** AGENTS.md | one-line pointers + deploy target (Sections C/G + Write) |
27
27
  | `.github/workflows/agent-workflow-kit-update.yml` | optional tested Kit update pull request for GitHub consumers (Section A2) |
28
+ | `docs/agents/census.md` | optional-census choice, paths, state, and safe disable contract seeded from [census.md](./census.md) (Section A3) |
28
29
 
29
30
  ## Idempotency contract — read before writing anything
30
31
 
@@ -54,6 +55,7 @@ Read the current state; don't assume. For every target file, read its first line
54
55
  - `CLAUDE.md` and `AGENTS.md` at the repo root — which exist? Do they already have a `## Workflow` / `## Agent skills` / `## Prod` block?
55
56
  - `CONTEXT.md`, `CONTEXT-MAP.md`, `docs/adr/` — domain-doc layout.
56
57
  - `docs/agents/`, `docs/agents/skills/`, `docs/conventions/` — prior output of this skill.
58
+ - `docs/agents/census.md`, `.census/profile.json`, `.census/active.json` — an existing census choice or consumer-owned census to adopt.
57
59
  - `gh auth status` (if GitHub) — is `gh` authenticated, and with which scopes?
58
60
 
59
61
  ### 2. Section A — Issue tracker
@@ -105,6 +107,34 @@ For GitLab, local, other, or an unknown provider, give only a provider-neutral e
105
107
 
106
108
  **Conditional board-write note (only when the GitHub tracker uses a managed board):** if Section D ends with `board-sync.md` at `mode: github-projects-v2`, add one line to `issue-tracker.md`: *"Board writes (item-add, status/wave/cluster field edits, sub-issue links) go through the board-sync helper, not bare `gh issue create`/`gh project item-*`."* Do **not** add this for GitLab, local, other, or `mode: none`.
107
109
 
110
+ ### 2b. Section A3 — Optional project census
111
+
112
+ > A project census is an optional, consumer-owned map that counts product
113
+ > surfaces and lists behavior families separately. It can make later plans and
114
+ > handoffs more complete, but setup cannot honestly claim coverage before the
115
+ > repository has been scanned and verified.
116
+
117
+ Read [census.md](./census.md) in full before presenting the choice. If
118
+ `docs/agents/census.md` already records `yes`, `later`, or `no`, adopt that
119
+ choice and do not prompt again on an ordinary setup rerun. Also adopt an
120
+ existing, explicitly documented census path. If no choice exists, ask in plain
121
+ language: *"Should setup prepare the optional project census now?"* Offer
122
+ exactly:
123
+
124
+ - **Yes** — create or adopt the project layer and minimal enabled profile, run
125
+ only the shipped self-test, and report the honest `bootstrap` / "not yet
126
+ meaningful" state. Do not scan, activate, or install a hook or gate.
127
+ - **Later** — record a deferral. Create no census profile, hook, or gate; a
128
+ later explicit `census-update` invocation may activate without setup.
129
+ - **No** — record the opt-out as `disabled`. Create no census profile, hook, or
130
+ gate and do not prompt again unless the user explicitly changes the choice.
131
+
132
+ Use the complete `missing / yes / later / no / existing / explicit-enable /
133
+ disable` matrix in the seed. A later explicit `census-update` invocation may
134
+ activate without rerunning setup. Disable enforcement first, but retain every
135
+ consumer-owned profile, scanner, test, and active snapshot unless the user
136
+ separately approves deletion. Repeated runs are no-ops after reconciliation.
137
+
108
138
  ### 3. Section B — Triage labels
109
139
 
110
140
  > When `triage` processes an incoming issue it applies labels (or your tracker's equivalent). It needs strings you've actually configured, or it creates duplicates.
@@ -182,6 +212,14 @@ Seed `docs/agents/code-review.md` from [code-review.md](./code-review.md) — th
182
212
 
183
213
  For each `docs/...` file: obey the idempotency contract (the "Idempotency contract" section). Prepend the sentinel with the resolved `state` (and `mode` for board-sync).
184
214
 
215
+ For `docs/agents/census.md`, seed [census.md](./census.md), prepend the normal
216
+ sentinel, and record the selected choice directly below it as
217
+ `<!-- census: choice=<yes|later|no> -->`. On adoption, also record the discovered
218
+ repository-relative profile and active-snapshot paths. Never overwrite a
219
+ pre-existing consumer-owned census file. `yes`, `later`, `no`, and an adopted
220
+ existing census are terminal for ordinary setup reruns. Only an explicit user
221
+ request changes a recorded choice.
222
+
185
223
  For the **`## Workflow`**, **`## Agent skills`**, and **`## Prod`** blocks, reconcile per section in **both** CLAUDE.md and AGENTS.md that exist:
186
224
 
187
225
  - If **both** files exist → write/update the block in **both** (keep them coherent — Codex is a first-class surface).
@@ -0,0 +1,83 @@
1
+ # Optional project census
2
+
3
+ The census is a consumer-owned, counted map of product surfaces and behavior
4
+ families. It is optional. Setup records only the user's choice; `census-update`
5
+ does the factual scan, resolves ambiguity, verifies a candidate, and activates
6
+ the result transactionally.
7
+
8
+ ## Setup state matrix
9
+
10
+ | State or choice | Setup action | Observable result on repeat |
11
+ |---|---|---|
12
+ | `missing` | Explain the census in plain language and ask `yes / later / no`; do not infer an answer. | Ask again only while no choice has been recorded; write no hook or gate. |
13
+ | `yes` | Create the minimal consumer-owned profile, or adopt the existing documented profile path. Set `enabled: true`, keep the active snapshot absent, run only the shipped census self-test, and report `bootstrap` / "not yet meaningful". | Adopt the same profile byte-for-byte; do not rescan, activate, or add another self-test. |
14
+ | `later` | Record a retryable deferral outside the active profile. | Leave census files, hooks, and gates absent; an ordinary setup rerun is a no-op, while an explicit `census-update` may activate later. |
15
+ | `no` | Record an explicit opt-out with census state `disabled`. | Keep the opt-out and do not create census files, hooks, or gates. |
16
+ | `existing` | Adopt the repository's explicitly documented profile and active-snapshot paths without replacing consumer-owned content. Derive its state through the public census API. | Preserve every existing byte and report the derived state. |
17
+ | `explicit-enable` | On a later explicit `census-update` invocation, let that skill scan, decide, verify, and transactionally activate without rerunning setup. | An unchanged verified census reports `current` and performs no write. |
18
+ | `disable` | Set the profile to `enabled: false` transactionally and remove census hooks/gates from enforcement. | Stay `disabled`; retain consumer-owned profiles, scanners, tests, and snapshots unless the user separately approves their deletion. |
19
+
20
+ ## Deterministic setup effects
21
+
22
+ The table below is the machine-checkable reference contract for setup. Its
23
+ ordered `operations` are the only effects the setup proof may execute. Choice
24
+ persistence always means `docs/agents/census.md`: the normal setup sentinel is
25
+ the first line and `<!-- census: choice=<yes|later|no> -->` is the second.
26
+ Paths under `retain` are consumer-owned evidence. Enforcement operations refer
27
+ only to kit-owned wiring documented by the consumer; they are not permission to
28
+ invent another census engine.
29
+
30
+ ```json census-setup-effects
31
+ [
32
+ {"state":"missing","actor":"setup","choice":"none","operations":[],"retain":[],"repeat":"no-write"},
33
+ {"state":"yes","actor":"setup","choice":"yes","operations":["reconcile-choice-doc","reconcile-minimal-profile","derive-state","run-foundation-self-test"],"retain":[],"repeat":"no-write"},
34
+ {"state":"later","actor":"setup","choice":"later","operations":["reconcile-choice-doc"],"retain":[],"repeat":"no-write"},
35
+ {"state":"no","actor":"setup","choice":"no","operations":["reconcile-choice-doc","derive-state"],"retain":[],"repeat":"no-write"},
36
+ {"state":"existing","actor":"setup","choice":"recorded","operations":["adopt-choice-doc","derive-state"],"retain":["choice-doc","profile","active","scanner","scanner-test"],"repeat":"no-write"},
37
+ {"state":"explicit-enable","actor":"census-update","choice":"recorded","operations":["delegate-census-update","run-census-update-contract"],"retain":["choice-doc","profile","active","scanner","scanner-test"],"repeat":"no-write"},
38
+ {"state":"disable","actor":"census-update","choice":"recorded","operations":["remove-kit-hook","remove-kit-gate","update-profile-disabled","derive-state"],"retain":["choice-doc","profile-unknown-keys","active","scanner","scanner-test"],"repeat":"no-write"}
39
+ ]
40
+ ```
41
+
42
+ ## Bootstrap profile
43
+
44
+ When `yes` creates the default `.census/profile.json`, write the deterministic
45
+ profile shape documented by `census-update`: `schemaVersion: 1`, `enabled:
46
+ true`, and empty `decisions`, `localScanners`, and `overrides` arrays. Do not
47
+ create `.census/active.json`. Its absence is the evidence that the honest state
48
+ is `bootstrap`, not `current`.
49
+
50
+ Before writing, check for an existing repository convention and adopt it. A
51
+ pre-existing profile remains consumer-owned: preserve unknown keys and do not
52
+ replace its decisions. Never derive `current` from file presence; use
53
+ `resolveCensusState` from `scripts/census/index.mjs`.
54
+
55
+ Run the focused `scripts/census/state.test.mjs` census foundation self-test
56
+ already shipped with the kit.
57
+ A passing self-test proves the mechanism is available, not that this repository
58
+ has been scanned. Setup must not install pre-commit, pre-push, CI, planning, or
59
+ handoff gates for `yes`, `later`, or `no`.
60
+
61
+ ## Later activation and disable
62
+
63
+ `later` and `no` are setup choices, not partially active censuses. A later,
64
+ explicit `census-update` invocation is the sole activation route. Setup
65
+ delegates this route to the shipped `census-update` contract and its focused
66
+ `scripts/test_census_update_contract.test.mjs` proof; it does not reproduce
67
+ activation, snapshots, or enforcement. Setup itself never calls `activateCensus`.
68
+
69
+ Disable follows the ordered contract: remove the kit-owned hook, remove the
70
+ kit-owned gate, then atomically replace only the profile's `enabled` value with
71
+ `false`, preserving unknown keys, and verify `disabled` through
72
+ `resolveCensusState`. Enforcement removal must finish before any profile
73
+ mutation. Treat the choice document, local scanners, their tests, the profile,
74
+ and the active snapshot as consumer-owned evidence. List those files and ask
75
+ for separate deletion approval; without that approval, retain them.
76
+ Setup never deletes consumer-owned files as part of disable.
77
+
78
+ ## Setup report
79
+
80
+ Report the choice, adopted or created paths, derived state, self-test result,
81
+ and whether enforcement changed. Name every action skipped on an idempotent
82
+ rerun. Never claim surface coverage during setup: only `census-update` can
83
+ produce a verified `X of Y` result.
@@ -17,6 +17,7 @@ Use this section as the entry-point map for agent-assisted work. The individual
17
17
  - **A design question needs a runnable answer (state, business logic, a UI you have to see):** spike it with `prototype`, then fold what you learned back in.
18
18
  - **Multi-session build from a PRD or issue:** use `implement` to drive `tdd` end-to-end, one red-green slice at a time.
19
19
  - **Implementation slice:** use `tdd` for one behavior at a time: RED, GREEN, then refactor.
20
+ - **Build or refresh a project-local census:** use `census-update` to scan facts, resolve ambiguous decisions one at a time, and transactionally activate a counted census.
20
21
  - **Finished slice:** use `wrapup` to prepare the branch, PR, and cleanup steps your repo expects.
21
22
  - **Kit release:** use `kit-release` to derive the shipped delta, confirm Semver, regenerate the manifest, run all gates, and then hand landing to `wrapup`.
22
23
  - **Kit update:** use `kit-update` to preview and transactionally apply a parity-verified scoped release without overwriting local modifications.
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: census-update
3
+ description: "Build, refresh, or check an optional project-local census. Use when a user invokes census-update, asks to establish a counted surface census, or needs to reconcile census drift; scan facts in the current repository, guide only ambiguous decisions, and activate a verified candidate transactionally."
4
+ ---
5
+
6
+ # Census Update
7
+
8
+ Build and maintain the current repository's consumer-owned census through the
9
+ public API in `scripts/census/index.mjs`. Keep this skill a thin coordinator:
10
+ do not copy, rename, or reimplement the scanner, state, delta, fingerprint, or
11
+ transaction logic.
12
+
13
+ ## Boundaries
14
+
15
+ - Work only in the current repository. Never inspect another project, aggregate
16
+ cross-project findings, learn shared recipes from other repositories, or
17
+ propose an upstream kit change.
18
+ - Treat code as the source of facts. Never ask the user which files, paths, or
19
+ patterns exist.
20
+ - Ask only for one genuinely ambiguous decision at a time. Include a concise
21
+ recommendation and the evidence behind it.
22
+ - Keep generated scanners, tests, profiles, decisions, and the active census in
23
+ the consumer repository. Do not add a dependency without explicit approval.
24
+
25
+ ## Public mechanism
26
+
27
+ Import only the stable exports from `scripts/census/index.mjs`:
28
+ `scanCensus`, `serializeCensus`, `fingerprintCensus`,
29
+ `CENSUS_BUILDER_VERSION`, `diffCensus`, `CENSUS_STATES`, `CENSUS_VERDICTS`,
30
+ `resolveCensusState`, `activateCensus`, and `CensusTransactionError`.
31
+
32
+ ## Consumer files
33
+
34
+ First adopt an existing, explicitly documented census path convention when the
35
+ repository has one. Otherwise use `.census/profile.json` for the consumer-owned
36
+ profile and `.census/active.json` for the verified snapshot. A missing default
37
+ profile is not an error: report `bootstrap` and stage it only after facts and
38
+ decisions are ready rather than silently enabling a gate.
39
+
40
+ The deterministic profile schema is:
41
+
42
+ ```json
43
+ {
44
+ "schemaVersion": 1,
45
+ "enabled": true,
46
+ "decisions": [
47
+ { "family": "name", "status": "verdict", "evidence": "fact", "justification": "required when not relevant" }
48
+ ],
49
+ "localScanners": [
50
+ { "surface": "family", "module": "repo-relative path", "export": "function", "test": "repo-relative test path" }
51
+ ],
52
+ "overrides": [
53
+ { "scope": "this change", "reason": "visible display-only reason" }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ Keep all three arrays present and order their records by family or surface, then
59
+ path. Preserve extra consumer-owned keys when rewriting an adopted profile.
60
+ Pass `decisions` to `scanCensus` as `behaviorFamilies` after mapping `family` to
61
+ `name`. Put the unchanged decision, local-scanner, and override records in a
62
+ visible `profileReport` beside the scanned snapshot. Derive snapshot state with
63
+ `resolveCensusState`; never assign `current` as a literal shortcut.
64
+
65
+ Local-scanner records configure the verifier passed to `activateCensus`: run
66
+ the named focused test, import the named repository-local export, and require
67
+ its result to include the recorded surface. Both `module` and `test` must be
68
+ repository-relative, contained regular files; reject absolute paths, `..`
69
+ escapes, and symlinks before executing or importing either one. Compare surface
70
+ families with the previous active snapshot; a new family without that passing
71
+ proof is still open for state resolution even when Git tracking lets the base
72
+ scan enumerate it. Overrides are report input only and are never passed into
73
+ scanning, fingerprinting, verification, or state resolution.
74
+
75
+ ## Workflow
76
+
77
+ 1. **Check.** Read the local profile and active census, if present. Report a
78
+ missing profile as `bootstrap`; otherwise derive one
79
+ of `disabled`, `bootstrap`, `current`, `refresh_required`, `updating`, or
80
+ `failed` through the public API. An explicit opt-out is disabled. Do not
81
+ write during this step.
82
+ 2. **Scan facts.** Call `scanCensus` once with the current repository root.
83
+ Product code and production configuration form the surface denominator;
84
+ tests and docs remain evidence. Let the scanner exclude secrets, ignored,
85
+ generated, and vendored content. Never read excluded content to explain a
86
+ result.
87
+ 3. **Show the delta.** For an active census, call `diffCensus` and show only
88
+ added, changed, removed, and open names. Do not dump the full scan unless the
89
+ user asks. For bootstrap, show the discovered families and counts.
90
+ 4. **Resolve ambiguity.** Recommend a decision for each ambiguous behavior or
91
+ surface and ask separately. Record the user's decision with its evidence.
92
+ `nicht relevant` requires a durable justification. Never infer it silently. <!-- language-census: ok -->
93
+ 5. **Handle unknown patterns locally.** Keep an unknown surface `offen`. It can
94
+ become `abgedeckt` only after this repository contains a small local scanner
95
+ and a focused passing test for that pattern. Run that test before rescanning.
96
+ 6. **Verify a candidate.** Build the candidate from the fresh scan and recorded
97
+ decisions. Fail verification when any surface or behavior remains `offen`,
98
+ when a required local scanner test fails, or when the candidate fingerprints
99
+ do not describe the current repository.
100
+ 7. **Activate.** Call `activateCensus` with a real verifier so it stages, verifies,
101
+ and atomically swaps under its local lock. On `CensusTransactionError`, report
102
+ `updating` or `failed` and keep the previous active census authoritative.
103
+ 8. **Prove the result.** Report surface coverage as `X of Y`, then render the
104
+ behavior overview separately. State the resulting census state and the
105
+ builder version.
106
+
107
+ ## Decision rules
108
+
109
+ - Store a justified `nicht relevant` verdict as a visible decision beside the <!-- language-census: ok -->
110
+ candidate; do not erase the family from the overview.
111
+ - A change-local override may suppress a known mechanical false-positive in
112
+ the displayed delta only when its reason and scope are visible. It must not
113
+ alter scanner facts, fingerprints, `offen` verdicts, or state resolution, so
114
+ real drift can never become `current` through an override.
115
+ - Any unexpected product area stays `offen` and therefore prevents `current`,
116
+ even if every known area is covered.
117
+ - Facts discovered after a decision invalidate that decision's stale premise;
118
+ rescan and ask again only if the remaining choice is genuinely ambiguous.
119
+
120
+ ## No-write and recovery proof
121
+
122
+ Before activation, compare the fresh candidate with the active census using
123
+ the public fingerprints and deterministic `serializeCensus` output. If the
124
+ repository and decisions are unchanged and the derived state is `current`,
125
+ report `current` and do not call `activateCensus` or write any file.
126
+
127
+ If scanning, a local test, verification, or activation fails, report `failed`,
128
+ discard the candidate when safe, and confirm that the previous active census
129
+ bytes are unchanged. Never manufacture `current` after an error.
130
+
131
+ ## Final report
132
+
133
+ Return only the useful audit trail:
134
+
135
+ - state and builder version;
136
+ - compact delta;
137
+ - surface coverage `X of Y`;
138
+ - separate behavior overview;
139
+ - visible `nicht relevant` justifications and active override, if any; <!-- language-census: ok -->
140
+ - local scanner tests run and the transaction/no-write result.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: setup-workflow
3
- description: "Scaffolds the project layer the portable workflow skills assume — issue tracker, triage labels, domain-doc layout, GitHub-Projects board field-IDs, spec-self-critique + spec-completeness seeds, workflow overview, and the deploy target. Writes `docs/agents/*`, `docs/conventions/spec-completeness.md`, and the `## Workflow` / `## Agent skills` / `## Prod` blocks in CLAUDE.md/AGENTS.md. Idempotent: a re-run reconciles per file/section and never overwrites filled content. Run once after installing the skills (or `npx <pkg> init`), or when a skill reports missing project-layer context. Adapted from Matt Pocock's `setup-matt-pocock-skills` (MIT)."
3
+ description: "Scaffolds the project layer the portable workflow skills assume — issue tracker, triage labels, domain-doc layout, board field IDs, spec seeds, workflow overview, optional census choice, and deploy target. Writes `docs/agents/*`, `docs/conventions/spec-completeness.md`, and the `## Workflow` / `## Agent skills` / `## Prod` blocks in CLAUDE.md/AGENTS.md. Idempotent: a re-run reconciles per file/section and never overwrites filled content. Run once after installing the skills (or `npx <pkg> init`), or when a skill reports missing project-layer context. Adapted from Matt Pocock's `setup-matt-pocock-skills` (MIT)."
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
@@ -25,6 +25,7 @@ This is a prompt-driven skill, not a deterministic script. Explore, present what
25
25
  | `## Workflow` in CLAUDE.md **and** AGENTS.md | generic entry-point map seeded from [workflow-overview.md](./workflow-overview.md) (Section F + Write) |
26
26
  | `## Agent skills` + `## Prod` in CLAUDE.md **and** AGENTS.md | one-line pointers + deploy target (Sections C/G + Write) |
27
27
  | `.github/workflows/agent-workflow-kit-update.yml` | optional tested Kit update pull request for GitHub consumers (Section A2) |
28
+ | `docs/agents/census.md` | optional-census choice, paths, state, and safe disable contract seeded from [census.md](./census.md) (Section A3) |
28
29
 
29
30
  ## Idempotency contract — read before writing anything
30
31
 
@@ -54,6 +55,7 @@ Read the current state; don't assume. For every target file, read its first line
54
55
  - `CLAUDE.md` and `AGENTS.md` at the repo root — which exist? Do they already have a `## Workflow` / `## Agent skills` / `## Prod` block?
55
56
  - `CONTEXT.md`, `CONTEXT-MAP.md`, `docs/adr/` — domain-doc layout.
56
57
  - `docs/agents/`, `docs/agents/skills/`, `docs/conventions/` — prior output of this skill.
58
+ - `docs/agents/census.md`, `.census/profile.json`, `.census/active.json` — an existing census choice or consumer-owned census to adopt.
57
59
  - `gh auth status` (if GitHub) — is `gh` authenticated, and with which scopes?
58
60
 
59
61
  ### 2. Section A — Issue tracker
@@ -105,6 +107,34 @@ For GitLab, local, other, or an unknown provider, give only a provider-neutral e
105
107
 
106
108
  **Conditional board-write note (only when the GitHub tracker uses a managed board):** if Section D ends with `board-sync.md` at `mode: github-projects-v2`, add one line to `issue-tracker.md`: *"Board writes (item-add, status/wave/cluster field edits, sub-issue links) go through the board-sync helper, not bare `gh issue create`/`gh project item-*`."* Do **not** add this for GitLab, local, other, or `mode: none`.
107
109
 
110
+ ### 2b. Section A3 — Optional project census
111
+
112
+ > A project census is an optional, consumer-owned map that counts product
113
+ > surfaces and lists behavior families separately. It can make later plans and
114
+ > handoffs more complete, but setup cannot honestly claim coverage before the
115
+ > repository has been scanned and verified.
116
+
117
+ Read [census.md](./census.md) in full before presenting the choice. If
118
+ `docs/agents/census.md` already records `yes`, `later`, or `no`, adopt that
119
+ choice and do not prompt again on an ordinary setup rerun. Also adopt an
120
+ existing, explicitly documented census path. If no choice exists, ask in plain
121
+ language: *"Should setup prepare the optional project census now?"* Offer
122
+ exactly:
123
+
124
+ - **Yes** — create or adopt the project layer and minimal enabled profile, run
125
+ only the shipped self-test, and report the honest `bootstrap` / "not yet
126
+ meaningful" state. Do not scan, activate, or install a hook or gate.
127
+ - **Later** — record a deferral. Create no census profile, hook, or gate; a
128
+ later explicit `census-update` invocation may activate without setup.
129
+ - **No** — record the opt-out as `disabled`. Create no census profile, hook, or
130
+ gate and do not prompt again unless the user explicitly changes the choice.
131
+
132
+ Use the complete `missing / yes / later / no / existing / explicit-enable /
133
+ disable` matrix in the seed. A later explicit `census-update` invocation may
134
+ activate without rerunning setup. Disable enforcement first, but retain every
135
+ consumer-owned profile, scanner, test, and active snapshot unless the user
136
+ separately approves deletion. Repeated runs are no-ops after reconciliation.
137
+
108
138
  ### 3. Section B — Triage labels
109
139
 
110
140
  > When `triage` processes an incoming issue it applies labels (or your tracker's equivalent). It needs strings you've actually configured, or it creates duplicates.
@@ -182,6 +212,14 @@ Seed `docs/agents/code-review.md` from [code-review.md](./code-review.md) — th
182
212
 
183
213
  For each `docs/...` file: obey the idempotency contract (the "Idempotency contract" section). Prepend the sentinel with the resolved `state` (and `mode` for board-sync).
184
214
 
215
+ For `docs/agents/census.md`, seed [census.md](./census.md), prepend the normal
216
+ sentinel, and record the selected choice directly below it as
217
+ `<!-- census: choice=<yes|later|no> -->`. On adoption, also record the discovered
218
+ repository-relative profile and active-snapshot paths. Never overwrite a
219
+ pre-existing consumer-owned census file. `yes`, `later`, `no`, and an adopted
220
+ existing census are terminal for ordinary setup reruns. Only an explicit user
221
+ request changes a recorded choice.
222
+
185
223
  For the **`## Workflow`**, **`## Agent skills`**, and **`## Prod`** blocks, reconcile per section in **both** CLAUDE.md and AGENTS.md that exist:
186
224
 
187
225
  - If **both** files exist → write/update the block in **both** (keep them coherent — Codex is a first-class surface).
@@ -0,0 +1,83 @@
1
+ # Optional project census
2
+
3
+ The census is a consumer-owned, counted map of product surfaces and behavior
4
+ families. It is optional. Setup records only the user's choice; `census-update`
5
+ does the factual scan, resolves ambiguity, verifies a candidate, and activates
6
+ the result transactionally.
7
+
8
+ ## Setup state matrix
9
+
10
+ | State or choice | Setup action | Observable result on repeat |
11
+ |---|---|---|
12
+ | `missing` | Explain the census in plain language and ask `yes / later / no`; do not infer an answer. | Ask again only while no choice has been recorded; write no hook or gate. |
13
+ | `yes` | Create the minimal consumer-owned profile, or adopt the existing documented profile path. Set `enabled: true`, keep the active snapshot absent, run only the shipped census self-test, and report `bootstrap` / "not yet meaningful". | Adopt the same profile byte-for-byte; do not rescan, activate, or add another self-test. |
14
+ | `later` | Record a retryable deferral outside the active profile. | Leave census files, hooks, and gates absent; an ordinary setup rerun is a no-op, while an explicit `census-update` may activate later. |
15
+ | `no` | Record an explicit opt-out with census state `disabled`. | Keep the opt-out and do not create census files, hooks, or gates. |
16
+ | `existing` | Adopt the repository's explicitly documented profile and active-snapshot paths without replacing consumer-owned content. Derive its state through the public census API. | Preserve every existing byte and report the derived state. |
17
+ | `explicit-enable` | On a later explicit `census-update` invocation, let that skill scan, decide, verify, and transactionally activate without rerunning setup. | An unchanged verified census reports `current` and performs no write. |
18
+ | `disable` | Set the profile to `enabled: false` transactionally and remove census hooks/gates from enforcement. | Stay `disabled`; retain consumer-owned profiles, scanners, tests, and snapshots unless the user separately approves their deletion. |
19
+
20
+ ## Deterministic setup effects
21
+
22
+ The table below is the machine-checkable reference contract for setup. Its
23
+ ordered `operations` are the only effects the setup proof may execute. Choice
24
+ persistence always means `docs/agents/census.md`: the normal setup sentinel is
25
+ the first line and `<!-- census: choice=<yes|later|no> -->` is the second.
26
+ Paths under `retain` are consumer-owned evidence. Enforcement operations refer
27
+ only to kit-owned wiring documented by the consumer; they are not permission to
28
+ invent another census engine.
29
+
30
+ ```json census-setup-effects
31
+ [
32
+ {"state":"missing","actor":"setup","choice":"none","operations":[],"retain":[],"repeat":"no-write"},
33
+ {"state":"yes","actor":"setup","choice":"yes","operations":["reconcile-choice-doc","reconcile-minimal-profile","derive-state","run-foundation-self-test"],"retain":[],"repeat":"no-write"},
34
+ {"state":"later","actor":"setup","choice":"later","operations":["reconcile-choice-doc"],"retain":[],"repeat":"no-write"},
35
+ {"state":"no","actor":"setup","choice":"no","operations":["reconcile-choice-doc","derive-state"],"retain":[],"repeat":"no-write"},
36
+ {"state":"existing","actor":"setup","choice":"recorded","operations":["adopt-choice-doc","derive-state"],"retain":["choice-doc","profile","active","scanner","scanner-test"],"repeat":"no-write"},
37
+ {"state":"explicit-enable","actor":"census-update","choice":"recorded","operations":["delegate-census-update","run-census-update-contract"],"retain":["choice-doc","profile","active","scanner","scanner-test"],"repeat":"no-write"},
38
+ {"state":"disable","actor":"census-update","choice":"recorded","operations":["remove-kit-hook","remove-kit-gate","update-profile-disabled","derive-state"],"retain":["choice-doc","profile-unknown-keys","active","scanner","scanner-test"],"repeat":"no-write"}
39
+ ]
40
+ ```
41
+
42
+ ## Bootstrap profile
43
+
44
+ When `yes` creates the default `.census/profile.json`, write the deterministic
45
+ profile shape documented by `census-update`: `schemaVersion: 1`, `enabled:
46
+ true`, and empty `decisions`, `localScanners`, and `overrides` arrays. Do not
47
+ create `.census/active.json`. Its absence is the evidence that the honest state
48
+ is `bootstrap`, not `current`.
49
+
50
+ Before writing, check for an existing repository convention and adopt it. A
51
+ pre-existing profile remains consumer-owned: preserve unknown keys and do not
52
+ replace its decisions. Never derive `current` from file presence; use
53
+ `resolveCensusState` from `scripts/census/index.mjs`.
54
+
55
+ Run the focused `scripts/census/state.test.mjs` census foundation self-test
56
+ already shipped with the kit.
57
+ A passing self-test proves the mechanism is available, not that this repository
58
+ has been scanned. Setup must not install pre-commit, pre-push, CI, planning, or
59
+ handoff gates for `yes`, `later`, or `no`.
60
+
61
+ ## Later activation and disable
62
+
63
+ `later` and `no` are setup choices, not partially active censuses. A later,
64
+ explicit `census-update` invocation is the sole activation route. Setup
65
+ delegates this route to the shipped `census-update` contract and its focused
66
+ `scripts/test_census_update_contract.test.mjs` proof; it does not reproduce
67
+ activation, snapshots, or enforcement. Setup itself never calls `activateCensus`.
68
+
69
+ Disable follows the ordered contract: remove the kit-owned hook, remove the
70
+ kit-owned gate, then atomically replace only the profile's `enabled` value with
71
+ `false`, preserving unknown keys, and verify `disabled` through
72
+ `resolveCensusState`. Enforcement removal must finish before any profile
73
+ mutation. Treat the choice document, local scanners, their tests, the profile,
74
+ and the active snapshot as consumer-owned evidence. List those files and ask
75
+ for separate deletion approval; without that approval, retain them.
76
+ Setup never deletes consumer-owned files as part of disable.
77
+
78
+ ## Setup report
79
+
80
+ Report the choice, adopted or created paths, derived state, self-test result,
81
+ and whether enforcement changed. Name every action skipped on an idempotent
82
+ rerun. Never claim surface coverage during setup: only `census-update` can
83
+ produce a verified `X of Y` result.
@@ -17,6 +17,7 @@ Use this section as the entry-point map for agent-assisted work. The individual
17
17
  - **A design question needs a runnable answer (state, business logic, a UI you have to see):** spike it with `prototype`, then fold what you learned back in.
18
18
  - **Multi-session build from a PRD or issue:** use `implement` to drive `tdd` end-to-end, one red-green slice at a time.
19
19
  - **Implementation slice:** use `tdd` for one behavior at a time: RED, GREEN, then refactor.
20
+ - **Build or refresh a project-local census:** use `census-update` to scan facts, resolve ambiguous decisions one at a time, and transactionally activate a counted census.
20
21
  - **Finished slice:** use `wrapup` to prepare the branch, PR, and cleanup steps your repo expects.
21
22
  - **Kit release:** use `kit-release` to derive the shipped delta, confirm Semver, regenerate the manifest, run all gates, and then hand landing to `wrapup`.
22
23
  - **Kit update:** use `kit-update` to preview and transactionally apply a parity-verified scoped release without overwriting local modifications.
@@ -107,6 +107,16 @@
107
107
  ],
108
108
  "provenance": "matt-pocock"
109
109
  },
110
+ "census-update": {
111
+ "class": "generic",
112
+ "publish": true,
113
+ "entryPoint": true,
114
+ "surfaces": [
115
+ "claude",
116
+ "codex"
117
+ ],
118
+ "provenance": "own"
119
+ },
110
120
  "board-to-waves": {
111
121
  "class": "generic",
112
122
  "publish": true,