SC4SAP Trust Session (Internal-Only)
Session-scoped permission bootstrap for automated pipelines. When a long-running parent skill enters its automated phases, sub-agent dispatch (Agent/Task) and .sc4sap/ state-file writes would otherwise trigger permission prompts. This skill pre-grants those so the parent pipeline proceeds uninterrupted.
⚠️ This skill is NOT user-facing. It exists only as a sub-routine of other skills. Direct /sc4sap:trust-session invocation by the user is rejected — see <Standalone_Invocation_Refusal> below.
Detect whether this skill is being invoked standalone or by a parent skill:
- Parent skill present: the invocation is chained from
/sc4sap:create-program, /sc4sap:setup, /sc4sap:analyze-cbo-obj, /sc4sap:analyze-code, /sc4sap:analyze-symptom, or /sc4sap:create-object. The caller passes parent_skill={name} as the first argument OR the invocation appears inside another skill's execution trace in the current turn.
- Standalone (no parent): user typed
/sc4sap:trust-session directly, or the arguments do not identify a known parent.
On standalone invocation, refuse and redirect:
⚠️ /sc4sap:trust-session is an internal-only skill. Direct invocation is not allowed.
To grant session-wide permissions for an automated pipeline, run one of the following
parent skills instead (each auto-invokes trust-session at entry):
• /sc4sap:create-program — program creation pipeline (invokes at Phase 1)
• /sc4sap:create-object — single object creation
• /sc4sap:analyze-cbo-obj — CBO package inventory walk
• /sc4sap:analyze-code — code review
• /sc4sap:analyze-symptom — dump / error root-cause analysis
→ A separate trust-session run is unnecessary — the parent skill handles it for you.
After printing the message, STOP. Do NOT modify .claude/settings.local.json. Do NOT write .sc4sap/session-trust.log.
- Sub-agent dispatch — allowed:
Agent(*) — required so parallel review fan-out and any other sub-agent dispatch run without prompts. Each sub-agent's MCP calls are still auto-approved individually by the permission-approver hook; its non-MCP tool calls follow this same allowlist.
- Internal state file I/O — allowed (path-scoped):
Write(.sc4sap/**), Edit(.sc4sap/**) — runtime state files only (state.json, spec.md, plan.md, review.md, report.md, cbo/**, session-trust.log, etc.). Writes outside .sc4sap/** still prompt.
Read(.sc4sap/**), Read(sc4sap/**) — read project state and rule files.
Glob(.sc4sap/**), Glob(sc4sap/**), Grep(.sc4sap/**), Grep(sc4sap/**) — search within project and state folders.
- Everything else — NOT added to allow (normal prompt behavior preserved):
Bash(...) — prompt per command.
Write / Edit outside .sc4sap/** — prompt (protects sc4sap/ source, .claude/, elsewhere).
WebFetch / WebSearch and any non-SAP MCP namespace (mcp__claude_ai_Notion__*, mcp__ide__*, …) — prompt.
- SAP MCP handlers — NOT added here; the hook approves them at call time (do NOT enumerate them in
settings.local.json).
Idempotent: if an entry already exists, do not duplicate.
Row-data extraction stays gated: GetTableContents / GetSqlQuery (both namespaces) are never auto-approved — the hook passes them through to the normal prompt, and block-forbidden-tables enforces the blocklist. See common/data-extraction-policy.md.
Task: {{ARGUMENTS}}
1---2name: sc4sap-trust-session3description: INTERNAL-ONLY permission bootstrap. Pre-approves Agent dispatch + `.sc4sap/` state-file I/O for the session so parent-skill pipelines run without prompts. SAP MCP handlers are auto-approved by the `permission-approver` PreToolUse hook (except GetTableContents / GetSqlQuery, which stay prompt-gated). MUST be invoked by a parent skill (create-program, setup, team, analyze-*, create-object) — direct user invocation is rejected with a redirect message.4---56# SC4SAP Trust Session (Internal-Only)78Session-scoped permission bootstrap for automated pipelines. When a long-running parent skill enters its automated phases, sub-agent dispatch (`Agent`/`Task`) and `.sc4sap/` state-file writes would otherwise trigger permission prompts. This skill pre-grants those so the parent pipeline proceeds uninterrupted.910**⚠️ This skill is NOT user-facing.** It exists only as a sub-routine of other skills. Direct `/sc4sap:trust-session` invocation by the user is rejected — see `<Standalone_Invocation_Refusal>` below.1112<Permission_Model_Note>13**SAP MCP handler permissions are NOT managed by this skill anymore.** They are auto-approved at call time by the `permission-approver` PreToolUse hook (`scripts/permission-approver.mjs`, wired in `hooks/hooks.json`), which returns `permissionDecision: "allow"` for every `mcp__plugin_sc4sap_sap__*` / `mcp__mcp-abap-adt__*` tool except the two row-data extraction tools (`GetTableContents`, `GetSqlQuery`), which fall through to normal prompting plus the `block-forbidden-tables` safeguard. The hook runs in BOTH the main thread and sub-agents, regardless of session permission mode — this replaces the former `settings.local.json` MCP enumeration and the deprecated `mode: "dontAsk"` Agent-dispatch parameter (ignored by current Claude Code; sub-agents now inherit the parent session's permission mode). trust-session therefore only handles the NON-MCP grants below.14</Permission_Model_Note>1516<Purpose>17Pre-approve the non-MCP operations an automated parent pipeline needs — sub-agent dispatch and `.sc4sap/` runtime-state I/O — by writing a scoped allowlist to `.claude/settings.local.json`. Must ride on the authority of a parent skill so the grant is contextual, not a blanket user-initiated one.18</Purpose>1920<Response_Prefix>21Every response triggered by this skill MUST begin with `[Model: <main-model> · Dispatched: <sub-summary>]` per [`../../common/model-routing-rule.md`](../../common/model-routing-rule.md) § Response Prefix Convention.22</Response_Prefix>2324<Standalone_Invocation_Refusal>25**MANDATORY gate — runs as Step 0 before any file write.**2627Detect whether this skill is being invoked standalone or by a parent skill:28- **Parent skill present**: the invocation is chained from `/sc4sap:create-program`, `/sc4sap:setup`, `/sc4sap:analyze-cbo-obj`, `/sc4sap:analyze-code`, `/sc4sap:analyze-symptom`, or `/sc4sap:create-object`. The caller passes `parent_skill={name}` as the first argument OR the invocation appears inside another skill's execution trace in the current turn.29- **Standalone (no parent)**: user typed `/sc4sap:trust-session` directly, or the arguments do not identify a known parent.3031**On standalone invocation, refuse and redirect**:3233```34⚠️ /sc4sap:trust-session is an internal-only skill. Direct invocation is not allowed.3536To grant session-wide permissions for an automated pipeline, run one of the following37parent skills instead (each auto-invokes trust-session at entry):3839 • /sc4sap:create-program — program creation pipeline (invokes at Phase 1)40 • /sc4sap:create-object — single object creation41 • /sc4sap:analyze-cbo-obj — CBO package inventory walk42 • /sc4sap:analyze-code — code review43 • /sc4sap:analyze-symptom — dump / error root-cause analysis4445→ A separate trust-session run is unnecessary — the parent skill handles it for you.46```4748After printing the message, STOP. Do NOT modify `.claude/settings.local.json`. Do NOT write `.sc4sap/session-trust.log`.49</Standalone_Invocation_Refusal>5051<Use_When>52- Called automatically as Phase 0 / entry step of a parent skill (see list above)53- Parent skill passes `parent_skill={name}` argument to identify itself54</Use_When>5556<Do_Not_Use_When>57- User types `/sc4sap:trust-session` directly → refuse per `<Standalone_Invocation_Refusal>`58- Running on a production SAP system without change authorization59</Do_Not_Use_When>6061<What_This_Skill_Does>62Single-layer, non-MCP permission grant written to `.claude/settings.local.json` → `permissions.allow` (project-local, persists). **Scope policy: sub-agent dispatch + `.sc4sap/` state I/O only. SAP MCP is handled by the hook; everything else stays prompt-gated.**6364- **Sub-agent dispatch — allowed**:65 - `Agent(*)` — required so parallel review fan-out and any other sub-agent dispatch run without prompts. Each sub-agent's MCP calls are still auto-approved individually by the `permission-approver` hook; its non-MCP tool calls follow this same allowlist.66- **Internal state file I/O — allowed (path-scoped)**:67 - `Write(.sc4sap/**)`, `Edit(.sc4sap/**)` — runtime state files only (`state.json`, `spec.md`, `plan.md`, `review.md`, `report.md`, `cbo/**`, `session-trust.log`, etc.). Writes outside `.sc4sap/**` still prompt.68 - `Read(.sc4sap/**)`, `Read(sc4sap/**)` — read project state and rule files.69 - `Glob(.sc4sap/**)`, `Glob(sc4sap/**)`, `Grep(.sc4sap/**)`, `Grep(sc4sap/**)` — search within project and state folders.70- **Everything else — NOT added to allow** (normal prompt behavior preserved):71 - `Bash(...)` — prompt per command.72 - `Write` / `Edit` outside `.sc4sap/**` — prompt (protects `sc4sap/` source, `.claude/`, elsewhere).73 - `WebFetch` / `WebSearch` and any non-SAP MCP namespace (`mcp__claude_ai_Notion__*`, `mcp__ide__*`, …) — prompt.74 - SAP MCP handlers — NOT added here; the hook approves them at call time (do NOT enumerate them in `settings.local.json`).7576Idempotent: if an entry already exists, do not duplicate.7778**Row-data extraction stays gated**: `GetTableContents` / `GetSqlQuery` (both namespaces) are never auto-approved — the hook passes them through to the normal prompt, and `block-forbidden-tables` enforces the blocklist. See `common/data-extraction-policy.md`.79</What_This_Skill_Does>8081<Execution_Steps>820. **Standalone gate** — if `<Standalone_Invocation_Refusal>` conditions match, refuse and STOP.831. Read `.claude/settings.local.json` (create `{"permissions":{"allow":[]}}` skeleton if missing).842. **Strip forbidden broad entries if present** — remove these from `permissions.allow` when found (they violate the scoped policy):85 - Broad wildcards: `Read(*)`, `Write(*)`, `Edit(*)`, `Glob(*)`, `Grep(*)`.86 - SAP MCP entries added by a prior version or by an "Always allow" click — the hook now owns MCP approval, so enumerated `mcp__plugin_sc4sap_sap__*` / `mcp__mcp-abap-adt__*` entries are redundant and the wildcards `mcp__plugin_sc4sap_sap__*` / `mcp__mcp-abap-adt__*` MUST be removed (a wildcard would silently auto-approve `GetTableContents` / `GetSqlQuery`, defeating the safeguard). Removing enumerated non-gated MCP entries is optional cleanup; removing the two gated tools and any MCP wildcard is MANDATORY.87 - Non-SAP MCP wildcards: `mcp__claude_ai_Notion__*`, `mcp__ide__*`.883. **Append scoped entries** to `permissions.allow` only if not already present:89 ```90 Agent(*)91 Read(.sc4sap/**)92 Read(sc4sap/**)93 Write(.sc4sap/**)94 Edit(.sc4sap/**)95 Glob(.sc4sap/**)96 Glob(sc4sap/**)97 Grep(.sc4sap/**)98 Grep(sc4sap/**)99 ```1004. Preserve all other existing entries verbatim (env, hooks, other permissions).1015. Write the updated JSON back with 2-space indent.1026. Print one-line confirmation: `"✅ Session trust granted by {parent_skill} — Agent dispatch + .sc4sap/ state I/O auto-approved. SAP MCP handlers are auto-approved by the permission-approver hook; Bash, WebFetch, Write/Edit outside .sc4sap/, GetTableContents, GetSqlQuery remain prompt-gated."`1037. Record activation in `.sc4sap/session-trust.log` (append line: `{ISO-timestamp} granted-by={parent_skill}`) for audit.104</Execution_Steps>105106<Enforcement_Contract>107- Parent skills invoke `trust-session` with `parent_skill={self-name}` at entry, before their first sub-agent dispatch.108- SAP MCP permission prompts are handled by the `permission-approver` hook — parent skills do NOT pass any `mode` parameter to `Agent` (the parameter is deprecated and ignored by current Claude Code).109- If the user has `DISABLE_SC4SAP=1` (or `DISABLE_OMC=1`) set, skip the allowlist writes and warn.110- **Standalone refusal is non-negotiable** — even if the user insists, the refusal message stands.111</Enforcement_Contract>112113<Revocation>114To revoke: user runs `/sc4sap:sap-option` → permissions tab → "revoke session trust", which strips the `Agent(*)` and `.sc4sap/`-scoped entries from `settings.local.json`. Per-tool prompts resume on next run. SAP MCP auto-approval is disabled separately via `DISABLE_SC4SAP=1` (turns off the hook).115</Revocation>116117<State_Files>118- `.claude/settings.local.json` — permissions allowlist (modified)119- `.sc4sap/session-trust.log` — audit trail120</State_Files>121122Task: {{ARGUMENTS}}