Skip to content

feat: add rm/delete command to remove local skill images - #29

Merged
pavelanni merged 7 commits into
mainfrom
feature/rm-delete-command
Apr 30, 2026
Merged

pavelanni merged 7 commits into
mainfrom
feature/rm-delete-command

Conversation

@pavelanni

@pavelanni pavelanni commented Apr 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add skillctl rm (alias delete) to remove skill images from the local OCI store by name:tag reference
  • Support multiple refs in a single invocation with confirmation prompt (skippable via --force)
  • Add Client.Remove() method to pkg/oci backed by oras-go Untag()

Closes #22

Design decisions

  • Tag-based removal only (no digest or glob support in v1)
  • Blob cleanup deferred to existing skillctl prune
  • Pre-validates all refs before prompting for confirmation
  • Partial failure: reports errors per-ref, continues with remaining, exits non-zero if any failed

Test plan

  • TestRemove — build image, remove by ref, verify absent from ListLocal
  • TestRemoveNotFound — error on non-existent ref contains "not found"
  • TestRemoveMultipleImages — remove one of two images, verify other remains
  • go test ./... — all tests pass
  • make lint — 0 issues

Summary by CodeRabbit

  • New Features
    • Added a new rm command to remove locally stored skill images by name:tag reference
    • Supports removing multiple images in a single operation
    • Includes --force flag to skip confirmation prompts
    • Displays a confirmation prompt before removal (unless bypassed with --force)
    • Returns appropriate exit codes for success and partial/complete failure scenarios

Add three test cases for the Remove method (TDD red phase):
- TestRemove: remove an existing image
- TestRemoveNotFound: error on missing ref
- TestRemoveMultipleImages: remove one, keep another

Tests fail to compile as expected - client.Remove does not exist yet.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Closes #22

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@pavelanni has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 47 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 2085d267-0ff3-40de-a894-50fefd9f7c5a

📥 Commits

Reviewing files that changed from the base of the PR and between 65b468c and 5e46e24.

📒 Files selected for processing (3)
  • dev/plans/2026-04-30-rm-delete-command.md
  • dev/specs/2026-04-30-rm-delete-command-design.md
  • internal/cli/rm.go
📝 Walkthrough

Walkthrough

This pull request introduces a new rm command to skillctl for removing locally stored OCI skill images by name:tag reference. The implementation includes design documentation, a CLI command with confirmation prompts, a client method that resolves and untags references, and corresponding tests.

Changes

Cohort / File(s) Summary
Documentation & Planning
dev/plans/2026-04-30-rm-delete-command.md, dev/specs/2026-04-30-rm-delete-command-design.md
Design plan and specification for the rm/delete command feature, including CLI usage, confirmation flow, client method behavior, exit codes, and test requirements.
CLI Implementation
internal/cli/rm.go, internal/cli/root.go
New rm command that accepts image refs, enumerates local images, validates provided refs, prompts for confirmation unless --force is set, invokes client.Remove() for each valid ref, and reports successes/errors with aggregate failure handling. Command is registered in root CLI.
OCI Client & Tests
pkg/oci/remove.go, pkg/oci/remove_test.go
New Client.Remove() method that resolves a ref and untags it, returning "image not found" error for missing refs. Tests cover successful removal, non-existent refs, and multiple-image scenarios with a helper to generate test skill data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the primary change: adding an rm/delete command for removing local skill images.
Linked Issues check ✅ Passed The PR implements the core requirements from issue #22: skillctl rm command, confirmation prompts, and --force flag. However, it only supports name:tag removal, not digest/glob/namespace patterns as proposed.
Out of Scope Changes check ✅ Passed All changes are directly related to the rm/delete command feature: CLI implementation, OCI client method, tests, documentation, and command registration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/rm-delete-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 48 minutes and 47 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@pavelanni
pavelanni marked this pull request as ready for review April 30, 2026 20:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dev/plans/2026-04-30-rm-delete-command.md`:
- Line 21: The heading "### Task 1: Client.Remove method — test" jumps levels;
change it to a second-level heading by replacing "###" with "##" so heading
levels increment properly (update the markdown line containing "Client.Remove
method — test").

In `@dev/specs/2026-04-30-rm-delete-command-design.md`:
- Around line 26-28: The fenced code block containing the command usage
`skillctl rm <ref> [<ref>...] [flags]` is missing a language identifier; update
that fence in the markdown to include a language tag (for example add ```text or
```bash) so markdownlint MD040 is satisfied and the block renders
consistently—locate the fenced block in the spec file and change the opening
fence from ``` to a tagged fence like ```text or ```bash.

In `@internal/cli/rm.go`:
- Around line 41-42: Replace the use of process globals by switching the local
ctx := context.Background() to use the Cobra command context (cmd.Context()) and
replace direct reads from os.Stdin with cmd.InOrStdin() so
cancellations/timeouts and test-injected stdin are respected; update any
functions in this file that reference ctx or os.Stdin (e.g., the ctx variable
and the stdin usage around the confirmation/read logic in the rm command) to
accept/use cmd.Context() and cmd.InOrStdin().

In `@pkg/oci/remove.go`:
- Around line 16-18: The branch that checks errors.Is(err, errdef.ErrNotFound)
currently returns a plain error string which loses the original sentinel; update
that return to wrap the not-found sentinel using %w so callers can still detect
errdef.ErrNotFound (i.e., change the fmt.Errorf call in pkg/oci/remove.go to
include %w and wrap errdef.ErrNotFound, mirroring the other %w wraps in this
function).
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 38be9260-6716-44b8-9428-0371e6f9b420

📥 Commits

Reviewing files that changed from the base of the PR and between b11b6bc and 65b468c.

📒 Files selected for processing (6)
  • dev/plans/2026-04-30-rm-delete-command.md
  • dev/specs/2026-04-30-rm-delete-command-design.md
  • internal/cli/rm.go
  • internal/cli/root.go
  • pkg/oci/remove.go
  • pkg/oci/remove_test.go

Comment thread internal/cli/rm.go Resolved
Comment thread pkg/oci/remove.go
Comment on lines +16 to +18
if errors.Is(err, errdef.ErrNotFound) {
return fmt.Errorf("image not found: %s", ref)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In oras-go v2, is wrapping resolve errors with %wthe recommended way to preserveerrdef.ErrNotFoundclassification for callers usingerrors.Is?

💡 Result:

Yes—if ORAS Go v2 wraps underlying resolve errors while preserving the original error in the wrapping chain (by using fmt.Errorf("...: %w", err) or errors.Join), callers can use errors.Is(err, errdef.ErrNotFound) to classify not-found at higher layers. However, this depends on the exact wrapping implementation in the relevant ORAS v2 function(s): ORAS v2 does define a sentinel ErrNotFound in its errdef package, and it relies on Go error-wrapping semantics for classification. The library also uses structured error types with Unwrap (e.g., CopyError) so the underlying ErrNotFound can still be found via errors.Is/errors.As. Grounding in ORAS Go v2: - ORAS Go v2 defines ErrNotFound as a sentinel error value in its errdef package. - CopyError in the v3 codebase (pattern indicative of how ORAS preserves inner errors) implements Unwrap to return the underlying Err; this is what makes errors.Is work when the underlying error is errdef.ErrNotFound. Practical recommendation: - When ORAS Go v2 needs to add context while preserving classification, wrapping with %w (or otherwise preserving the original error as an unwrap target) is the correct approach. - Callers should use errors.Is(err, errdef.ErrNotFound) rather than direct equality, because the library may wrap errors to add context. Note: I did not find an ORAS v2-specific documentation statement explicitly saying “%w is recommended” for resolve errors. The conclusion is based on ORAS Go v2’s use of sentinel errdef.ErrNotFound and ORAS’s observable wrapping/unwrapping patterns that are compatible with Go’s errors.Is mechanism.

Citations:


🏁 Script executed:

# First, let's find and examine the remove.go file
fd -t f "remove.go" --exec wc -l {} \;

Repository: redhat-et/skillimage

Length of output: 87


🏁 Script executed:

# Read the file with context around lines 16-18
cat -n pkg/oci/remove.go | head -30

Repository: redhat-et/skillimage

Length of output: 900


Preserve the not-found sentinel when returning the custom error.

Line 17 returns a plain error string without wrapping, preventing callers from using errors.Is(err, errdef.ErrNotFound) for typed error handling. The function already wraps errors with %w on lines 19 and 23; line 17 should follow the same pattern.

Proposed fix
 	if _, err := c.store.Resolve(ctx, ref); err != nil {
 		if errors.Is(err, errdef.ErrNotFound) {
-			return fmt.Errorf("image not found: %s", ref)
+			return fmt.Errorf("image not found: %s: %w", ref, err)
 		}
 		return fmt.Errorf("resolving %s: %w", ref, err)
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/oci/remove.go` around lines 16 - 18, The branch that checks
errors.Is(err, errdef.ErrNotFound) currently returns a plain error string which
loses the original sentinel; update that return to wrap the not-found sentinel
using %w so callers can still detect errdef.ErrNotFound (i.e., change the
fmt.Errorf call in pkg/oci/remove.go to include %w and wrap errdef.ErrNotFound,
mirroring the other %w wraps in this function).

- Fix heading levels in plan doc (h3 → h2)
- Add language tag to fenced code block in spec
- Use cmd.Context() instead of context.Background()
- Use cmd.InOrStdin() instead of os.Stdin

Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni merged commit fa9fd65 into main Apr 30, 2026
5 checks passed
@pavelanni
pavelanni deleted the feature/rm-delete-command branch April 30, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add rm/delete command to remove local skill images

1 participant