Add generate-api-stubs skill to openshift plugin#468
Conversation
New skill to automate running `make generate` in openshift/api with iterative error detection and auto-fixing. Includes multi-repo workflow support for updating openshift/client-go vendoring and regeneration. Bumps openshift plugin version to 0.0.6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rvanderp3 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughBumps the ChangesOpenShift generate-api and supporting skill + docs & registry updates
sequenceDiagram
participant User
participant CLI as /openshift:generate-api
participant Make as make generate
participant Detector as detect_generation_errors.py
participant Validator as validate_generated_code.sh
User->>CLI: invoke /openshift:generate-api (api-repo-path [, --client-go])
CLI->>Make: run make generate
Make-->>Detector: stdout/stderr (piped)
Detector-->>CLI: JSON error classification
CLI->>CLI: attempt auto-fix loop (<=5) / run fix scripts
CLI->>Make: re-run make generate (if fixes applied)
Make-->>Validator: generated files
Validator-->>CLI: validation result (pass/fail, details)
CLI->>User: report modified files, errors/fixes, final status
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (9 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
❌ error (plugins-doc-up-to-date): PLUGINS.md is out of sync with plugin metadata. Run 'make update' to update.
There was a problem hiding this comment.
❌ error (plugins-doc-up-to-date): docs/data.json is out of sync with plugin metadata. Run 'make update' to update.
New `/openshift:generate-api` command that invokes the generate-api-stubs skill. Accepts optional path to openshift/api and a --client-go flag to also update and regenerate openshift/client-go. Bumps openshift plugin version to 0.0.7. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
plugins/openshift/skills/generate-api-stubs/scripts/check_working_directory.sh (1)
34-39: ⚡ Quick winAvoid assuming
originwhen identifying the repo remote.Using only
origincan generate false warnings when the canonical remote has a different name.Suggested adjustment
-REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "") -if [[ ! "$REMOTE_URL" =~ openshift/api ]]; then +REMOTE_URLS="$(git remote -v 2>/dev/null | awk '{print $2}' | sort -u)" +if ! grep -Eq 'github\.com[:/]+openshift/api(\.git)?$' <<< "$REMOTE_URLS"; then echo -e "${YELLOW}Warning: This doesn't appear to be the openshift/api repository${NC}" >&2 - echo "Remote URL: $REMOTE_URL" >&2 + echo "Remote URLs: $REMOTE_URLS" >&2 echo "Expected: *openshift/api*" >&2 fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/openshift/skills/generate-api-stubs/scripts/check_working_directory.sh` around lines 34 - 39, The script currently sets REMOTE_URL by querying only the "origin" remote; change it to detect any configured remote whose URL contains "openshift/api" (e.g. parse "git remote -v" or iterate `git remote` names) and set REMOTE_URL accordingly before the check; update the conditional that references REMOTE_URL in check_working_directory.sh so it doesn't emit a warning when a different remote name (not "origin") points to openshift/api.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/data.json`:
- Around line 674-677: The synopsis for the "list-repos" command is missing the
optional flag declared in argument_hint; update the "synopsis" field for the
JSON object with "name": "list-repos" to include the same " [--refresh]" suffix
so it matches the "argument_hint" value, ensuring both fields remain consistent.
In `@plugins/openshift/skills/generate-api-stubs/references/common_errors.md`:
- Around line 8-12: Several fenced signature blocks containing the lines "Types
need DeepCopy methods", "missing deepcopy-gen markers", and "DeepCopy method not
found for type X" (and other similar signature-only blocks) lack a fence
language and trigger MD040; update each of those fenced code blocks to use the
language tag "text" (i.e., replace ``` with ```text) so the blocks become
```text ... ```; search for each occurrence of the exact signature strings
(e.g., the three-line block shown and the other signature-only blocks with the
same pattern) and apply the same change to all listed occurrences.
In
`@plugins/openshift/skills/generate-api-stubs/scripts/validate_generated_code.sh`:
- Around line 82-88: The build log uses a fixed /tmp/validation-build.log which
can collide; change it to a unique temp file using mktemp (e.g.
TMP_LOG=$(mktemp)) before the go build call, redirect go build output to
"$TMP_LOG" (2>&1), reference "$TMP_LOG" when printing errors and set
VALIDATION_FAILED=1 as before, and ensure cleanup by removing the temp file (rm
-f "$TMP_LOG") or installing a trap 'trap "rm -f \"$TMP_LOG\"" EXIT' so the temp
log is removed after validate_generated_code.sh finishes; update any references
in this block to use the TMP_LOG variable instead of the fixed path.
In `@plugins/openshift/skills/generate-api-stubs/SKILL.md`:
- Around line 61-64: The GOPATH example in SKILL.md is incorrect: change the
Option C example so it shows that the repository must be placed under
GOPATH/src/github.com/openshift/api (not directly under GOPATH as
/home/user/repos/api) and update the example lines that currently read "export
GOPATH=/home/user/repos" and the following path to demonstrate the correct
layout (e.g., GOPATH=/home/user/repos with the repo at
$GOPATH/src/github.com/openshift/api), plus adjust the explanatory text to state
that the repo must live under src/github.com/openshift/api for the import path
github.com/openshift/api to resolve.
- Around line 38-39: The SKILL.md contains incorrect `${CLAUDE_PLUGIN_ROOT}`
path expansions that omit the skill subdirectory; update all occurrences to
include `skills/generate-api-stubs/` so the scripts and references point to the
correct skill folder: replace the entry for the check script referenced in the
README (`${CLAUDE_PLUGIN_ROOT}/scripts/check_working_directory.sh`) with
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/check_working_directory.sh`,
update the detect script reference
(`${CLAUDE_PLUGIN_ROOT}/scripts/detect_generation_errors.py`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/detect_generation_errors.py`,
change the common errors reference
(`${CLAUDE_PLUGIN_ROOT}/references/common_errors.md`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/references/common_errors.md`,
and update the validate script
(`${CLAUDE_PLUGIN_ROOT}/scripts/validate_generated_code.sh`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/validate_generated_code.sh`
so all paths match the pattern used by other plugins.
---
Nitpick comments:
In
`@plugins/openshift/skills/generate-api-stubs/scripts/check_working_directory.sh`:
- Around line 34-39: The script currently sets REMOTE_URL by querying only the
"origin" remote; change it to detect any configured remote whose URL contains
"openshift/api" (e.g. parse "git remote -v" or iterate `git remote` names) and
set REMOTE_URL accordingly before the check; update the conditional that
references REMOTE_URL in check_working_directory.sh so it doesn't emit a warning
when a different remote name (not "origin") points to openshift/api.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0e873985-631c-4209-8327-3d7f7bb43796
📒 Files selected for processing (9)
.claude-plugin/marketplace.jsonPLUGINS.mddocs/data.jsonplugins/openshift/.claude-plugin/plugin.jsonplugins/openshift/skills/generate-api-stubs/SKILL.mdplugins/openshift/skills/generate-api-stubs/references/common_errors.mdplugins/openshift/skills/generate-api-stubs/scripts/check_working_directory.shplugins/openshift/skills/generate-api-stubs/scripts/detect_generation_errors.pyplugins/openshift/skills/generate-api-stubs/scripts/validate_generated_code.sh
| "argument_hint": "[--refresh]", | ||
| "description": "Report on repository purpose and approvers for github.com/openshift", | ||
| "name": "list-repos", | ||
| "synopsis": "/teams:list-repos" |
There was a problem hiding this comment.
Keep command synopsis aligned with declared options.
Line 677 omits [--refresh] even though Line 674 declares it in argument_hint, which can confuse users relying on synopsis text.
Suggested fix
- "synopsis": "/teams:list-repos"
+ "synopsis": "/teams:list-repos [--refresh]"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "argument_hint": "[--refresh]", | |
| "description": "Report on repository purpose and approvers for github.com/openshift", | |
| "name": "list-repos", | |
| "synopsis": "/teams:list-repos" | |
| "argument_hint": "[--refresh]", | |
| "description": "Report on repository purpose and approvers for github.com/openshift", | |
| "name": "list-repos", | |
| "synopsis": "/teams:list-repos [--refresh]" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/data.json` around lines 674 - 677, The synopsis for the "list-repos"
command is missing the optional flag declared in argument_hint; update the
"synopsis" field for the JSON object with "name": "list-repos" to include the
same " [--refresh]" suffix so it matches the "argument_hint" value, ensuring
both fields remain consistent.
| ``` | ||
| Types need DeepCopy methods | ||
| missing deepcopy-gen markers | ||
| DeepCopy method not found for type X | ||
| ``` |
There was a problem hiding this comment.
Add fence languages to signature blocks to clear markdown lint.
Several fenced blocks omit a language identifier, triggering MD040 warnings.
Suggested fix pattern
-```
+```text
Types need DeepCopy methods
missing deepcopy-gen markers
DeepCopy method not found for type X
Apply the same `text` language annotation to all signature-only fenced blocks in this file.
</details>
Also applies to: 50-54, 100-104, 142-148, 181-185, 221-225, 243-248, 277-281, 305-309, 327-331, 358-361, 384-388, 421-424, 460-463
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>
[warning] 8-8: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @plugins/openshift/skills/generate-api-stubs/references/common_errors.md
around lines 8 - 12, Several fenced signature blocks containing the lines "Types
need DeepCopy methods", "missing deepcopy-gen markers", and "DeepCopy method not
found for type X" (and other similar signature-only blocks) lack a fence
language and trigger MD040; update each of those fenced code blocks to use the
language tag "text" (i.e., replace withtext) so the blocks become
text ... ; search for each occurrence of the exact signature strings
(e.g., the three-line block shown and the other signature-only blocks with the
same pattern) and apply the same change to all listed occurrences.
</details>
<!-- fingerprinting:phantom:poseidon:hawk -->
<!-- This is an auto-generated comment by CodeRabbit -->
| if go build ./... > /tmp/validation-build.log 2>&1; then | ||
| echo -e "${GREEN}✓${NC} Code compiles successfully" | ||
| else | ||
| echo -e "${RED}✗${NC} Compilation failed" | ||
| echo "Build errors:" | ||
| cat /tmp/validation-build.log | ||
| VALIDATION_FAILED=1 |
There was a problem hiding this comment.
Use a unique temp log file for build output.
A fixed /tmp/validation-build.log path is collision-prone across concurrent executions.
Suggested fix
+BUILD_LOG="$(mktemp -t validation-build.XXXXXX.log)"
+trap 'rm -f "$BUILD_LOG"' EXIT
...
-if go build ./... > /tmp/validation-build.log 2>&1; then
+if go build ./... > "$BUILD_LOG" 2>&1; then
echo -e "${GREEN}✓${NC} Code compiles successfully"
else
echo -e "${RED}✗${NC} Compilation failed"
echo "Build errors:"
- cat /tmp/validation-build.log
+ cat "$BUILD_LOG"
VALIDATION_FAILED=1
fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@plugins/openshift/skills/generate-api-stubs/scripts/validate_generated_code.sh`
around lines 82 - 88, The build log uses a fixed /tmp/validation-build.log which
can collide; change it to a unique temp file using mktemp (e.g.
TMP_LOG=$(mktemp)) before the go build call, redirect go build output to
"$TMP_LOG" (2>&1), reference "$TMP_LOG" when printing errors and set
VALIDATION_FAILED=1 as before, and ensure cleanup by removing the temp file (rm
-f "$TMP_LOG") or installing a trap 'trap "rm -f \"$TMP_LOG\"" EXIT' so the temp
log is removed after validate_generated_code.sh finishes; update any references
in this block to use the TMP_LOG variable instead of the fixed path.
| - Run `${CLAUDE_PLUGIN_ROOT}/scripts/check_working_directory.sh` from the openshift/api repository | ||
| - This script validates that the repository is in the correct Go workspace structure |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "References used in this skill:"
rg -n '\$\{CLAUDE_PLUGIN_ROOT\}/(scripts|references)/' plugins/openshift/skills/generate-api-stubs/SKILL.md
echo
echo "Actual files added for this skill:"
fd -p check_working_directory.sh
fd -p detect_generation_errors.py
fd -p validate_generated_code.sh
fd -p common_errors.mdRepository: openshift-eng/ai-helpers
Length of output: 823
🏁 Script executed:
# Check how CLAUDE_PLUGIN_ROOT is used in other plugins/skills
rg -n 'CLAUDE_PLUGIN_ROOT' plugins/ -t md | head -30
# Look for plugin initialization or environment setup
fd -p 'plugin.json' plugins/ -x cat {}
# Check if there's documentation about variable resolution
fd -p 'README.md' plugins/openshift/ -x cat {}Repository: openshift-eng/ai-helpers
Length of output: 27789
Fix path references to include the skill directory name in all ${CLAUDE_PLUGIN_ROOT} expansions.
The current references assume scripts and references are at the plugin root, but they are located in the skill-specific subdirectory. Based on the pattern used in other plugins (e.g., git/skills/suggest-reviewers references ${CLAUDE_PLUGIN_ROOT}/skills/suggest-reviewers/...), the paths must include skills/generate-api-stubs/:
- Line 38: Change
${CLAUDE_PLUGIN_ROOT}/scripts/check_working_directory.shto${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/check_working_directory.sh - Line 90: Change
${CLAUDE_PLUGIN_ROOT}/scripts/detect_generation_errors.pyto${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/detect_generation_errors.py - Line 94: Change
${CLAUDE_PLUGIN_ROOT}/references/common_errors.mdto${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/references/common_errors.md - Line 169: Change
${CLAUDE_PLUGIN_ROOT}/scripts/validate_generated_code.shto${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/validate_generated_code.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@plugins/openshift/skills/generate-api-stubs/SKILL.md` around lines 38 - 39,
The SKILL.md contains incorrect `${CLAUDE_PLUGIN_ROOT}` path expansions that
omit the skill subdirectory; update all occurrences to include
`skills/generate-api-stubs/` so the scripts and references point to the correct
skill folder: replace the entry for the check script referenced in the README
(`${CLAUDE_PLUGIN_ROOT}/scripts/check_working_directory.sh`) with
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/check_working_directory.sh`,
update the detect script reference
(`${CLAUDE_PLUGIN_ROOT}/scripts/detect_generation_errors.py`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/detect_generation_errors.py`,
change the common errors reference
(`${CLAUDE_PLUGIN_ROOT}/references/common_errors.md`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/references/common_errors.md`,
and update the validate script
(`${CLAUDE_PLUGIN_ROOT}/scripts/validate_generated_code.sh`) to
`${CLAUDE_PLUGIN_ROOT}/skills/generate-api-stubs/scripts/validate_generated_code.sh`
so all paths match the pattern used by other plugins.
| # If repo is at /home/user/repos/api | ||
| export GOPATH=/home/user/repos | ||
| # Now the import path github.com/openshift/api resolves correctly | ||
| ``` |
There was a problem hiding this comment.
Correct the GOPATH example in Option C.
This example is incorrect: setting GOPATH=/home/user/repos does not make /home/user/repos/api resolve as github.com/openshift/api; the repo must still live under src/github.com/openshift/api.
Suggested correction
-# If repo is at /home/user/repos/api
-export GOPATH=/home/user/repos
-# Now the import path github.com/openshift/api resolves correctly
+# If repo is at /home/user/repos/src/github.com/openshift/api
+export GOPATH=/home/user/repos
+# The import path github.com/openshift/api now resolves correctly🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@plugins/openshift/skills/generate-api-stubs/SKILL.md` around lines 61 - 64,
The GOPATH example in SKILL.md is incorrect: change the Option C example so it
shows that the repository must be placed under
GOPATH/src/github.com/openshift/api (not directly under GOPATH as
/home/user/repos/api) and update the example lines that currently read "export
GOPATH=/home/user/repos" and the following path to demonstrate the correct
layout (e.g., GOPATH=/home/user/repos with the repo at
$GOPATH/src/github.com/openshift/api), plus adjust the explanatory text to state
that the repo must live under src/github.com/openshift/api for the import path
github.com/openshift/api to resolve.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/data.json (1)
673-678:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winKeep
synopsisaligned withargument_hintforteams:list-repos.Line 674 declares
[--refresh], but Line 677 omits it fromsynopsis, creating inconsistent command metadata.Proposed fix
- "synopsis": "/teams:list-repos" + "synopsis": "/teams:list-repos [--refresh]"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/data.json` around lines 673 - 678, The metadata for the "list-repos" command has an argument_hint of "[--refresh]" but the synopsis omits it; update the "list-repos" entry (look for the object with "name": "list-repos") so its "synopsis" includes the same "[--refresh]" token (e.g., "/teams:list-repos [--refresh]") to keep argument_hint and synopsis consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugins/openshift/commands/generate-api.md`:
- Around line 10-12: Add a language identifier (e.g., "text") to every fenced
code block that contains the /openshift:generate-api usage examples so
markdownlint MD040 is satisfied; update the top usage block and each example
block that contains "/openshift:generate-api" (the header usage and Example 1–4
command fences) from triple backticks with no language to triple backticks with
"text".
---
Duplicate comments:
In `@docs/data.json`:
- Around line 673-678: The metadata for the "list-repos" command has an
argument_hint of "[--refresh]" but the synopsis omits it; update the
"list-repos" entry (look for the object with "name": "list-repos") so its
"synopsis" includes the same "[--refresh]" token (e.g., "/teams:list-repos
[--refresh]") to keep argument_hint and synopsis consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0c1732b5-936e-485e-9a7f-cc3ebb0c9b9d
📒 Files selected for processing (5)
.claude-plugin/marketplace.jsonPLUGINS.mddocs/data.jsonplugins/openshift/.claude-plugin/plugin.jsonplugins/openshift/commands/generate-api.md
✅ Files skipped from review due to trivial changes (2)
- plugins/openshift/.claude-plugin/plugin.json
- .claude-plugin/marketplace.json
| ``` | ||
| /openshift:generate-api [api-repo-path] [--client-go [client-go-path]] | ||
| ``` |
There was a problem hiding this comment.
Add language identifiers to fenced code blocks.
markdownlint MD040 is triggered on these fences; this can fail docs lint in CI.
Proposed fix
## Synopsis
-```
+```text
/openshift:generate-api [api-repo-path] [--client-go [client-go-path]]Example 1: Generate from current directory
- +text
/openshift:generate-api
### Example 2: Generate from a specific path
-```
+```text
/openshift:generate-api ~/code/api
Example 3: Generate API and update client-go
- +text
/openshift:generate-api ~/code/api --client-go ~/code/client-go
### Example 4: Generate API and auto-detect client-go
-```
+```text
/openshift:generate-api --client-go
</details>
Also applies to: 73-75, 79-81, 85-87, 91-93
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>
[warning] 10-10: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
</details>
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @plugins/openshift/commands/generate-api.md around lines 10 - 12, Add a
language identifier (e.g., "text") to every fenced code block that contains the
/openshift:generate-api usage examples so markdownlint MD040 is satisfied;
update the top usage block and each example block that contains
"/openshift:generate-api" (the header usage and Example 1–4 command fences) from
triple backticks with no language to triple backticks with "text".
</details>
<!-- fingerprinting:phantom:triton:hawk -->
<!-- This is an auto-generated comment by CodeRabbit -->
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
New skill to automate running
make generatein openshift/api with iterative error detection and auto-fixing. Includes multi-repo workflow support for updating openshift/client-go vendoring and regeneration.Bumps openshift plugin version to 0.0.6.
What this PR does / why we need it:
Which issue(s) this PR fixes:
Summary by CodeRabbit
New Features
Documentation
Updates