AI & Agentslow risk

metagit-gating

Use when implementing or operating Metagit MCP server activation and tool exposure rules based on .metagit.yml presence and validity.

metagit-ai/metagit-cli·src/metagit/data/skills/metagit-gating/SKILL.md
85/ 100品質分

匯入這個 Skill

選擇你的 coding agent,複製專案級或個人級安裝指令。

固定至平台收錄的 commit
匯入目前專案.agents/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a codex -y
匯入個人環境~/.agents/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a codex -g -y
手動放置目錄.agents/skills/metagit-gatingOfficial docs ↗
匯入目前專案.claude/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a claude-code -y
匯入個人環境~/.claude/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a claude-code -g -y
手動放置目錄.claude/skills/metagit-gatingOfficial docs ↗
匯入目前專案.agents/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a github-copilot -y
匯入個人環境~/.copilot/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a github-copilot -g -y
手動放置目錄.agents/skills/metagit-gatingOfficial docs ↗
匯入目前專案.agents/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a cursor -y
匯入個人環境~/.cursor/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a cursor -g -y
手動放置目錄.agents/skills/metagit-gatingOfficial docs ↗
匯入目前專案.agents/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a gemini-cli -y
匯入個人環境~/.gemini/skills/metagit-gating
npx skills add https://github.com/metagit-ai/metagit-cli/tree/482dfb3b7a407ca5e541657a6fcc9af619818243/src/metagit/data/skills/metagit-gating -a gemini-cli -g -y
Native Gemini CLIgemini skills install https://github.com/metagit-ai/metagit-cli.git --scope workspace --path src/metagit/data/skills/metagit-gating
手動放置目錄.agents/skills/metagit-gatingOfficial docs ↗
⚠ 安裝指令使用開源 skills CLI。執行前請檢查來源、腳本與權限。
# Metagit MCP Gating Skill

Use this skill whenever you need to control whether Metagit MCP tools/resources are exposed.

## Purpose

Ensure high-risk tooling and multi-repo context are only available when a valid `.metagit.yml` exists at the resolved workspace root.

## Bundled scripts (optional)

Hermes `skill_manage` installs SKILL.md only. Resolve scripts from the package or a full
`metagit skills install`:

```bash
SKILL_ROOT="$(python3 -c "import metagit, pathlib; print(pathlib.Path(metagit.__file__).parent / 'data/skills/metagit-gating')")"
"$SKILL_ROOT/scripts/gate-status.sh" [root_path]
```

Expected output (single line, tab-delimited):
- `state=<value>\troot=<path|none>\ttools=<count>`

### Inline CLI fallback (no scripts)

```bash
metagit mcp serve --status-once --root .
metagit config validate -c .metagit.yml
```

Parse `mcp_state=` from `--status-once` output (`missing`, `invalid`, or `active`).

## Activation Workflow

1. Resolve workspace root:
   - `METAGIT_WORKSPACE_ROOT`
   - CLI `--root`
   - upward directory walk
2. Check for `.metagit.yml` in resolved root.
3. Validate config through existing Metagit config models.
4. Derive activation state: missing, invalid, or active.
5. Register tool surface based on state.

## Tool Exposure Contract

### Inactive (missing or invalid config)
Expose only:
- `metagit_workspace_status`
- `metagit_bootstrap_config_plan_only`

### Active (valid config)
Expose full set:
- `metagit_workspace_status`
- `metagit_workspace_index`
- `metagit_workspace_search`
- `metagit_workspace_grep_info`
- `metagit_upstream_hints`
- `metagit_repo_inspect`
- `metagit_repo_sync`
- `metagit_bootstrap_config`

## Error Handling

- Return explicit, machine-readable state and reason.
- Avoid stack traces in user-facing outputs.
- Log parser/validation errors with enough detail for debugging.

## Safety Rules

- Never expose mutation-capable tools in inactive state.
- Never operate outside validated workspace boundaries.
- Keep defaults read-only unless user/agent explicitly opts in.