Commit 00ad75b
authored
docs: add new-netbox-endpoint reference skill (.claude/skills/) (#408)
* docs: add .claude/skills/new-netbox-endpoint reference skill
New project-scoped Claude Code skill codifying the repeatable workflow
for adding a NetBox REST API endpoint as PowerShell cmdlets
(Get/New/Set/Remove + tests).
What it covers:
- All 4 cmdlet templates with parameter-set layout, pipeline input,
Write-Verbose logging, SupportsShouldProcess, and -Raw switch
- Query filter parameter placement in Get templates
- Test pattern (mock at InvokeNetboxRequest, not Invoke-RestMethod)
+ the Pester-default / UriBuilder / JSON depth gotchas
- MANDATORY AssertNBMutualExclusiveParam on every Get cmdlet (PR #397/#400)
- ValidateSet parity workflow against scripts/Verify-ValidateSetParity.ps1
- Recurring pitfalls from past releases:
- PS 5.1 non-ASCII parse bug (PR #398, #404)
- [ValidateRange] + [Nullable[T]] conflict (PR #398)
- [AllowNull] + [ValidateSet] on [string] — use empty-string
sentinel + [AllowEmptyString] (PR #401)
- Default-value stripping in Pester mocks
- Pagination .next origin validation (PR #404)
- Build artefact drift on deploy.ps1 runs
- Parameter naming (snake_case → PascalCase via underscore; [object[]]$Tags
for new cmdlets; [bool] not [switch] for API bool fields)
- Verification checklist before PR
Iterated on feedback from a subagent reviewer dispatch:
- Added Write-Verbose to New/Set/Remove templates (matches actual repo
convention in all EventRules/* and peer functions)
- Added query-filter placeholder block to the Get template
- Made the Brief/Fields/Omit mutex check explicitly MANDATORY (not
optional) per PR #397/#400
The skill itself is auto-discovered by Claude Code at
`.claude/skills/new-netbox-endpoint/SKILL.md`. Human contributors can
read it as a regular markdown doc.
Updated `.gitignore` to un-ignore `.claude/skills/**` while keeping
`.claude/commands/` and `settings.local.json` ignored (existing behavior
for local-only slash commands and personal settings).
No runtime code changes. CLAUDE.md refresh landed as a local workstation
change (CLAUDE.md is intentionally outside the git repo per
`.gitignore:26`, so it doesn't participate in this PR).
* docs(skill): apply subagent review fixes to new-netbox-endpoint
Three valid findings from the Explore-agent dispatch that didn't make
it into the initial commit:
1. Add `Write-Verbose` to GET/NEW/SET/REMOVE templates (matches the
actual convention in Functions/Extras/EventRules/* and peer
functions; was missing from my first draft).
2. Add a query-filter placeholder block + explanation to the GET
template. New contributors need to see where to put `-Label`,
`-Status`, etc. and how they flow through BuildURIComponents.
3. Tighten the Brief/Fields/Omit mutex comment from "enforce mutual
exclusion" to "MANDATORY on every Get cmdlet since PR #397/#400"
so agents don't treat it as optional.
Also tightened the frontmatter description per writing-skills guidance
(should describe triggering conditions only, never summarise the
skill's workflow).
* docs(skill): address Gemini review — Tags pitfall row + JSON depth 10
Round 1 Gemini on PR #408, two valid findings applied:
- Test template now uses `ConvertTo-Json -Compress -Depth 10`. The
Pitfalls table already notes the default depth of 2 can mangle
nested objects; the test example should demonstrate the fix rather
than silently inherit the default.
- Added a Tags row to the Pitfalls table explaining the
[string[]] / [uint64[]] → [object[]] evolution. The Parameter
naming section had a `see Pitfalls` pointer to a row that didn't
exist; now it does.
The third finding (remove the switch/foreach from the Get template and
rely on BuildURIComponents' id / id__in branching) was rejected with
evidence — see Gemini reply on the PR. That pattern would collapse the
ByID and Query parameter sets into one, which is a functional change:
ByID hits the detail endpoint (/api/.../42/) returning richer data;
Query hits the list endpoint with an id__in filter. The switch+foreach
is the actual repo convention, verified against
Functions/DCIM/Devices/Get-NBDCIMDevice.ps1 and
Functions/Extras/EventRules/Get-NBEventRule.ps1.
* docs(skill): Gemini round 2 — ByID passes Brief/Fields/Omit, Offset uint32
Two valid findings from round 2:
1. ByID block ignored projection params (HIGH — real bug in my template).
NetBox supports ?brief=1 / ?fields= / ?omit= on detail endpoints
(/api/<x>/<id>/), and real Get functions (Get-NBDCIMDevice,
Get-NBEventRule) all pass them through. My minimal template skipped
BuildURIComponents in the ByID branch, so a user following the
skill would produce cmdlets where -Brief did nothing on single-ID
fetches. Fixed.
2. Offset type uint16 overflows on large NetBox datasets (MEDIUM).
uint16 tops out at 65 535; real-world IPAM addresses and Circuits
easily exceed that. Changed the template to uint32. Existing Get
functions still use uint16 — leaving those as-is for now (would be
a ~120-function sweep) and documenting the skill as the forward-
going convention, matching the pattern used for [object[]]$Tags.
The other two round-2 findings were rejected with evidence in the PR
comment: (a) adding Id to the Query parameter set would swap detail
representations for list representations on single-ID fetches; and
(b) moving AssertNBMutualExclusiveParam to begin{} contradicts the
actual repo convention established in PR #397/#400 where all 122
Get functions run it in process{}.
* docs(skill): add null-clearing enum pattern example to Set template
Gemini round 3 MEDIUM finding: Pitfalls table mentions the
[AllowEmptyString] + '' sentinel + translate-to-$null pattern from
PR #401, but the Set template doesn't demonstrate it. A user
following the template literally would have to assemble the pieces
from the pitfalls row.
Added a dedicated "SET — null-clearing for enum string parameters"
subsection after the basic Set template showing the complete pattern
(Set-NBDCIMInterface-style) with:
- [AllowEmptyString()] + [ValidateSet(..., '')]
- $PSBoundParameters translation loop BEFORE BuildURIComponents
- Inline comment explaining why the translation order matters
Kept the basic Set template lean since null-clearing is opt-in for
specific parameters that need it — not all Set cmdlets do.
The [Nullable[bool]] suggestion in round 3 was rejected: the entire
repo uses [bool] on Set-* boolean API fields (verified across
Set-NBEventRule, Set-NBIPAMAddressRange, Set-NBDCIMDevice, etc.)
because BuildURIComponents iterates $PSBoundParameters which only
contains user-bound values — unbound [bool] defaults never leak into
the PATCH body. See PR comment for the empirical reasoning.1 parent 63f3aea commit 00ad75b
2 files changed
Lines changed: 363 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
0 commit comments