MCPcopy Index your code
hub / github.com/cli/cli / NewCmdUpdate

Function NewCmdUpdate

pkg/cmd/skills/update/update.go:66–141  ·  view source on GitHub ↗

NewCmdUpdate creates the "skills update" command.

(f *cmdutil.Factory, runF func(*UpdateOptions) error)

Source from the content-addressed store, hash-verified

64
65// NewCmdUpdate creates the "skills update" command.
66func NewCmdUpdate(f *cmdutil.Factory, runF func(*UpdateOptions) error) *cobra.Command {
67 opts := &UpdateOptions{
68 IO: f.IOStreams,
69 Prompter: f.Prompter,
70 Config: f.Config,
71 GitClient: f.GitClient,
72 HttpClient: f.HttpClient,
73 }
74
75 cmd := &cobra.Command{
76 Use: "update [<skill>...] [flags]",
77 Short: "Update installed skills to their latest versions (preview)",
78 Long: heredoc.Docf(`
79 Checks installed skills for available updates by comparing the local
80 tree SHA (from %[1]sSKILL.md%[1]s frontmatter) against the remote repository.
81
82 Scans all known agent host directories (Copilot, Claude, Cursor, Codex,
83 Gemini, Antigravity) in both project and user scope automatically.
84
85 Without arguments, checks all installed skills. With skill names,
86 checks only those specific skills.
87
88 Pinned skills (installed with %[1]s--pin%[1]s) are skipped with a notice.
89 Use %[1]s--unpin%[1]s to clear the pinned version and include those skills
90 in the update.
91
92 Skills without GitHub metadata (e.g. installed manually or by another
93 tool) are prompted for their source repository in interactive mode.
94 With %[1]s--all%[1]s or in non-interactive mode, they are skipped with a notice.
95 The update re-downloads the skill with metadata injected, so future
96 updates work automatically.
97
98 With %[1]s--force%[1]s, re-downloads skills even when the remote version matches
99 the local tree SHA. This overwrites locally modified skill files with
100 their original content, but does not remove extra files added locally.
101
102 In interactive mode, shows which skills have updates and asks for
103 confirmation before proceeding. With %[1]s--all%[1]s, updates without prompting.
104 With %[1]s--dry-run%[1]s, reports available updates without modifying any files.
105 `, "`"),
106 Example: heredoc.Doc(`
107 # Check and update all skills interactively
108 $ gh skill update
109
110 # Update specific skills
111 $ gh skill update mcp-cli git-commit
112
113 # Update all without prompting
114 $ gh skill update --all
115
116 # Re-download all skills (restore locally modified files)
117 $ gh skill update --force --all
118
119 # Check for updates without applying (read-only)
120 $ gh skill update --dry-run
121
122 # Unpin skills and update them to latest
123 $ gh skill update --unpin

Callers 4

NewCmdSkillsFunction · 0.92
TestNewCmdUpdate_HelpFunction · 0.85
TestNewCmdUpdate_FlagsFunction · 0.85

Calls 1

updateRunFunction · 0.85

Tested by 3

TestNewCmdUpdate_HelpFunction · 0.68
TestNewCmdUpdate_FlagsFunction · 0.68