MCPcopy Create free account
hub / github.com/github/gh-aw / NewInitCommand

Function NewInitCommand

pkg/cli/init_command.go:17–156  ·  view source on GitHub ↗

NewInitCommand creates the init command

()

Source from the content-addressed store, hash-verified

15
16// NewInitCommand creates the init command
17func NewInitCommand() *cobra.Command {
18 cmd := &cobra.Command{
19 Use: "init",
20 Short: "Initialize the repository for agentic workflows",
21 Long: `Initialize the repository for agentic workflows by configuring .gitattributes and creating the dispatcher skill file.
22
23This command performs non-interactive repository setup and does not prompt for
24engine selection or secret configuration.
25
26This command:
27- Configures .gitattributes to mark .lock.yml files as generated
28- Creates the dispatcher skill at .github/skills/agentic-workflows/SKILL.md
29- Creates the workflow designer skill at .github/skills/agentic-workflow-designer/SKILL.md
30- Creates the custom agent at .github/agents/agentic-workflows.md
31- Removes old prompt files from .github/prompts/ if they exist
32- Configures VSCode settings (.vscode/settings.json)
33- Generates/updates .github/workflows/agentics-maintenance.yml if any workflows use expires field for discussions or issues
34
35By default (without --no-mcp):
36- Creates .github/workflows/copilot-setup-steps.yml with gh-aw installation steps
37- Creates .github/mcp.json with gh-aw MCP server configuration
38
39With --no-mcp flag:
40- Skips creating GitHub Copilot Agent MCP server configuration files
41
42With --no-skill flag:
43- Skips creating the dispatcher skill
44
45With --no-agent flag:
46- Skips creating the custom agent
47
48With --codespaces flag:
49- Updates existing .devcontainer/devcontainer.json if present, otherwise creates new file at default location
50- Configures permissions for current repo: actions:write, contents:write, discussions:read, issues:read, pull-requests:write, workflows:write
51- Configures permissions for additional repos (in same org): actions:read, contents:read, discussions:read, issues:read, pull-requests:read, workflows:read
52- Adds GitHub Copilot extensions and gh aw CLI installation
53- Use with an empty value (--codespaces "") for current repo only, or with comma-separated repos (--codespaces repo1,repo2)
54
55With --completions flag:
56- Automatically detects your shell (bash, zsh, fish, or PowerShell)
57- Installs shell completion configuration for the CLI
58- Provides instructions for enabling completions in your shell
59
60After running this command, you can:
61- Use GitHub Copilot Chat or coding agent tools with the agentic-workflows skill to get started with workflow tasks
62- The dispatcher skill will route your request to the appropriate specialized prompt
63- Add workflows from the catalog with: ` + string(constants.CLIExtensionPrefix) + ` add <workflow-name>
64- Create new workflows from scratch with: ` + string(constants.CLIExtensionPrefix) + ` new <workflow-name>`,
65 Example: ` ` + string(constants.CLIExtensionPrefix) + ` init # Initialize repository with defaults
66 ` + string(constants.CLIExtensionPrefix) + ` init -v # Initialize with verbose output
67 ` + string(constants.CLIExtensionPrefix) + ` init --engine claude # Skip Copilot-specific artifacts
68 ` + string(constants.CLIExtensionPrefix) + ` init --no-mcp # Skip MCP configuration
69 ` + string(constants.CLIExtensionPrefix) + ` init --no-skill # Skip dispatcher skill creation
70 ` + string(constants.CLIExtensionPrefix) + ` init --no-agent # Skip custom agent creation
71 ` + string(constants.CLIExtensionPrefix) + ` init --codespaces "" # Configure Codespaces for current repo only
72 ` + string(constants.CLIExtensionPrefix) + ` init --codespaces repo1,repo2 # Codespaces with additional repos
73 ` + string(constants.CLIExtensionPrefix) + ` init --completions # Install shell completions
74 ` + string(constants.CLIExtensionPrefix) + ` init --create-pull-request # Initialize and create a pull request`,

Callers 6

initFunction · 0.92
TestNewInitCommandFunction · 0.85
TestInitCommandHelpFunction · 0.85

Calls 10

GetGlobalEngineRegistryFunction · 0.92
InitRepositoryFunction · 0.85
addEngineFlagFunction · 0.85
IsValidEngineMethod · 0.80
GetSupportedEnginesMethod · 0.80
PrintMethod · 0.80
GetStringMethod · 0.65
ErrorfMethod · 0.45
PrintfMethod · 0.45
StringMethod · 0.45

Tested by 5

TestNewInitCommandFunction · 0.68
TestInitCommandHelpFunction · 0.68