Skip to content

Add devbox skill command and offer it on devbox init - #3139

Open
mikeland73 wants to merge 3 commits into
mainfrom
claude/elegant-darwin-qf3nx6
Open

mikeland73 wants to merge 3 commits into
mainfrom
claude/elegant-darwin-qf3nx6

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

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 a devbox.json. It covers:

  • running commands through devbox run and project scripts
  • adding tools with devbox add rather than brew, apt or global installs
  • when to use the built-in plugins and services, and when to disable a plugin or write your own
  • fixing native library and compatibility problems: missing headers or libs, --outputs=out,dev, LD_LIBRARY_PATH with $DEVBOX_PACKAGES_DIR, "patch": "always" for glibc, macOS linker errors, --allow-insecure

The skill is 121 lines and a test keeps it under 200.

New commands

  • devbox skill install [--scope project|user|all] [-f] (the default scope is all)
    • project writes .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.
    • user writes the same paths under $HOME and honors CLAUDE_CONFIG_DIR.
    • Files are copied, not symlinked, so they commit cleanly and work on Windows. If .claude/skills is a symlink to .agents/skills, as in this repo, the file is written once.
    • The frontmatter carries metadata.managed-by: devbox and devbox-version. Running install again updates a file devbox wrote. A SKILL.md the user wrote is left alone unless --force is passed.
  • devbox skill uninstall removes only files devbox manages.
  • devbox skill show prints the skill.

devbox init

  • In an interactive terminal (not CI), init asks whether to install the skill for the project and user, the project only, or not at all.
  • --skill all|project|user|none skips the prompt. An invalid value fails before devbox.json is created.

This repo

  • The hand-written .agents/skills/use-devbox is replaced by the generated devbox skill.

The layout follows Vercel's skills CLI (a canonical .agents/skills plus agent-specific directories), glab skills install (no overwrite without --force) and gh skill install (--scope project|user, provenance recorded in frontmatter metadata).

How was it tested?

  • Unit tests in internal/skill:
    • frontmatter validity and size limit
    • install, update and uninstall
    • user-authored files are kept
    • symlinked skills directory
    • CLAUDE_CONFIG_DIR
  • New testscript testscripts/skill/skill.test.txt covering install, show, uninstall, init --skill and invalid values.
  • Drove the interactive devbox init prompt 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/skill all pass.
  • Not run: 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

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
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous findings are fixed and no new actionable issues remain.

Summary

Adds a bundled agent skill and commands to install, remove, or print it.

  • The Devbox skill now guides agents through packages, services, and native-library fixes.
  • Devbox can install, show, and remove its agent skill.
  • Devbox init can install the agent skill after creating a project.

No new actionable issues were found. Both numbered previous findings are fixed.

Reviews (2) · Last reviewed commit: "skill: don't write through symlinks; fix..." · Reviewed by Greptile

@claude

claude Bot commented Nov 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Comment thread internal/skill/skill.go Outdated
Comment on lines +139 to +142
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return results, err
}
if err := os.WriteFile(path, content, 0o644); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security 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.

Fix in Claude Code

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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/skills or .agents/skills/devbox. Links between skills directories inside the project, such as .claude/skills -> ../.agents/skills, still work.
  • A SKILL.md that 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: TestInstallDoesNotWriteThroughSymlinks and TestInstallRejectsSkillDirOutsideProject.

Leaving this thread open for a maintainer to confirm.


Generated by Claude Code

Comment thread internal/skill/SKILL.md Resolved
Comment thread internal/skill/SKILL.md Resolved
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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants