add-command

GitHub

用于在 VS Code 插件中生成新命令的脚手架工具,自动创建命令文件、注册贡献点及运行代码生成脚本,适用于快速开发扩展功能。

.claude/skills/add-command/SKILL.md gitkraken/vscode-gitlens

Trigger Scenarios

需要创建新的 VS Code 命令 初始化命令模板和配置

Install

npx skills add gitkraken/vscode-gitlens --skill add-command -g -y
More Options

Non-standard path

npx skills add https://github.com/gitkraken/vscode-gitlens/tree/main/.claude/skills/add-command -g -y

Use without installing

npx skills use gitkraken/vscode-gitlens@add-command

指定 Agent (Claude Code)

npx skills add gitkraken/vscode-gitlens --skill add-command -a claude-code -g -y

安装 repo 全部 skill

npx skills add gitkraken/vscode-gitlens --all -g -y

预览 repo 内 skill

npx skills add gitkraken/vscode-gitlens --list

SKILL.md

Frontmatter
{
    "name": "add-command",
    "description": "Create new VS Code commands with all required boilerplate"
}

/add-command - Create New Command

Scaffold a new VS Code command with all required boilerplate.

Usage

/add-command [name]

Information Needed

  1. Command ID — e.g., myNewFeature (becomes gitlens.myNewFeature)
  2. Label — Display name in command palette
  3. Base class:
    • GlCommandBase — No editor required (opening panels, showing pickers)
    • ActiveEditorCommand — Requires active editor
    • ActiveEditorCachedCommand — Like ActiveEditorCommand with "repeat last command" support
  4. Variants (optional): :views, :graph, :scm suffixes for context menus

Files to Create/Modify

1. Command File: src/commands/{commandName}.ts

import type { TextEditor, Uri } from 'vscode';
import type { Container } from '../container.js';
import { command } from '../system/-webview/command.js';
import { {BaseClass} } from './commandBase.js';

export interface {CommandName}CommandArgs {
    // Define args if needed
}

@command()
export class {CommandName}Command extends {BaseClass} {
    constructor(private readonly container: Container) {
        super([
            'gitlens.{commandId}',
            // Add variants here
        ]);
    }

    async execute(editor?: TextEditor, uri?: Uri, args?: {CommandName}CommandArgs): Promise<void> {
        // TODO: Implement
    }
}

2. Import in src/commands.ts

import './commands/{commandName}.js';

3. Add to contributions.json

Under "commands" key:

"gitlens.{commandId}": {
    "label": "{Label}",
    "category": "GitLens",
    "commandPalette": "gitlens:enabled"
}

For :views variant:

"gitlens.{commandId}:views": {
    "label": "{Label}",
    "icon": "$(icon-name)",
    "menus": {
        "view/item/context": [{
            "when": "viewItem =~ /gitlens:/ && gitlens:enabled",
            "group": "1_gitlens"
        }]
    }
}

4. Run Generation

pnpm run generate:contributions && pnpm run generate:commandTypes

Common when Clauses

  • gitlens:enabled — Extension is enabled
  • !gitlens:readonly — Not in readonly mode
  • !gitlens:untrusted — Workspace is trusted
  • gitlens:plus — Pro features available
  • viewItem =~ /gitlens:commit/ — On a commit node
  • viewItem =~ /gitlens:branch/ — On a branch node

Version History

  • ba869f2 Current 2026-08-20 14:21

Same Skill Collection

.claude/skills/a11y-audit/SKILL.md
.claude/skills/a11y-flow-audit/SKILL.md
.claude/skills/a11y-remediate/SKILL.md
.claude/skills/add-webview/SKILL.md
.claude/skills/challenge-plan/SKILL.md
.claude/skills/commit/SKILL.md
.claude/skills/create-issue/SKILL.md
.claude/skills/deep-planning/SKILL.md
.claude/skills/deep-review/SKILL.md
.claude/skills/dev-scope/SKILL.md
.claude/skills/investigate/SKILL.md
.claude/skills/live-exercise/SKILL.md
.claude/skills/live-inspect/SKILL.md
.claude/skills/live-pair/SKILL.md
.claude/skills/live-perf/SKILL.md
.claude/skills/modern-css/SKILL.md
.claude/skills/prioritize/SKILL.md
.claude/skills/review/SKILL.md
.claude/skills/triage/SKILL.md
.claude/skills/update-issues/SKILL.md
.claude/skills/ux-review/SKILL.md
.claude/skills/worktree/SKILL.md
.claude/skills/add-icon/SKILL.md
.claude/skills/add-test/SKILL.md
.claude/skills/audit-commits/SKILL.md

Metadata

Files
0
Version
ba869f2
Hash
e17560b7
Indexed
2026-08-20 14:21

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 04:23
浙ICP备14020137号-1 $방문자$