/new-dcode-agent
Scaffold a new Deep Agents (LangChain) agent, a dcode CLI agent, or both, from one command. Use ONLY when the user explicitly runs /new-dcode-agent; never auto-trigger. It interviews the user (form, name, purpose, tools, model, safety), shows a spec, and on confirmation writes a
$ npx -y skills add EliaAlberti/dcode-agent-kit --skill new-dcode-agent --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/new-dcode-agent
Context preview
The summary Claude sees to decide when to auto-load this skill.
Scaffold a new Deep Agents (LangChain) agent, a dcode CLI agent, or both, from one command. Use ONLY when the user explicitly runs /new-dcode-agent; never auto-trigger. It interviews the user (form, name, purpose, tools, model, safety), shows a spec, and on confirmation writes a
SKILL.md
new-dcode-agent.SKILL.mdname: new-dcode-agent
description: Scaffold a new Deep Agents (LangChain) agent, a dcode CLI agent, or both, from one command. Use ONLY when the user explicitly runs /new-dcode-agent; never auto-trigger. It interviews the user (form, name, purpose, tools, model, safety), shows a spec, and on confirmation writes a self-contained agent into the user's current project (and/or a dcode CLI agent under ~/.deepagents). The agents it writes work with any OpenAI-compatible API via environment variables.
disable-model-invocation: true
/new-dcode-agent
You are running the **/new-dcode-agent** skill. It scaffolds a working agent for the user. Everything it writes is SELF-CONTAINED, so it works from any folder, with no dependency on this skill's own location. Run no `git`; the user commits.
The three forms (keep them straight)
- **SDK program**: a standalone Python agent (LangChain `create_deep_agent`) the user runs or deploys. Scaffolded into `./<name>/` in the user's current directory.
- **dcode agent**: a named identity for the dcode CLI (an `AGENTS.md`) the user chats with via `/agents`. Scaffolded into `~/.deepagents/<name>/AGENTS.md`.
- **both**: a dcode agent that acts as the cockpit for a deployed SDK program.
(This is NOT Claude Code's own subagents, which are a different feature.)
Phase 1: Interview (use AskUserQuestion; batch related questions)
1. **Form**: SDK program / dcode agent / both. 2. **name** (kebab-case; reject names starting with `_`, names that match an existing target, or shell-unsafe names). 3. **purpose**: one or two sentences. 4. **(SDK or both)**: closest starting flavour (custom / project / work-jira / vps-ops / personal); the tools it needs (plain Python functions, plus any MCP servers); the **model** (a `provider:model` string for any LangChain provider, or the bundled env-driven connector below); **does it change anything?** (if yes, it gets an approval gate); how it will run (one-shot / long-running / scheduled / server). 5. **(dcode agent or both)**: what it knows and operates; which tools or MCP it leans on; its operating rules.
Phase 2: Spec
Show the user exactly what you will create: the target paths, the tools, the model, and the safety posture. Wait for explicit confirmation. Do not write anything until they confirm.
Phase 3: Scaffold
SDK program (form = SDK or both): write `./<name>/` in the user's current directory
Create the folder `<name>/` with three files. It is self-contained: `agent.py` imports its connector from the sibling `model.py` (a same-directory import, so there is no path manipulation at all).
**`<name>/model.py`** (write this verbatim; the env-driven, provider-agnostic connector):
"""Model connector for this agent. Provider-agnostic, configured from the environment.
Targets any OpenAI-compatible Chat Completions endpoint (OpenAI itself, or a compatible
gateway). Set these in the environment or a .env file next to this agent:
LLM_API_KEY (or OPENAI_API_KEY) required
LLM_BASE_URL (or OPENAI_BASE_URL) optional; omit for OpenAI's default endpoint
LLM_MODEL optional; the model id (default below)
USE_RESPONSES_API optional; set 1 only if your provider supports it
"""
from __future__ import annotations
import os
import pathlib
from langchain_openai import ChatOpenAI
DEFAULT_MODEL = "gpt-4o-mini" # override via LLM_MODEL or the model= argument
def _load_env() -> None:
"""Minimal .env loader (no extra deps): this agent's folder, then the current
directory, then ~/.deepagents/.env. Existing environment variables always win."""
here = pathlib.Path(__file__).resolve().parent
for path in (here / ".env", pathlib.Path.cwd() / ".env",
pathlib.Path.home() / ".deepagents" / ".env"):
if not path.is_file():
continue
for line in path.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
os.environ.setdefault(key.strip(), value.strip())
def chat_model(model: str | None = None, *, temperature: float = 0.0, **kwargs) -> ChatOpenAI:
"""Return a ChatOpenAI wired to your OpenAI-compatible provider, from env."""
_load_env()
key = os.environ.get("LLM_API_KEY") or os.environ.get("OPENAI_API_KEY")
if not key:
raise RuntimeError("No API key. Set LLM_API_KEY (or OPENAI_API_KEY) in the "
"environment or a .env file next to this agent.")
base_url = os.environ.get("LLM_BASE_URL") or os.environ.get("OPENAI_BASE_URL") or None
use_responses = os.environ.get("USE_RESPONSES_API", "").strip().lower() in ("1", "true", "yes")
return ChatOpenAI(base_url=base_url, api_key=key,
model=model or os.environ.get("LLM_MODEL") or DEFAULT_MODEL,
temperature=temperature, use_responses_api=use_responses, **kwargs)**`<name>/agent.py`** (base, non-mutating flavour; fill in `system_prompt` and real tools):
"""<name>: a Deep Agents SDK agent. Run: python agent.py "your prompt" """
from __future__ import annotations
import sys
from model import chat_model # sibling model.py, same-directory import
from deepagents import create_deep_agent
def example_tool(query: str) -> str:
"""Describe what this tool does (stub; replace)."""
return f"[stub] {query}"
SYSTEM_PROMPT = """You are a helpful agent. TODO: describe the role, scope, and rules."""
def build_agent():
return create_deep_agent(
model=chat_model(), # your provider/model from env; pass an id to override
tools=[example_tool],
system_prompt=SYSTEM_PROMPT,
)
if __name__ == "__main__":
agent = build_agent()
prompt = " ".join(sys.argv[1:]) or "Hello"
res = agent.invoke({"messages": [{"role": "user", "content": prompt}]})
print(res["Read more
name: new-dcode-agent description: Scaffold a new Deep Agents (LangChain) agent, a dcode CLI agent, or both, from one command. Use ONLY when the user explicitly runs /new-dcode-agent; never auto-trigger. It interviews the user (form, name, purpose, tools, model, safety), shows a spec, and on confirmation writes a self-contained agent into the user's current project (and/or a dcode CLI agent under ~/.deepagents). The agents it writes work with any OpenAI-compatible API via environment variables. disable-model-invocation: true
/new-dcode-agent
You are running the **/new-dcode-agent** skill. It scaffolds a working agent for the user. Everything it writes is SELF-CONTAINED, so it works from any folder, with no dependency on this skill's own location. Run no `git`; the user commits.
The three forms (keep them straight)
- **SDK program**: a standalone Python agent (LangChain `create_deep_agent`) the user runs or deploys. Scaffolded into `./<name>/` in the user's current directory.
- **dcode agent**: a named identity for the dcode CLI (an `AGENTS.md`) the user chats with via `/agents`. Scaffolded into `~/.deepagents/<name>/AGENTS.md`.
- **both**: a dcode agent that acts as the cockpit for a deployed SDK program.
(This is NOT Claude Code's own subagents, which are a different feature.)
Phase 1: Interview (use AskUserQuestion; batch related questions)
1. **Form**: SDK program / dcode agent / both. 2. **name** (kebab-case; reject names starting with `_`, names that match an existing target, or shell-unsafe names). 3. **purpose**: one or two sentences. 4. **(SDK or both)**: closest starting flavour (custom / project / work-jira / vps-ops / personal); the tools it needs (plain Python functions, plus any MCP servers); the **model** (a `provider:model` string for any LangChain provider, or the bundled env-driven connector below); **does it change anything?** (if yes, it gets an approval gate); how it will run (one-shot / long-running / scheduled / server). 5. **(dcode agent or both)**: what it knows and operates; which tools or MCP it leans on; its operating rules.
Phase 2: Spec
Show the user exactly what you will create: the target paths, the tools, the model, and the safety posture. Wait for explicit confirmation. Do not write anything until they confirm.
Phase 3: Scaffold
SDK program (form = SDK or both): write `./<name>/` in the user's current directory
Create the folder `<name>/` with three files. It is self-contained: `agent.py` imports its connector from the sibling `model.py` (a same-directory import, so there is no path manipulation at all).
**`<name>/model.py`** (write this verbatim; the env-driven, provider-agnostic connector):
"""Model connector for this agent. Provider-agnostic, configured from the environment.
Targets any OpenAI-compatible Chat Completions endpoint (OpenAI itself, or a compatible
gateway). Set these in the environment or a .env file next to this agent:
LLM_API_KEY (or OPENAI_API_KEY) required
LLM_BASE_URL (or OPENAI_BASE_URL) optional; omit for OpenAI's default endpoint
LLM_MODEL optional; the model id (default below)
USE_RESPONSES_API optional; set 1 only if your provider supports it
"""
from __future__ import annotations
import os
import pathlib
from langchain_openai import ChatOpenAI
DEFAULT_MODEL = "gpt-4o-mini" # override via LLM_MODEL or the model= argument
def _load_env() -> None:
"""Minimal .env loader (no extra deps): this agent's folder, then the current
directory, then ~/.deepagents/.env. Existing environment variables always win."""
here = pathlib.Path(__file__).resolve().parent
for path in (here / ".env", pathlib.Path.cwd() / ".env",
pathlib.Path.home() / ".deepagents" / ".env"):
if not path.is_file():
continue
for line in path.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
os.environ.setdefault(key.strip(), value.strip())
def chat_model(model: str | None = None, *, temperature: float = 0.0, **kwargs) -> ChatOpenAI:
"""Return a ChatOpenAI wired to your OpenAI-compatible provider, from env."""
_load_env()
key = os.environ.get("LLM_API_KEY") or os.environ.get("OPENAI_API_KEY")
if not key:
raise RuntimeError("No API key. Set LLM_API_KEY (or OPENAI_API_KEY) in the "
"environment or a .env file next to this agent.")
base_url = os.environ.get("LLM_BASE_URL") or os.environ.get("OPENAI_BASE_URL") or None
use_responses = os.environ.get("USE_RESPONSES_API", "").strip().lower() in ("1", "true", "yes")
return ChatOpenAI(base_url=base_url, api_key=key,
model=model or os.environ.get("LLM_MODEL") or DEFAULT_MODEL,
temperature=temperature, use_responses_api=use_responses, **kwargs)**`<name>/agent.py`** (base, non-mutating flavour; fill in `system_prompt` and real tools):
"""<name>: a Deep Agents SDK agent. Run: python agent.py "your prompt" """
from __future__ import annotations
import sys
from model import chat_model # sibling model.py, same-directory import
from deepagents import create_deep_agent
def example_tool(query: str) -> str:
"""Describe what this tool does (stub; replace)."""
return f"[stub] {query}"
SYSTEM_PROMPT = """You are a helpful agent. TODO: describe the role, scope, and rules."""
def build_agent():
return create_deep_agent(
model=chat_model(), # your provider/model from env; pass an id to override
tools=[example_tool],
system_prompt=SYSTEM_PROMPT,
)
if __name__ == "__main__":
agent = build_agent()
prompt = " ".join(sys.argv[1:]) or "Hello"
res = agent.invoke({"messages": [{"role": "user", "content": prompt}]})
print(res["Showing the first part of this file.
A Claude Code skill that scaffolds ready-to-run LangChain Deep Agents and dcode CLI agents into any project.

