Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var skillsCmd = &cobra.Command{
Use: "skills",
Short: "Manage Render agent skills for AI coding tools",
Long: `Install and manage Render agent skills for AI coding tools such as Claude Code, Codex, OpenCode, and Cursor. Skills add deployment, debugging, and monitoring capabilities to your AI coding assistant.`,
Long: `Install and manage Render agent skills for AI coding tools such as Claude Code, Codex, OpenCode, and Cursor (now Grok Build). Skills add deployment, debugging, and monitoring capabilities to your AI coding assistant.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
if !command.IsInteractive(ctx) {
Expand Down
42 changes: 35 additions & 7 deletions cmd/skillsinstall.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"os"
"path/filepath"

"github.com/spf13/cobra"

"github.com/render-oss/cli/pkg/command"
Expand All @@ -23,7 +26,7 @@ var skillsInstallCmd = &cobra.Command{
Short: "Install Render skills to AI coding tools",
Long: `Install Render agent skills from https://github.com/render-oss/skills to detected AI coding tools.

Supported tools: Claude Code, Codex, OpenCode, Cursor.
Supported tools: Claude Code, Codex, OpenCode, Cursor (now Grok Build).

Skills can be installed at two scopes:
- user: Install to ~/.{tool}/skills/ (default, current user only)
Expand All @@ -43,7 +46,7 @@ By default an interactive prompt lets you pick scope, tools, and skills. Use --s

func init() {
skillsCmd.AddCommand(skillsInstallCmd)
skillsInstallCmd.Flags().String("tool", "", "Install skills to a specific tool only (claude, codex, opencode, or cursor)")
skillsInstallCmd.Flags().String("tool", "", "Install skills to a specific tool only (claude, codex, opencode, cursor, or grok)")
skillsInstallCmd.Flags().StringSlice("skill", nil, "Install specific skills only (use --skill multiple times)")
skillsInstallCmd.Flags().Bool("dry-run", false, "Show what would be installed without making changes")
skillsInstallCmd.Flags().String("scope", "", "Set installation scope to user or project (defaults to user)")
Expand Down Expand Up @@ -76,11 +79,7 @@ func init() {
Scope: scope,
})
}, func(r *skills.InstallResult) string {
action := "Installed"
if r.DryRun {
action = "Would install"
}
return text.FormatStringF("%s %d skill(s) to %d tool(s)", action, len(r.Skills), len(r.Tools))
return formatInstallResult(r, scope)
}); err != nil {
return err
} else if nonInteractive {
Expand Down Expand Up @@ -108,3 +107,32 @@ func interactiveSkillsInstall(cmd *cobra.Command, input SkillsInstallInput, scop
Breadcrumb: "Install Skills",
})
}

// formatInstallResult describes an install for text output. With one tool it
// names the skills directory: relative to the current directory for project
// scope, and with ~ for the home directory otherwise.
func formatInstallResult(r *skills.InstallResult, scope skills.Scope) string {
action := "Installed"
if r.DryRun {
action = "Would install"
}
if len(r.Tools) != 1 {
return text.FormatStringF("%s %d skill(s) to %d tool(s)", action, len(r.Skills), len(r.Tools))
}

dir := r.Tools[0].SkillsDir
if scope == skills.ScopeProject {
if wd, err := os.Getwd(); err == nil {
// The repository root comes from git with symlinks resolved.
if resolved, err := filepath.EvalSymlinks(wd); err == nil {
wd = resolved
}
if rel, err := filepath.Rel(wd, dir); err == nil {
dir = rel
}
}
} else {
dir = skills.ShortenPath(dir)
}
return text.FormatStringF("%s %d skill(s) to %s", action, len(r.Skills), dir)
}
91 changes: 91 additions & 0 deletions cmd/skillsinstall_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package cmd

import (
"os"
"path/filepath"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/render-oss/cli/pkg/skills"
)

func TestFormatInstallResult(t *testing.T) {
home, err := os.UserHomeDir()
require.NoError(t, err)
repoRoot := t.TempDir()
t.Chdir(repoRoot)

twoSkills := []skills.SkillInfo{{Name: "render-deploy"}, {Name: "render-debug"}}
userDir := filepath.Join(home, ".cursor", "skills")
projectDir := filepath.Join(repoRoot, ".grok", "skills")
shortUserDir := "~/.cursor/skills"
if runtime.GOOS == "windows" {
shortUserDir = userDir // ShortenPath leaves Windows paths unchanged
}

tests := []struct {
name string
result skills.InstallResult
scope skills.Scope
want string
}{
{
name: "one tool, user scope",
result: skills.InstallResult{Skills: twoSkills, Tools: []skills.Tool{{Name: "Grok Build", SkillsDir: userDir}}},
scope: skills.ScopeUser,
want: "Installed 2 skill(s) to " + shortUserDir + "\n",
},
{
name: "one tool, project scope",
result: skills.InstallResult{Skills: twoSkills, Tools: []skills.Tool{{Name: "Grok Build", SkillsDir: projectDir}}},
scope: skills.ScopeProject,
want: "Installed 2 skill(s) to " + filepath.Join(".grok", "skills") + "\n",
},
{
name: "dry run",
result: skills.InstallResult{Skills: twoSkills, Tools: []skills.Tool{{Name: "Grok Build", SkillsDir: projectDir}}, DryRun: true},
scope: skills.ScopeProject,
want: "Would install 2 skill(s) to " + filepath.Join(".grok", "skills") + "\n",
},
{
name: "several tools",
result: skills.InstallResult{Skills: twoSkills, Tools: []skills.Tool{
{Name: "Claude Code", SkillsDir: filepath.Join(home, ".claude", "skills")},
{Name: "Grok Build", SkillsDir: userDir},
}},
scope: skills.ScopeUser,
want: "Installed 2 skill(s) to 2 tool(s)\n",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, formatInstallResult(&tt.result, tt.scope))
})
}
}

// The repository root comes from git with symlinks resolved, so a current
// directory reached through a symlink must be resolved too.
func TestFormatInstallResult_SymlinkedWorkingDirectory(t *testing.T) {
repoRoot, err := filepath.EvalSymlinks(t.TempDir())
require.NoError(t, err)
require.NoError(t, os.MkdirAll(filepath.Join(repoRoot, "sub"), 0o755))
link := filepath.Join(t.TempDir(), "link")
if err := os.Symlink(repoRoot, link); err != nil {
t.Skipf("symlinks unavailable: %v", err)
}
t.Chdir(filepath.Join(link, "sub"))

result := skills.InstallResult{
Skills: []skills.SkillInfo{{Name: "render-deploy"}},
Tools: []skills.Tool{{Name: "Grok Build", SkillsDir: filepath.Join(repoRoot, ".grok", "skills")}},
}

got := formatInstallResult(&result, skills.ScopeProject)

assert.Equal(t, "Installed 1 skill(s) to "+filepath.Join("..", ".grok", "skills")+"\n", got)
}
12 changes: 2 additions & 10 deletions cmd/skillsremove.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Use --scope to remove from a specific scope (user or project).`,
func init() {
skillsCmd.AddCommand(skillsRemoveCmd)
skillsRemoveCmd.Flags().StringSlice("skill", nil, "Remove specific skills only (use --skill multiple times)")
skillsRemoveCmd.Flags().String("tool", "", "Remove skills from a specific tool only (claude, codex, opencode, or cursor)")
skillsRemoveCmd.Flags().String("tool", "", "Remove skills from a specific tool only (claude, codex, opencode, cursor, or grok)")
skillsRemoveCmd.Flags().Bool("all", false, "Remove all installed Render skills")
skillsRemoveCmd.Flags().String("scope", "", "Remove skills from the specified scope (user or project)")
setFlagPlaceholder(skillsRemoveCmd.Flags(), "skill", "SKILL")
Expand Down Expand Up @@ -121,22 +121,14 @@ func nonInteractiveSkillsRemove(cmd *cobra.Command, skillFilter []string, toolFi
}

// Filter tools.
detectedMap := make(map[string]skills.Tool, len(detectedTools))
for _, t := range detectedTools {
detectedMap[t.Name] = t
}
var selectedTools []skills.Tool
if toolFilter != "" {
selectedTools = skills.FilterTools(detectedTools, toolFilter)
if len(selectedTools) == 0 {
return fmt.Errorf("no installed tool matching %q found", toolFilter)
}
} else {
for _, name := range state.Tools {
if t, ok := detectedMap[name]; ok {
selectedTools = append(selectedTools, t)
}
}
selectedTools = skills.IntersectToolsByState(detectedTools, state)
}
if len(selectedTools) == 0 {
return fmt.Errorf("no matching tools found")
Expand Down
115 changes: 106 additions & 9 deletions pkg/skills/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
Expand All @@ -21,6 +22,12 @@ const (
repoHTTPS = "https://github.com/render-oss/skills.git"
)

// Cursor is now Grok Build; saved names and --tool cursor still match it.
const (
cursorName = "Cursor"
grokBuildName = "Grok Build"
)

// Tool represents an AI coding tool that supports skills.
type Tool struct {
Name string
Expand All @@ -36,6 +43,14 @@ func DetectTools() ([]Tool, error) {
return nil, fmt.Errorf("failed to determine home directory: %w", err)
}

return detectTools(home, exec.LookPath), nil
}

// detectTools implements DetectTools for the given home directory. lookPath
// finds an installed command, as exec.LookPath does.
func detectTools(home string, lookPath func(file string) (string, error)) []Tool {
cursorToolName, cursorDir := cursorTool(home, lookPath)

candidates := []struct {
name string
parentDir string
Expand All @@ -58,7 +73,7 @@ func DetectTools() ([]Tool, error) {
{"Command Code", filepath.Join(home, ".commandcode"), filepath.Join(home, ".commandcode", "skills")},
{"Continue", filepath.Join(home, ".continue"), filepath.Join(home, ".continue", "skills")},
{"Crush", filepath.Join(home, ".config", "crush"), filepath.Join(home, ".config", "crush", "skills")},
{"Cursor", filepath.Join(home, ".cursor"), filepath.Join(home, ".cursor", "skills")},
{cursorToolName, cursorDir, filepath.Join(cursorDir, "skills")},
{"Droid", filepath.Join(home, ".factory"), filepath.Join(home, ".factory", "skills")},
{"Gemini CLI", filepath.Join(home, ".gemini"), filepath.Join(home, ".gemini", "skills")},
{"GitHub Copilot", filepath.Join(home, ".copilot"), filepath.Join(home, ".copilot", "skills")},
Expand Down Expand Up @@ -103,7 +118,48 @@ func DetectTools() ([]Tool, error) {
})
}

return tools, nil
return tools
}

// cursorTool returns the name and config directory of Cursor, which is now
// Grok Build. The Grok Build desktop app keeps its files in ~/.cursor and
// installs a grok-build command; without that command, ~/.cursor is still
// detected as Cursor, even with the Grok CLI: it reads ~/.cursor/skills by
// default. The Grok CLI is recognized by ~/.grok/config.toml, since other
// tools also use ~/.grok. Render skills already in ~/.grok/skills keep Grok
// Build there either way. An empty parentDir means neither is present.
func cursorTool(home string, lookPath func(file string) (string, error)) (name, parentDir string) {
cursorDir := filepath.Join(home, ".cursor")
grokDir := filepath.Join(home, ".grok")
_, err := lookPath("grok-build")
hasGrokBuildCmd := err == nil
hasGrokSkills := hasRenderSkills(filepath.Join(grokDir, "skills"))
if !hasGrokBuildCmd && !hasGrokSkills && dirExists(cursorDir) {
return cursorName, cursorDir
}
if !dirExists(cursorDir) && !hasGrokSkills && !fileExists(filepath.Join(grokDir, "config.toml")) {
return grokBuildName, ""
}
return grokBuildName, grokBuildDir(home)
}

// grokBuildDir returns the directory Grok Build's skills go in under root, a
// home directory or repository root. Grok Build reads skills from both .cursor
// and .grok, its CLI's own directory. Where root already has .cursor, it stays
// in use, unless Render skills are already in .grok/skills, so installed
// skills are neither left behind nor copied a second time.
func grokBuildDir(root string) string {
cursorDir := filepath.Join(root, ".cursor")
grokDir := filepath.Join(root, ".grok")
if dirExists(cursorDir) && !hasRenderSkills(filepath.Join(grokDir, "skills")) {
return cursorDir
}
return grokDir
}

// hasRenderSkills reports whether skillsDir holds any installed Render skills.
func hasRenderSkills(skillsDir string) bool {
return len(DetectInstalledSkills(skillsDir)) > 0
}

// FilterTools returns only the tools whose names contain the given filter
Expand All @@ -112,13 +168,49 @@ func FilterTools(tools []Tool, filter string) []Tool {
filter = strings.ToLower(filter)
var filtered []Tool
for _, t := range tools {
if strings.Contains(strings.ToLower(t.Name), filter) {
if matchesTool(t, filter) {
filtered = append(filtered, t)
}
}
return filtered
}

// matchesTool reports whether filter (lowercase) is part of the tool's name;
// Grok Build also matches as Cursor.
func matchesTool(t Tool, filter string) bool {
names := []string{t.Name}
if savedToolName(t.Name) == cursorName {
names = []string{cursorName, grokBuildName}
}
for _, name := range names {
if strings.Contains(strings.ToLower(name), filter) {
return true
}
}
return false
}

// LookupTool returns the tool with the given name. A tool name saved as Cursor
// finds Grok Build, and the other way around.
func LookupTool(tools []Tool, name string) (Tool, bool) {
for _, t := range tools {
if savedToolName(t.Name) == savedToolName(name) {
return t, true
}
}
return Tool{}, false
}

// savedToolName returns the name a tool is saved under: Grok Build is saved
// as Cursor, so older versions of the CLI still find it, and the saved name
// doesn't depend on whether the grok-build command is on PATH.
func savedToolName(name string) string {
if name == grokBuildName {
return cursorName
}
return name
}

// CloneSkillsRepo performs a shallow clone of the render-oss/skills repo into
// the given directory. The default branch is always used.
func CloneSkillsRepo(destDir string) error {
Expand Down Expand Up @@ -442,9 +534,9 @@ func ScanInstalledState(tools []Tool) (installed []InstalledSkill, toolNames []s
if len(found) == 0 {
continue
}
if !toolSeen[t.Name] {
toolSeen[t.Name] = true
toolNames = append(toolNames, t.Name)
if name := savedToolName(t.Name); !toolSeen[name] {
toolSeen[name] = true
toolNames = append(toolNames, name)
}
for _, s := range found {
key := "user:" + s.DirName
Expand All @@ -469,9 +561,9 @@ func ScanInstalledState(tools []Tool) (installed []InstalledSkill, toolNames []s
if len(found) == 0 {
continue
}
if !toolSeen[t.Name] {
toolSeen[t.Name] = true
toolNames = append(toolNames, t.Name)
if name := savedToolName(t.Name); !toolSeen[name] {
toolSeen[name] = true
toolNames = append(toolNames, name)
}
for _, s := range found {
key := "project:" + s.DirName
Expand Down Expand Up @@ -599,3 +691,8 @@ func dirExists(path string) bool {
info, err := os.Stat(path)
return err == nil && info.IsDir()
}

func fileExists(path string) bool {
info, err := os.Stat(path)
return err == nil && !info.IsDir()
}
Loading