Skip to content

Commit aea7507

Browse files
imaqsoodclaude
andcommitted
(MODULES-11829) Address review: move to moduleroot_init + content fixes
Respond to review on #642: - Move CLAUDE.md.erb from moduleroot/ (force-synced on every pdk update) to moduleroot_init/ so it is a one-time default: new modules get it and own it, existing modules are never overwritten (per @david22swan). This also removes the clobber risk for the 5 modules that hand-maintain a CLAUDE.md -- no .sync.yml opt-out needed. moduleroot_init needs no config_defaults entry. - Reframe the header from "do not edit" to "starting point, tailor it to this repo" -- the file is meant to carry module-specific detail, not stay generic. - Drop `has_linux ||= !has_windows`: it mislabelled AIX/Solaris/Darwin-only modules as Linux (@Copilot). Empty/unknown metadata still defaults to Linux. - Keep RuboCop under bundler: `bundle exec rubocop -A`, not bare `rubocop -a` (@Copilot). - Note facts come from facterdb via rspec-puppet-facts/on_supported_os (@david22swan). - Mention spec_helper_acceptance.rb(+_local) for Litmus setup (@david22swan). - Note that rules needing enforcement should be backed by runtime hooks in .claude/, since prose alone can be treated as suggestions (@david22swan). Validated with PDK 3.4.0: pdk new module deploys the file (owned, customizable); pdk update leaves an existing module's copy untouched. Pure ASCII, ERB balanced. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7d88682 commit aea7507

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@
77
os_names = os_support.map { |o| ((o['operatingsystem'] || '').to_s.downcase rescue '') }
88
linux_names = %w[redhat centos oraclelinux scientific sles suse opensuse debian ubuntu rocky almalinux amazon fedora virtuozzolinux gentoo archlinux]
99
has_windows = os_names.include?('windows')
10+
# Empty/unknown metadata (e.g. a fresh `pdk new module`) defaults to the Linux section. Modules that
11+
# support only non-Linux, non-Windows platforms (AIX/Solaris/Darwin) render neither OS section and
12+
# rely on the OS-agnostic guidance above -- rather than being mislabelled as Linux.
1013
has_linux = os_names.empty? || os_names.any? { |n| linux_names.include?(n) }
11-
# Guarantee at least one OS section: any non-Windows module (incl. AIX/Solaris/Darwin-only)
12-
# defaults to the Linux content; Windows-only modules stay Windows-only.
13-
has_linux ||= !has_windows
1414
-%>
1515
# CLAUDE.md
1616

1717
This file provides guidance to Claude Code (claude.ai/code) and human contributors when
1818
working with code in this repository.
1919

20-
> **This file is synced from [puppetlabs/pdk-templates](https://github.com/puppetlabs/pdk-templates)
21-
> (`moduleroot/CLAUDE.md.erb`).** Do not edit it directly in a module repo -- changes are
22-
> overwritten on the next `pdk update`. To customise per module, add module-specific notes via a
23-
> `## Module-specific notes` section in a file PDK does not manage, or opt this file out entirely
24-
> with `CLAUDE.md: unmanaged: true` in the module's `.sync.yml` and maintain a hand-written copy.
20+
> **Starting point, not a straitjacket.** This file ships from
21+
> [puppetlabs/pdk-templates](https://github.com/puppetlabs/pdk-templates) as a baseline of conventions
22+
> common to CAT-supported modules. **Tailor it to this repo** -- add the specifics Claude actually
23+
> needs: what the manifests/types/providers/functions here do, module-specific gotchas, and anything
24+
> learned while working in the codebase. A generic framework alone is not enough to guide good changes.
25+
>
26+
> PDK adds this file when a module is first created (`pdk new module`, or `pdk convert` for a module
27+
> that doesn't have one yet) and then leaves it alone -- it is **not** re-synced or overwritten on
28+
> `pdk update`. It is yours to edit freely; keep it current as the module grows.
2529

2630
For generic Puppet/PDK workflow that *is* derivable from the files themselves (the full PDK command
2731
reference, CI matrix mechanics, README badges), see the PDK docs and the README. The notes below are
@@ -98,6 +102,8 @@ bundle exec rake litmus:acceptance:parallel
98102
- Every class/defined type should have `it { is_expected.to compile.with_all_deps }` -- a clean
99103
compile across the supported OS matrix is the baseline gate.
100104
- Drive OS variants with `on_supported_os` (reads `metadata.json`) rather than hand-listing facts.
105+
- Facts come largely from **facterdb** (via `rspec-puppet-facts` / `on_supported_os`) -- you rarely
106+
need to hand-build fact hashes; override only the specific facts a test needs on top of the OS set.
101107
- Stub facts via the `:facts` hash or `spec/default_facts.yml`; do not rely on the host's real facts.
102108
- Provide Hiera test data through `spec/fixtures/hiera/` and a test `hiera.yaml` when behaviour is
103109
data-driven. Use `let(:params)` / `let(:pre_condition)` for class params and dependencies.
@@ -135,14 +141,17 @@ COVERAGE=yes bundle exec rspec # SimpleCov report
135141
### Spec helpers
136142

137143
- `spec/spec_helper.rb` is **PDK-managed -- do not edit**; it is overwritten on `pdk update`.
138-
- Put project-local setup in `spec/spec_helper_local.rb` (safe to edit).
144+
- Put project-local unit setup in `spec/spec_helper_local.rb` (safe to edit).
145+
- `spec/spec_helper_acceptance.rb` (+ `spec/spec_helper_acceptance_local.rb`) drives the Litmus
146+
acceptance run; put acceptance-only helpers there, not in the unit spec helper.
139147

140148
---
141149

142150
## Ruby code style
143151

144152
- Style is enforced by `.rubocop.yml` (deployed from pdk-templates, `strict` profile). Run
145-
`bundle exec rake rubocop` / `rubocop -a` before pushing; do not hand-tune cops in the synced file.
153+
`bundle exec rake rubocop` (or `bundle exec rubocop -A` to autocorrect) before pushing -- always
154+
under `bundle exec` so you get the module's pinned RuboCop version; do not hand-tune cops in the synced file.
146155
- Conventions the profile enforces: `Layout/LineLength` max 200, `snake_case` naming, `%r{}` for regex
147156
literals, trailing commas on multiline arrays/args, and the `rubocop-performance` / `rubocop-rspec`
148157
extensions. Target Ruby version follows `.rubocop.yml`'s `TargetRubyVersion`.
@@ -337,3 +346,7 @@ PRs are judged on outcomes, not line counts:
337346
- Never delete a file without permission -- this applies even after a blanket "yes to all".
338347
- Never output, log, save, or hardcode security-sensitive values -- passwords, tokens, API keys,
339348
private keys, secrets, or credentials of any kind. Do not write them to files, commit messages, or responses.
349+
350+
> These are guidance, not enforcement. For anything that must hold every run (secret hygiene, no
351+
> direct pushes to `main`, the coverage gate), back it with a runtime hook in the repo's `.claude/`
352+
> settings -- prose alone can be treated as a suggestion and skipped.

0 commit comments

Comments
 (0)