Skip to content

Commit f3acde2

Browse files
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).
1 parent 6ef3167 commit f3acde2

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

  • .claude/skills/new-netbox-endpoint

.claude/skills/new-netbox-endpoint/SKILL.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: new-netbox-endpoint
3-
description: Use when adding a new NetBox REST API endpoint to PowerNetbox as a set of PowerShell cmdlets (Get / New / Set / Remove). Covers function templates, parameter conventions, test patterns, ValidateSet parity checks, and the PS 5.1 / Nullable / Tags gotchas that recur on this codebase.
3+
description: Use when adding or porting a PowerShell cmdlet that wraps a NetBox REST API endpoint in PowerNetbox — creating a Get-NB, New-NB, Set-NB, or Remove-NB function for a new or missing resource, touching a ValidateSet on an existing one, or writing the matching Pester tests.
44
---
55

66
# Adding a new NetBox endpoint to PowerNetbox
@@ -52,6 +52,15 @@ logging (never `Write-Host` in non-interactive paths).
5252

5353
### GET
5454

55+
Add query filter parameters (`-Label`, `-Parent`, `-Status`, etc.) inside
56+
the `ParameterSet = 'Query'` group — they flow through `BuildURIComponents`
57+
automatically and appear as `?name=value` query params. Match the NetBox
58+
API field name one-to-one (e.g. API field `mark_utilized` → PS param
59+
`Mark_Utilized`; snake→PascalCase via underscore). Type-check each:
60+
numeric IDs as `[uint64]`, booleans as `[bool]` (never `[switch]`), arrays
61+
as `[string[]]` or `[uint64[]]` depending on whether the API filter
62+
expects names or IDs.
63+
5564
```powershell
5665
function Get-NB[Module][Resource] {
5766
[CmdletBinding(DefaultParameterSetName = 'Query')]
@@ -63,6 +72,10 @@ function Get-NB[Module][Resource] {
6372
[uint64[]]$Id,
6473
[Parameter(ParameterSetName = 'Query')]
6574
[string]$Name,
75+
# [Parameter(ParameterSetName = 'Query')]
76+
# [string]$Status, # <-- filter params go here
77+
# [Parameter(ParameterSetName = 'Query')]
78+
# [uint64]$Site_Id,
6679
[uint16]$Limit,
6780
[uint16]$Offset,
6881
[switch]$Brief,
@@ -71,12 +84,13 @@ function Get-NB[Module][Resource] {
7184
[switch]$Raw
7285
)
7386
process {
74-
# Enforce mutual exclusion — user can pick ONE projection strategy.
75-
# See Functions/Helpers/AssertNBMutualExclusiveParam.ps1 (PR #397/#400).
87+
# MANDATORY on every Get cmdlet since PR #397/#400.
88+
# User picks exactly one projection — Brief, Fields, OR Omit.
7689
AssertNBMutualExclusiveParam `
7790
-BoundParameters $PSBoundParameters `
7891
-Parameters 'Brief', 'Fields', 'Omit'
7992
93+
Write-Verbose "Retrieving <Resource>"
8094
switch ($PSCmdlet.ParameterSetName) {
8195
'ByID' {
8296
foreach ($i in $Id) {
@@ -105,10 +119,14 @@ function New-NB[Module][Resource] {
105119
param (
106120
[Parameter(Mandatory)]
107121
[string]$Name,
108-
[object[]]$Tags, # prefer [object[]] over [string[]] / [uint64[]] — see Pitfalls
122+
# Prefer [object[]] for Tags — it accepts both IDs (uint64) and
123+
# strings. Older cmdlets use [string[]] or [uint64[]] and are
124+
# kept as-is for back-compat, but new code should use [object[]].
125+
[object[]]$Tags,
109126
[switch]$Raw
110127
)
111128
process {
129+
Write-Verbose "Creating <Resource>: $Name"
112130
$Segments = [System.Collections.ArrayList]::new(@('<module>', '<resource>'))
113131
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() `
114132
-ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
@@ -133,6 +151,7 @@ function Set-NB[Module][Resource] {
133151
[switch]$Raw
134152
)
135153
process {
154+
Write-Verbose "Updating <Resource> ID $Id"
136155
$Segments = [System.Collections.ArrayList]::new(@('<module>', '<resource>', $Id))
137156
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() `
138157
-ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
@@ -157,6 +176,7 @@ function Remove-NB[Module][Resource] {
157176
[switch]$Raw
158177
)
159178
process {
179+
Write-Verbose "Deleting <Resource> ID $Id"
160180
if ($PSCmdlet.ShouldProcess($Id, 'Delete <Resource>')) {
161181
InvokeNetboxRequest `
162182
-URI (BuildNewURI -Segments @('<module>', '<resource>', $Id)) `

0 commit comments

Comments
 (0)