Repository navigation
Add devbox skill command and offer it on devbox init - #3139
mikeland73 wants to merge 3 commits into
Conversation
Adds an embedded Agent Skills SKILL.md that teaches coding agents to use devbox whenever a project has a devbox.json: run commands through `devbox run`, add tools with `devbox add`, prefer plugins and services over hand-rolled setup, and fix native library and compatibility issues. - `devbox skill install|uninstall|show`, with --scope project|user|all. Project installs write .agents/skills/devbox (Codex, Cursor, Copilot, Gemini, ...) and .claude/skills/devbox (Claude Code); user installs write the same under $HOME (honoring CLAUDE_CONFIG_DIR). Files are marked as managed by devbox so reinstalling updates them, while a SKILL.md the user wrote is left alone unless --force. - `devbox init` asks whether to install the skill when interactive, or takes --skill all|project|user|none. - Replaces this repo's hand-written use-devbox skill with the generated one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bqy92qDG5cjWA8disWEwCM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bqy92qDG5cjWA8disWEwCM
[Medium impact] The PR appears safe to merge; the previous findings are fixed and no new actionable issues remain.
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
| if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { | ||
| return results, err | ||
| } | ||
| if err := os.WriteFile(path, content, 0o644); err != nil { |
There was a problem hiding this comment.
Links can overwrite unrelated files
Install follows a repository's SKILL.md symlink when writing. If .agents/skills/devbox/SKILL.md points to a user's shell startup file, devbox skill install --scope project --force truncates that file instead of replacing the project link. A dangling link to a writable target is followed even without --force.
Reject destinations outside the selected scope and replace final-file symlinks rather than writing through them. Links between skills directories inside the project can still be supported.
How this was verified: The install command passes --force into Install, which writes through the supplied path; resolve only removes duplicate destinations and never checks where the write lands.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/skill/skill.go
Line: 139-142
Comment:
**Links can overwrite unrelated files**
`Install` follows a repository's `SKILL.md` symlink when writing. If `.agents/skills/devbox/SKILL.md` points to a user's shell startup file, `devbox skill install --scope project --force` truncates that file instead of replacing the project link. A dangling link to a writable target is followed even without `--force`.
Reject destinations outside the selected scope and replace final-file symlinks rather than writing through them. Links between skills directories inside the project can still be supported.
**How this was verified:** The install command passes `--force` into `Install`, which writes through the supplied path; `resolve` only removes duplicate destinations and never checks where the write lands.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Confirmed and fixed in 65b6512:
- Project-scope install and uninstall now refuse any destination that resolves outside the project root, for example a symlinked
.agents/skillsor.agents/skills/devbox. Links between skills directories inside the project, such as.claude/skills -> ../.agents/skills, still work. - A
SKILL.mdthat is itself a symlink counts as user-owned, so install skips it. With--force, the file is written to a temp file and renamed into place, which replaces the link rather than writing through it. Dangling links are never followed. - New tests cover both cases:
TestInstallDoesNotWriteThroughSymlinksandTestInstallRejectsSkillDirOutsideProject.
Leaving this thread open for a maintainer to confirm.
Generated by Claude Code
Install now refuses project destinations that resolve outside the project and replaces a symlinked SKILL.md with a regular file (via rename) rather than writing through it; a symlinked SKILL.md is treated as user-owned unless --force. Uninstall gets the same containment check. The skill now says the Python venv must be activated (or called directly), and that Corepack needs DEVBOX_COREPACK_ENABLED=1 (plus the corepack package on Node 25+ and nodejs-slim). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bqy92qDG5cjWA8disWEwCM
Summary
Adds a devbox agent skill (an Agent Skills
SKILL.md) built into the binary. The skill tells coding agents to use devbox whenever a project has adevbox.json. It covers:devbox runand project scriptsdevbox addrather than brew, apt or global installs--outputs=out,dev,LD_LIBRARY_PATHwith$DEVBOX_PACKAGES_DIR,"patch": "always"for glibc, macOS linker errors,--allow-insecureThe skill is 121 lines and a test keeps it under 200.
New commands
devbox skill install [--scope project|user|all] [-f](the default scope isall)projectwrites.agents/skills/devbox/SKILL.md, used by Codex, Cursor, Copilot, Gemini, OpenCode and Amp. It also writes.claude/skills/devbox/SKILL.md, because Claude Code only reads that path. These files are meant to be committed.userwrites the same paths under$HOMEand honorsCLAUDE_CONFIG_DIR..claude/skillsis a symlink to.agents/skills, as in this repo, the file is written once.metadata.managed-by: devboxanddevbox-version. Running install again updates a file devbox wrote. ASKILL.mdthe user wrote is left alone unless--forceis passed.devbox skill uninstallremoves only files devbox manages.devbox skill showprints the skill.devbox init--skill all|project|user|noneskips the prompt. An invalid value fails beforedevbox.jsonis created.This repo
.agents/skills/use-devboxis replaced by the generateddevboxskill.The layout follows Vercel's
skillsCLI (a canonical.agents/skillsplus agent-specific directories),glab skills install(no overwrite without--force) andgh skill install(--scope project|user, provenance recorded in frontmatter metadata).How was it tested?
internal/skill:CLAUDE_CONFIG_DIRtestscripts/skill/skill.test.txtcovering install, show, uninstall,init --skilland invalid values.devbox initprompt in a pseudo-terminal, chose "Only this project" and confirmed both files were created.go build ./...,go vet,go test ./internal/boxcli ./internal/skill ./testscripts -run TestScripts/skillall pass.golangci-lint. The local install was built with Go 1.25 and can't load this module (Go 1.27).Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
Generated by Claude Code