{"id":"self-customize","name":"self-customize","summary":"自分だけのエージェントをカスタマイズしましょう — 機能の追加、パッケージのインストール、MCPサーバーの追加、コードの編集など CLAUDE.md。","body":"# Self-Customization\n\nYou can modify your own environment. Different kinds of changes have different workflows.\n\n## Decision Tree\n\n**What needs to change?**\n\n- **Memory or standing instructions** → Edit `memory/` or `instructions.prepend.md` directly, no approval needed. The workspace is persisted on the host. The composed provider document (`CLAUDE.md` or `AGENTS.md`) is regenerated every spawn and must not be edited.\n- **System package (apt) or global npm package** → `install_packages`. Requires admin approval. On approval, image rebuild + container restart happen automatically.\n- **MCP server** → `add_mcp_server`. Requires admin approval. On approval, container restarts with the new server wired up (no rebuild — bun runs TS directly).\n- **Your source code or Dockerfile** → Delegate to a builder agent via `create_agent` (see below).\n- **A new specialist capability** → `create_agent` to spin up a dedicated agent for it.\n\n## Workflow: Code Changes via Builder Agent\n\nFor anything that requires editing source files (your own code, Dockerfile, etc.), **do not edit directly** — delegate to a builder agent. This gives the user a reviewable boundary and keeps your main session focused.\n\n1. Describe what you need changed in concrete terms (files, behavior, acceptance criteria)\n2. Call `create_agent({ name: \"Builder\", instructions: \"<builder prompt>\" })` — the returned agent group ID is your builder\n3. Call `send_to_agent({ agentGroupId, text: \"<task description with specific files and changes>\" })`\n4. The builder works in its own container, makes the changes, and reports back\n5. You review the builder's summary and confirm with the user. Source-code edits inside `/app/src` are picked up automatically on the next container start — no rebuild step needed (bun runs TS directly). If the builder also installed packages, its own `install_packages` approval will have rebuilt the image.\n\n### Builder Agent Instructions (use as CLAUDE.md when creating)\n\n```\nYou are a builder agent. Your job is to make precise, minimal code changes to NanoClaw source files when the main agent requests it.\n\n## Rules\n\n- **Minimal scope.** Only change what was requested. Do not refactor surrounding code, \"improve\" unrelated files, or add features not asked for.\n- **Diff size limits.** Reject any change that exceeds 200 new lines or 150 modified lines in a single task. If the change is larger, push back and ask for it to be split into smaller tasks.\n- **Read before writing.** Always read the target file fully before editing. Understand the existing patterns.\n- **Test if possible.** If there are relevant tests, run them after your change.\n- **Report back.** When done, use send_to_agent to tell the requesting agent: (a) what files you changed, (b) a summary of the changes, (c) any follow-up needed (rebuild, tests, migrations).\n- **No silent failures.** If you can't complete the task, explain why — don't produce partial work without flagging it.\n\n## Safety\n\n- Never edit files outside the requested scope\n- Never commit or push anything\n- Never modify secrets, credentials, or .env files\n- If a change would break existing tests, stop and report\n```\n\n## Diff Size Limits — Why\n\nA 50-line focused change is reviewable. A 500-line sweep is not. Hard limits force the agent to decompose work into reviewable chunks, which:\n\n- Makes human approval meaningful (you can actually read 150 lines)\n- Catches runaway edits early (if the first task hits the limit, the scope was wrong)\n- Forces clear acceptance criteria per task\n\nThe limits are **per builder task**, not per session. A 500-line feature is fine as 4 sequential builder tasks of ~125 lines each, each with its own scope.\n\n## Example: Adding a New MCP Tool to Yourself\n\nUser: \"Can you add a tool for reading RSS feeds?\"\n\n1. Check [mcp.so](https://mcp.so) for an existing RSS MCP server\n2. If one exists → `add_mcp_server({ name: \"rss\", command: \"npx\", args: [\"some-rss-mcp\"] })` → admin approves → container restarts with the new server → done\n3. If nothing suitable exists → delegate to a builder agent:\n   - `create_agent({ name: \"RSS Tool Builder\", instructions: \"<builder prompt from above>\" })`\n   - `send_to_agent({ agentGroupId, text: \"Add an MCP tool 'read_rss' to container/agent-runner/src/mcp-tools/. It should fetch an RSS URL and return the latest N items. Register it in mcp-tools/index.ts. Target: <200 new lines.\" })`\n   - Wait for builder's report — new tool code is picked up on the next container start (bun runs TS directly)\n\n## Example: Installing a System Tool\n\nUser: \"Can you transcribe audio?\"\n\n1. Check what's available — `which ffmpeg` (likely not installed in base image)\n2. Decide approach: `@xenova/transformers` (npm, workspace-local) or `whisper.cpp` (apt + compile)\n3. For persistent system tool: `install_packages({ apt: [\"ffmpeg\"], npm: [\"@xenova/transformers\"], reason: \"Audio transcription for voice messages\" })`\n4. Wait for admin approval — on approve, the image is rebuilt and your container is restarted automatically\n5. Test the new capability once the container restarts\n\n## When NOT to Self-Customize\n\n- **The change is for a one-off task** — just do it in your workspace, don't modify the container\n- **The request is ambiguous** — ask the user what they actually need before spinning up builders or requesting installs\n- **You don't know if it will work** — prototype in your workspace first (`pnpm install` in `/workspace/agent/`), then promote to container-level install if it proves useful","author":"@nanocoai","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/nanocoai/nanoclaw/tree/main/container/skills/self-customize","license":"MIT","category":"document","lang":"en","tokens":1281,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["mcp.so"]}}