Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(cli_agent): shared skill materialisation + conditional Skill in allowlist
trohitg76b707bbd63f
diff --git a/CLAUDE.md b/CLAUDE.mdindex 6d95d819..c521cf43 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -3499,7 +3499,9 @@ When `simpleMemory` is connected to `claude_code_agent`, memory continuity is ha**Stale-model coercion.** `ClaudeCodeAgentParams.model` is a `Literal` of supported model IDs + aliases — strict validation would reject legacy saved values like `"claude-sonnet-4.6"` (dot-spelled), `"claude-3-5-sonnet-20241022"` (date-suffixed), `""`. A `field_validator("model", "fallback_model", mode="before")` coerces unknown values to the default (`"claude-sonnet-4-6"` for `model`, `None` for `fallback_model`) so old workflows keep loading; the UI dropdown still constrains new edits.-**Strict tool allowlist — no claude built-ins, gated by `--permission-mode dontAsk`.** The spawn argv emits `--permission-mode dontAsk` (documented as *"only pre-approved tools, no prompts"* per [code.claude.com/docs/en/permission-modes](https://code.claude.com/docs/en/permission-modes)) so `--allowedTools` is actually enforced. The previous default `bypassPermissions` *"skips the permission layer entirely"* — same doc — which turned the allowlist into documentation-only and let claude's built-in `Read` / `Edit` / `Bash` / `Glob` / `Grep` / `Write` / `Skill` / `WebSearch` / `WebFetch` fire regardless of wiring. The new `--allowedTools` list contains exactly: (a) one `mcp__machinaos__<node_type>` per node wired through the agent's `input-tools` handle, (b) the five MachinaOs MCP infrastructure tools (`getWorkspaceFiles`, `listSkills`, `getSkill`, `getCredential`, `broadcastLog`). Every filesystem / shell / web operation flows through wired MCP tools (`fileRead` / `fileModify` / `fsSearch` / `shell` / `browser` / `perplexitySearch`) — explicit wiring, no built-in escape hatches. Defaults live in [`server/config/ai_cli_providers.json`](./server/config/ai_cli_providers.json) (`default_allowed_tools: ""`, `default_permission_mode: "dontAsk"`); per-task override via `ClaudeTaskSpec.allowed_tools` is honored verbatim (no auto-merge).+**Strict tool allowlist — no claude built-ins (except conditional `Skill`), gated by `--permission-mode dontAsk`.** The spawn argv emits `--permission-mode dontAsk` (documented as *"only pre-approved tools, no prompts"* per [code.claude.com/docs/en/permission-modes](https://code.claude.com/docs/en/permission-modes)) so `--allowedTools` is actually enforced. The previous default `bypassPermissions` *"skips the permission layer entirely"* — same doc — which turned the allowlist into documentation-only and let claude's built-in `Read` / `Edit` / `Bash` / `Glob` / `Grep` / `Write` / `Skill` / `WebSearch` / `WebFetch` fire regardless of wiring. The new `--allowedTools` list contains exactly: (a) one `mcp__machinaos__<node_type>` per node wired through the agent's `input-tools` handle, (b) the claude built-in `Skill` **conditionally** — only when at least one skill is wired through `input-skill` (paired with the materialisation helper below; never enabled when no skill is connected), (c) the five MachinaOs MCP infrastructure tools (`getWorkspaceFiles`, `listSkills`, `getSkill`, `getCredential`, `broadcastLog`). Every filesystem / shell / web operation flows through wired MCP tools (`fileRead` / `fileModify` / `fsSearch` / `shell` / `browser` / `perplexitySearch`) — explicit wiring, no built-in escape hatches. Defaults live in [`server/config/ai_cli_providers.json`](./server/config/ai_cli_providers.json) (`default_allowed_tools: ""`, `default_permission_mode: "dontAsk"`); per-task override via `ClaudeTaskSpec.allowed_tools` is honored verbatim (no auto-merge).++**Skill materialisation — shared helper, both paths.** [`services/cli_agent/_skills.py::materialise_skills`](./server/services/cli_agent/_skills.py) writes connected SKILL.md trees under `<cwd>/.claude/skills/<name>/` so claude's built-in `Skill` tool can load them. Filesystem skills are copied wholesale (`shutil.copytree`) preserving `scripts/` + `references/`; DB skills reconstruct the frontmatter from the loader's metadata. Called from BOTH `AICliSession._pre_spawn` (non-pool path) and `ClaudeSessionPool._spawn` (pool path) — closes the pre-existing gap where memory-bound runs got skills via MCP only. The helper is paired with the conditional `Skill` entry in `--allowedTools`: both fire iff `connected_skill_names` is non-empty.**Warm-subprocess tool-surface rebind — no respawn cost.** Claude bakes the MCP bearer token into argv (`--mcp-config`) at spawn time and can't rotate without respawning. The pool stashes the spawn-time token on `PooledClaudeSession.batch_token` so subsequent batches can rebind the same persistent `BatchContext` in place. On warm reuse, `ClaudeSessionPool.acquire` calls [`rebind_batch(existing.batch_token, connected_tools=new_ctx.connected_tools, ...)`](./server/services/cli_agent/mcp_server.py) — diffs old vs new tool lists, calls `unexpose_workflow_tools(removed)` to decrement FastMCP refcounts (so a disconnected `duckduckgoSearch` falls off the tool list when its refcount hits zero), `expose_workflow_tools(added)` for newly-wired ones, then unregisters the redundant new token. `_terminate_locked` calls `unregister_batch(session.batch_token)` so refcounts drain on pool eviction / `clear` / `shutdown_all` (closes the long-standing leak where every pooled run permanently incremented every wired tool's refcount). The per-handler scope check in `workflow_tools._build_handler` reads `ctx.connected_tools` at call time, so even if claude's frozen `--allowedTools` argv still references a now-disconnected tool, the handler returns `{"error": "...not connected to this batch", "status": 403}` — double-lock against tool leakage across warm-reuse turns.diff --git a/docs-internal/claude_code_interactive_mode.md b/docs-internal/claude_code_interactive_mode.mdindex 62fcf7bd..e407ac4d 100644--- a/docs-internal/claude_code_interactive_mode.md+++ b/docs-internal/claude_code_interactive_mode.md@@ -260,8 +260,8 @@ true` to opt out of MCP tool-search deferral so all`mcp__machinaos__*` tools enter context at session start.`--allowedTools` is the explicit allowlist, and it does NOT includeclaude's built-in escape hatches (`Read`, `Edit`, `Bash`, `Glob`,-`Grep`, `Write`, `Skill`, `WebSearch`, `WebFetch`) — every workflow-already wires the equivalents (`fileRead`, `fileModify`, `fsSearch`,+`Grep`, `Write`, `WebSearch`, `WebFetch`) — every workflow already+wires the equivalents (`fileRead`, `fileModify`, `fsSearch`,`shell`, `browser`, `perplexitySearch`, …) as MCP tools, and thebuilt-ins were the leakage path that let the agent invokecapabilities the workflow didn't explicitly grant. The default@@ -270,11 +270,21 @@ allowlist is:- `mcp__machinaos__<node_type>` per node connected to the agent's`input-tools` handle (LLM sees their typed Pydantic schemas viaFastMCP's `tools/list` reflection on the plugin `Params`).+- The claude built-in `Skill` — **conditional**, present iff at+ least one skill is wired through the agent's `input-skill`+ handle. Paired with the `materialise_skills` helper (below)+ which writes the connected SKILL.md trees under+ `<cwd>/.claude/skills/` so the built-in skill loader has+ something to discover. The one exception to the+ "no claude built-ins" rule, because the alternative (forcing the+ agent to load every skill through the `getSkill` MCP round-trip)+ is materially worse UX for the common case where the workflow+ pre-wired which skills should be on the table.- The five MachinaOs MCP infrastructure tools — `getWorkspaceFiles`,`listSkills`, `getSkill`, `getCredential`, `broadcastLog` — which- are how the agent reads its workspace, discovers connected skills,- fetches scoped credentials, and surfaces intermediate progress to- the FE.+ are how the agent reads its workspace, discovers connected skills+ (when no wiring is present), fetches scoped credentials, and+ surfaces intermediate progress to the FE.Callers wanting specific claude built-ins back in opt in per-task via`ClaudeTaskSpec.allowed_tools` (the field is honored verbatim — no@@ -283,12 +293,21 @@ Combined with `--permission-mode dontAsk`, the strict allowlist isactually enforced (see "argv shape" above for why `bypassPermissions`was the wrong default).-**Skills — known gap on the pool path.** `AICliSession._materialise_skills`-writes connected skills under `<cwd>/.claude/skills/` for the one-shot-non-pooled path. The pool path skips that materialisation; agents-discover skills via MCP `listSkills` / `getSkill` tools at runtime-instead. Fine for now, but pool-side skill materialisation is an open-follow-up.+**Skills — materialised on BOTH paths via the shared helper.**+[`services/cli_agent/_skills.py::materialise_skills`](../server/services/cli_agent/_skills.py)+writes one `SKILL.md` tree per connected skill under+`<cwd>/.claude/skills/<name>/`. Filesystem skills (those declared+under `server/skills/<group>/<name>/`) are copied wholesale via+`shutil.copytree` so `scripts/` and `references/` survive+intact; database skills (user-created from the UI) reconstruct+the frontmatter (`name`, `description`, `allowed-tools`,+`metadata`) plus the markdown body. Called from+`AICliSession._pre_spawn` (non-pool path) and+`ClaudeSessionPool._spawn` (pool path) — same helper, same+semantics, so memory-bound runs get the built-in `Skill` tool+working too (was the open follow-up before; closed now). Failure+modes are non-fatal: a skill that fails to load or write logs at+WARN and is skipped — the spawn continues.**Workspace dir — routed via `--add-dir`.**[`AICliService.run_batch`](../server/services/cli_agent/service.py)diff --git a/server/services/cli_agent/_skills.py b/server/services/cli_agent/_skills.pynew file mode 100644index 00000000..4da704cd--- /dev/null+++ b/server/services/cli_agent/_skills.py@@ -0,0 +1,130 @@+"""Skill materialisation helper shared by pool + non-pool claude paths.++Writes ``<cwd>/.claude/skills/<name>/SKILL.md`` for each connected skill+so the spawned claude can invoke them via its built-in ``Skill`` tool+(when ``--allowedTools`` includes ``Skill``). The+``AnthropicClaudeProvider.interactive_argv`` adds ``Skill`` to the+allowlist iff ``connected_skill_names`` is non-empty — so this helper+and the conditional allowlist entry are paired.++Two skill shapes:++ - **Filesystem skills** (``server/skills/<group>/<name>/SKILL.md``):+ copied wholesale via ``shutil.copytree`` so ``scripts/`` and+ ``references/`` survive.+ - **Database skills** (user-created from the UI): reconstructed from+ frontmatter — ``name``, ``description``, ``allowed-tools``,+ ``metadata`` — plus the markdown body.++This used to live as an instance method on ``AICliSession``; the pool+path didn't call it. Extracted to a module-level free function so both+``AICliSession._pre_spawn`` (non-pool, PTY-driven) and+``ClaudeSessionPool._spawn`` (pool, subprocess+stream-json) call the+same code with the same semantics.+"""++from __future__ import annotations++import shutil+from pathlib import Path+from typing import Iterable++import yaml++from core.logging import get_logger++logger = get_logger(__name__)+++async def materialise_skills(+ cwd: Path,+ skill_names: Iterable[str],+ *,+ log_label: str = "cli-agent",+) -> int:+ """Write SKILL.md trees under ``<cwd>/.claude/skills/`` for each name.++ Returns the number of skills successfully written. Failures (skill+ not found, OSError on copy / write) log at WARNING and are skipped+ — never fatal to the spawn.++ Args:+ cwd: Spawn directory. Memory-bound runs pass ``repo_root``;+ non-memory runs pass the per-task git worktree. Either way+ the helper writes under ``<cwd>/.claude/skills/<name>/``.+ skill_names: The set of skill names to materialise. Caller is+ responsible for passing only the skills wired through+ the agent's ``input-skill`` handle.+ log_label: Free-form prefix shown in log lines. Defaults to+ ``"cli-agent"``; callers pass ``self.label`` for sessions+ and ``f"pool {memory_node_id}"`` for the pool path.+ """+ skill_list = [s for s in skill_names if s]+ if not skill_list:+ return 0++ # Lazy import — the skill loader pulls the YAML parser + sqlmodel+ # which we don't want to charge on module import.+ from services.skill_loader import get_skill_loader++ loader = get_skill_loader()+ skills_dir = Path(cwd) / ".claude" / "skills"+ try:+ skills_dir.mkdir(parents=True, exist_ok=True)+ except OSError as exc:+ logger.warning(+ "[%s] cannot create skills dir %s: %s — skipping materialisation",+ log_label, skills_dir, exc,+ )+ return 0++ written = 0+ for name in skill_list:+ try:+ skill = await loader.load_skill_async(name)+ except Exception as exc:+ logger.warning(+ "[%s] load_skill_async(%r) failed: %s",+ log_label, name, exc,+ )+ continue+ if skill is None:+ logger.warning(+ "[%s] skill %r not found — skipping materialisation",+ log_label, name,+ )+ continue++ dest = skills_dir / name+ try:+ if skill.metadata.path is not None:+ # Filesystem skill: copy whole directory tree so+ # `scripts/` + `references/` survive intact.+ shutil.copytree(skill.metadata.path, dest, dirs_exist_ok=True)+ else:+ # DB skill: reconstruct frontmatter + body.+ dest.mkdir(parents=True, exist_ok=True)+ frontmatter = {+ "name": skill.metadata.name,+ "description": skill.metadata.description,+ "allowed-tools": " ".join(skill.metadata.allowed_tools),+ "metadata": skill.metadata.metadata,+ }+ body = (+ f"---\n"+ f"{yaml.safe_dump(frontmatter, sort_keys=False)}"+ f"---\n\n"+ f"{skill.instructions}"+ )+ (dest / "SKILL.md").write_text(body, encoding="utf-8")+ written += 1+ logger.info(+ "[%s] materialised skill %r -> %s", log_label, name, dest,+ )+ except OSError as exc:+ logger.warning(+ "[%s] failed to materialise skill %r at %s: %s",+ log_label, name, dest, exc,+ )++ return writtendiff --git a/server/services/cli_agent/providers/anthropic_claude.py b/server/services/cli_agent/providers/anthropic_claude.pyindex 2e3755ef..47ef07bf 100644--- a/server/services/cli_agent/providers/anthropic_claude.py+++ b/server/services/cli_agent/providers/anthropic_claude.py@@ -18,8 +18,11 @@ Subprocess: ``claude --permission-mode bypassPermissions`claude` discovers `mcp__machinaos__*` tools via `tools/list`.- ``--allowedTools`` carries the explicit allowlist (built-ins +every wired MCP tool) — same shape as the prior headless path.- - Skills are still materialised under ``<cwd>/.claude/skills/`` by- ``AICliSession._materialise_skills`` (unchanged).+ - Skills are materialised under ``<cwd>/.claude/skills/`` by the+ shared :func:`services.cli_agent._skills.materialise_skills`+ helper (called from both ``AICliSession._pre_spawn`` AND+ ``ClaudeSessionPool._spawn``); ``Skill`` enters+ ``--allowedTools`` iff at least one skill is wired.**Permission mode**: ``bypassPermissions`` lets every allowlist entryfire without a TUI prompt — non-interactive automation has no human at@@ -106,6 +109,7 @@ class AnthropicClaudeProvider:mcp_endpoint_url: Optional[str] = None,mcp_bearer_token: Optional[str] = None,connected_tool_names: Optional[List[str]] = None,+ connected_skill_names: Optional[List[str]] = None,include_prompt: bool = True,) -> List[str]:"""Build the full argv for one ``claude`` invocation, VSCode-style.@@ -250,6 +254,18 @@ class AnthropicClaudeProvider:allowed_list += [f"mcp__machinaos__{name}" for name in connected_tool_names]+ # Conditionally enable claude's built-in ``Skill`` tool ONLY+ # when at least one skill is wired through ``input-skill``.+ # The spawn path (pool + non-pool) materialises connected+ # SKILL.md files under ``<cwd>/.claude/skills/`` via the+ # shared :func:`services.cli_agent._skills.materialise_skills`+ # helper, so the built-in skill loader has something to+ # discover. Skills accessed by name (`Skill <name>`) load+ # those materialised files. If no skill is wired, ``Skill``+ # stays disabled — strict allowlist invariant holds (see+ # ``test_no_claude_builtins_in_default_allowlist``).+ if connected_skill_names:+ allowed_list.append("Skill")# MachinaOs's own MCP infrastructure tools — needed for the# agent to discover connected skills, read its workspace, and# surface intermediate progress. These are OUR tools, notdiff --git a/server/services/cli_agent/service.py b/server/services/cli_agent/service.pyindex 83963e8f..94cfe7c1 100644--- a/server/services/cli_agent/service.py+++ b/server/services/cli_agent/service.py@@ -262,6 +262,7 @@ class AICliService:mcp_port=port,mcp_bearer_token=token,connected_tools=connected_tools or [],+ connected_skill_names=list(connected_skill_names or []),workflow_id=workflow_id,)]else:@@ -393,6 +394,7 @@ class AICliService:mcp_port: int,mcp_bearer_token: str,connected_tools: List[Dict[str, Any]],+ connected_skill_names: List[str],workflow_id: str,) -> SessionResult:"""Route one memory-bound claude turn through ``ClaudeSessionPool``.@@ -439,6 +441,7 @@ class AICliService:mcp_endpoint_url=mcp_endpoint_url,mcp_bearer_token=mcp_bearer_token,connected_tool_names=tool_names,+ connected_skill_names=connected_skill_names,workflow_id=workflow_id,)try:diff --git a/server/services/cli_agent/session.py b/server/services/cli_agent/session.pyindex 395ba309..8ec2de9a 100644--- a/server/services/cli_agent/session.py+++ b/server/services/cli_agent/session.py@@ -37,7 +37,6 @@ import asyncioimport jsonimport osimport re-import shutilimport sysimport timeimport uuid@@ -45,7 +44,6 @@ from pathlib import Pathfrom typing import Any, Dict, List, Optionalimport anyio-import yamlfrom core.logging import get_loggerfrom services._supervisor.process import BaseProcessSupervisor@@ -175,6 +173,7 @@ class AICliSession(BaseProcessSupervisor):mcp_endpoint_url=self._mcp_endpoint_url(),mcp_bearer_token=self._batch_token,connected_tool_names=self._connected_tool_names,+ connected_skill_names=self._connected_skill_names,)def _mcp_endpoint_url(self) -> str:@@ -264,87 +263,14 @@ class AICliSession(BaseProcessSupervisor):# 3. Materialise connected skills under cwd's `.claude/skills/`.# cwd is repo_root for memory-bound, worktree otherwise — both- # are project-scope per the spec.+ # are project-scope per the spec. Same helper now also runs on+ # the pool path (``ClaudeSessionPool._spawn``) so memory-bound+ # runs get the built-in ``Skill`` tool too.if self._connected_skill_names:- await self._materialise_skills()-- async def _materialise_skills(self) -> None:- """Write `<worktree>/.claude/skills/<name>/SKILL.md` for each- connected skill so the spawned claude can invoke them via the- built-in `Skill` tool. Filesystem skills are copied wholesale- (preserves `scripts/` + `references/`); DB skills are- reconstructed from frontmatter.-- Only ``AICliSession`` (the non-pooled, one-shot agent path)- calls this. ``ClaudeSessionPool`` (the pooled, memory-bound- path) leaves skills accessible via the FastMCP server's- ``listSkills``/``getSkill`` tools instead. Switching the pool- to the standard ``--add-dir`` skill discovery is tracked- separately (requires restructuring ``server/skills/`` to the- Agent Skills `<root>/.claude/skills/<name>/SKILL.md` shape).- """- from services.skill_loader import get_skill_loader-- loader = get_skill_loader()- # cwd-relative — repo_root for memory-bound runs, worktree otherwise.- skills_dir = self.cwd() / ".claude" / "skills"- try:- skills_dir.mkdir(parents=True, exist_ok=True)- except OSError as exc:- logger.warning(- "[%s] cannot create skills dir %s: %s — skipping",- self.label, skills_dir, exc,+ from services.cli_agent._skills import materialise_skills+ await materialise_skills(+ self.cwd(), self._connected_skill_names, log_label=self.label,)- return-- for name in self._connected_skill_names:- try:- skill = await loader.load_skill_async(name)- except Exception as exc:- logger.warning(- "[%s] load_skill_async(%r) failed: %s",- self.label, name, exc,- )- continue- if skill is None:- logger.warning(- "[%s] skill %r not found — skipping materialisation",- self.label, name,- )- continue-- dest = skills_dir / name- try:- if skill.metadata.path is not None:- # Filesystem skill: copy whole directory tree.- shutil.copytree(- skill.metadata.path, dest, dirs_exist_ok=True,- )- else:- # DB skill: reconstruct frontmatter + body.- dest.mkdir(parents=True, exist_ok=True)- frontmatter = {- "name": skill.metadata.name,- "description": skill.metadata.description,- "allowed-tools": " ".join(skill.metadata.allowed_tools),- "metadata": skill.metadata.metadata,- }- body = (- f"---\n"- f"{yaml.safe_dump(frontmatter, sort_keys=False)}"- f"---\n\n"- f"{skill.instructions}"- )- (dest / "SKILL.md").write_text(body, encoding="utf-8")- logger.info(- "[CC-Agent _pre_spawn] materialised skill %r -> %s",- name, dest,- )- except OSError as exc:- logger.warning(- "[%s] failed to materialise skill %r at %s: %s",- self.label, name, dest, exc,- )# ------------------------------------------------------------------# _do_start: PTY spawn + JSONL watcher (interactive cutover)diff --git a/server/services/cli_agent/session_pool.py b/server/services/cli_agent/session_pool.pyindex bc6c3eb9..731eb34f 100644--- a/server/services/cli_agent/session_pool.py+++ b/server/services/cli_agent/session_pool.py@@ -212,6 +212,7 @@ class ClaudeSessionPool:mcp_endpoint_url: Optional[str],mcp_bearer_token: Optional[str],connected_tool_names: Optional[List[str]] = None,+ connected_skill_names: Optional[List[str]] = None,workflow_id: Optional[str] = None,) -> PooledClaudeSession:"""Return a live :class:`PooledClaudeSession`.@@ -302,6 +303,7 @@ class ClaudeSessionPool:mcp_endpoint_url=mcp_endpoint_url,mcp_bearer_token=mcp_bearer_token,connected_tool_names=connected_tool_names,+ connected_skill_names=connected_skill_names,)# Track the spawn-time bearer token so subsequent batches can# rebind the persistent BatchContext in place (warm-reuse@@ -502,8 +504,22 @@ class ClaudeSessionPool:mcp_endpoint_url: Optional[str],mcp_bearer_token: Optional[str],connected_tool_names: Optional[List[str]],+ connected_skill_names: Optional[List[str]] = None,) -> PooledClaudeSession:"""Cold-spawn a new pooled claude subprocess. Caller holds pool_lock."""+ # Materialise connected skills under ``<cwd>/.claude/skills/``+ # BEFORE spawning so the spawned claude sees them on its first+ # filesystem scan. Same helper the non-pool ``AICliSession``+ # path uses. Paired with the conditional ``Skill`` entry in+ # ``--allowedTools`` (see ``interactive_argv``) — both fire when+ # ``connected_skill_names`` is non-empty.+ if connected_skill_names:+ from services.cli_agent._skills import materialise_skills+ await materialise_skills(+ cwd, connected_skill_names,+ log_label=f"pool {memory_node_id}",+ )+# ``include_prompt`` is ignored by the new ``interactive_argv``# (stream-json input mode reads the prompt from stdin), but we# pass ``False`` to make the intent explicit for any future@@ -514,6 +530,7 @@ class ClaudeSessionPool:mcp_endpoint_url=mcp_endpoint_url,mcp_bearer_token=mcp_bearer_token,connected_tool_names=connected_tool_names,+ connected_skill_names=connected_skill_names,include_prompt=False,)diff --git a/server/tests/services/cli_agent/test_providers.py b/server/tests/services/cli_agent/test_providers.pyindex 01442e49..5d6850a5 100644--- a/server/tests/services/cli_agent/test_providers.py+++ b/server/tests/services/cli_agent/test_providers.py@@ -115,11 +115,11 @@ class TestClaudeArgv:def test_no_claude_builtins_in_default_allowlist(self, claude_provider):"""Claude's built-in escape-hatch tools (Read, Edit, Bash, Glob,Grep, Write, Skill, WebSearch, WebFetch) are intentionally NOT- in the default ``--allowedTools`` list. Combined with- ``--permission-mode dontAsk`` (which gates strictly on the- allowlist) this means the agent can ONLY invoke MCP tools that- were explicitly wired through ``input-tools`` plus MachinaOs's- own MCP infrastructure tools — never the built-ins.+ in the default ``--allowedTools`` list when no skills are+ wired. Combined with ``--permission-mode dontAsk`` (which+ gates strictly on the allowlist) this means the agent can+ ONLY invoke MCP tools that were explicitly wired through+ ``input-tools`` plus MachinaOs's own MCP infrastructure tools.Disconnected workflow tools are also blocked by the per-handlerscope check in ``workflow_tools._build_handler`` reading the@@ -146,6 +146,50 @@ class TestClaudeArgv:assert "mcp__machinaos__getCredential" in entriesassert "mcp__machinaos__broadcastLog" in entries+ def test_skill_builtin_conditional_on_wired_skills(self, claude_provider):+ """``Skill`` is the one claude built-in we conditionally allow+ — present in ``--allowedTools`` iff at least one skill is wired+ through the agent's ``input-skill`` handle. Paired with+ :func:`services.cli_agent._skills.materialise_skills` which+ writes the connected SKILL.md trees under+ ``<cwd>/.claude/skills/`` before spawn so the built-in skill+ loader has something to discover.++ When no skill is wired, ``Skill`` stays out of the allowlist+ (the strict-allowlist invariant from+ :meth:`test_no_claude_builtins_in_default_allowlist` still+ holds for that path).+ """+ task = ClaudeTaskSpec(prompt="x")++ # No skills wired → Skill stays out.+ argv_no_skills = claude_provider.interactive_argv(task, defaults={})+ allowed_idx = argv_no_skills.index("--allowedTools")+ entries_no_skills = [+ e.strip() for e in argv_no_skills[allowed_idx + 1].split(",")+ ]+ assert "Skill" not in entries_no_skills++ # Skills wired → Skill enters the allowlist.+ argv_with_skills = claude_provider.interactive_argv(+ task,+ defaults={},+ connected_skill_names=["humanify-skill", "memory-skill"],+ )+ allowed_idx = argv_with_skills.index("--allowedTools")+ entries_with_skills = [+ e.strip() for e in argv_with_skills[allowed_idx + 1].split(",")+ ]+ assert "Skill" in entries_with_skills+ # Other built-ins still stay out — only Skill is conditionally+ # enabled. The rest (Read, Edit, Bash, etc.) are never+ # auto-added by the allowlist builder.+ for forbidden in (+ "Read", "Edit", "Bash", "Glob", "Grep", "Write",+ "WebSearch", "WebFetch",+ ):+ assert forbidden not in entries_with_skills+def test_no_session_id_flag_in_interactive(self, claude_provider):"""Claude assigns its own session UUID in interactive mode; weno longer pre-mint a UUID and pass it via `--session-id`. The