/samocode:samocode-runfrom samocode
Runs and monitors the samocode autonomous session orchestrator on projects. Starts the Python worker and monitors its output when the user explicitly requests autonomous execution.
Ships in samocode. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Runs the samocode autonomous orchestrator on a project session and monitors its progress.
When user asks to "run samocode" or "continue samocode", you MUST use this skill.
DO NOT:
_overview.md only for status/monitoring_overview.md, _signal.json, or _signal_history.jsonl to advance, unblock, rewind, or complete a sessionThe Python worker (main.py) handles ALL of this. Your job is to START the worker and MONITOR its output.
If the user names a remote host ("on pod2", "on the server"), use the samocode-remote
skill instead: same rules, worker runs over SSH.
Use this skill when user says:
/samocode-implementSamocode is an autonomous session orchestrator that runs the configured AI CLI provider in a loop to complete complex tasks. It:
_overview.mdFor workflow details and phase definitions, see the installed workflow.md. For model
routing, defaults, and migration behavior, see docs/model-routing.md in the Samocode
source/package.
There's no strict "samocode session" - just sessions. Any session can be worked on:
Human judgment can supply inputs and approve supported gates. Once the worker owns a session lifecycle, only its CLI services may mutate lifecycle state; manual engineering work never authorizes hand-editing workflow control files.
Only when user explicitly asks for samocode (see Trigger Phrases above).
Do NOT assume samocode should run just because a session exists.
Arguments: $ARGUMENTS (session name or project path with session name)
Find .samocode config:
.samocode file in current working dir or project path.samocode file (e.g., ~/project/.samocode).samocode file is missing: ERROR and ask user to create itDetermine session name:
$ARGUMENTS is a session name (e.g., "my-task"), use it directly$ARGUMENTS includes a path, extract session name from itCheck session state (if exists):
_overview.md Status sectionPhase is not one of init|investigation|requirements|planning|implementation|testing|quality|pr-readiness|done:
report the exact value and stop. Do not edit _overview.md; the worker refuses
unknown phases at preflight, and only the human repairs the field./samocode-implement equivalent:
Phase: planning and the session is waiting for plan approval (Blocked: waiting_human, Next: Await plan approval, or _signal.json has "for": "plan_approval"), approve the gate before starting samocode:
samocode approve --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME]
The approval service atomically advances the overview state (Phase → implementation, Blocked → no) and consumes the pending signal. Do NOT manually edit _overview.md or _signal.json.Phase: done:
_overview.md; create a new
session for new work unless a dedicated worker command supports reopening.Blocked: workflow_error:
worktree_mutated guard rejection (testing mutated tracked files;
Last Action names the phase and a HEAD/tracked-path delta): report the delta, then
have the human inspect and restore the working dir themselves —
git -C [WORKING_DIR] status to see the change, git -C [WORKING_DIR] checkout -- <path> (or reset the stray commit) to undo it — and restart the worker. Do NOT run
recover final-polish for this class and never edit _overview.md/_signal.json.worktree_unverifiable guard rejection (the post-run git snapshot
could not run, so the guard could not confirm the working dir is unchanged — git
broke or the repo went away, nothing was necessarily mutated): have the human
confirm the working dir is still a healthy git repo (git -C [WORKING_DIR] status)
and fix whatever broke git before restarting the worker. Same handling class as
worktree_mutated: never run recover final-polish and never edit control files.samocode recover final-polish --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME] --check
samocode recover final-polish --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME] --apply
_recovery/ snapshot, preserves
_signal_history.jsonl, and returns to completed implementation so the worker
can honestly replay testing → quality → testing → pr-readiness. Restart the
worker normally after the command succeeds.Blocked: yes, blocked, or waiting_human:
Understand routing before startup:
$XDG_CONFIG_HOME/samocode/config.toml when
XDG_CONFIG_HOME is absolute; otherwise ~/.config/samocode/config.toml.samocode install creates defaults only when the file is absent and never
overwrites an existing config.--provider → SAMOCODE_PROVIDER → config
default_provider → legacy claude.samocode install before autonomous work.Start samocode:
samocode run \
--config [PATH_TO_.SAMOCODE] \
--session [SESSION_NAME] 2>&1
Optional: Add --provider claude|codex to override provider selection for this
process, or --timeout SECONDS for the per-iteration time limit (default: 1800s = 30 min).
Each child agent iteration is killed if it exceeds this. Increase for complex phases:
samocode run --config ... --session ... --provider codex --timeout 3600
Do NOT wrap with bash timeout - The orchestrator manages its own timeouts via --timeout.
External timeouts can kill iterations mid-work and corrupt session state.
Run this using the host's background execution facility (run_in_background: true
where available, or a short-yield process handle). Retain the handle for supervision.
Avoid reading background task output directly. The samocode worker output includes full
Agent CLI logs which are large (100KB+ per iteration). Monitor progress via _overview.md
and other session files instead.
If debugging requires checking task output (e.g., investigating a crash):
grep to search for specific errors or patterns firsttail -n 2 or tail -n 5 max - each line can be huge (full JSON)Read with offset and limit to read small portionsMonitor loop (prefer session files over task output):
6.1. Start background check (sleep duration by phase: investigation/planning 60s, implementation 120-180s, quality 120s, testing 60s):
Bash(command="sleep 60 && samocode status --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME]", run_in_background=true)
samocode status is read-only and prints Phase/Iteration/Blocked/Worker/Signal/Last/Next plus the last Flow Log entries (--flow N, --json for machine parsing). Fall back to cat [SESSION]/_overview.md only if the CLI is unavailable.
Returns task_id (e.g., "b155903")
6.2. Between checks, do independent work already authorized by the user. When
running with companion, use its bounded-work monitoring loop and session HTML
guidance; do not block immediately on the delayed check. Read its result when
ready, and check the worker handle for unexpected exit. If there is no useful
independent work, use the host's wait mechanism without busy polling. Do not let
companion work postpone checks indefinitely or mutate the worker's code/lifecycle.
6.3. Extract from result: Phase, Iteration, Total Iterations, Blocked, Last Action, Next, last 3 Flow Log entries
6.4. Get recent commits:
git -C [WORKING_DIR] log --oneline -3
6.5. Report to user:
Samocode Progress [HH:MM elapsed]
--------------------------------
Phase: [phase] (Iteration N/Total)
Last: [Last Action]
Next: [Next]
Recent commits:
- [hash] [message]
Flow:
- [last 2-3 Flow Log entries]
6.6. Check stop condition:
Phase: done → if the session has a companion HTML server, follow the sibling
companion/SKILL.md "Required server cleanup" procedure before reporting closure;
preserve the local HTML and report the external URL as offline. Report final summary, STOPBlocked: contains workflow_error, yes, or waiting → handle accordingly, STOPIMPORTANT: On STOP, clean up monitoring. When samocode finishes (done/blocked/waiting), do NOT leave pending background sleep tasks running. Stop any active monitoring task via TaskStop before reporting the final status. This prevents stale notification floods.
When samocode signals waiting:
Auto-approve/answer ONLY if user explicitly requested it (e.g., "run samocode and approve", "accept suggestions", "auto-approve"). Otherwise, report the waiting state and wait for user decision.
For waiting_for: plan_approval:
_overview.md or _signal.json):
samocode approve --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME]
The service validates the pending gate, atomically advances the overview (Phase → implementation, Blocked → no), and consumes the pending signal. Non-zero exit means approval was rejected — show the error and ask the user how to proceed.For waiting_for: qa_answers:
_qa.md with answerssamocode status --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME] [--json] [--flow N]
running when the orchestrator lease is held, stopped otherwise), Signal with
for/needs/reason, Q&A pending path, Last/Next, and the trailing Flow Log entries--json emits the same fields as one JSON object (lists for flow_log/errors)To verify the final-polish gate state without running the orchestrator:
samocode check final-polish --config [PATH_TO_.SAMOCODE] --session [SESSION_NAME]
pr-readiness -> done gate would passPhase/Blocked precondition — safe mid-sessionQuality and pr-readiness agents run this command as a self-check after writing reports or the ledger and fix vocabulary drift before routing. If you see a quality or pr-readiness agent loop unexpectedly, use this command to inspect the current gate state without waiting for the next iteration.
Testing can auto-escalate one profile rung on an environment block. This is a normal
continue, not a stop condition — the next iteration reruns testing on the stronger
profile. Recognize it in the Flow Log so you report it as progress, not a failure:
- [NNN @ MM-DD HH:MM] Escalation: testing strong (model/effort) -> max (model/effort); blocker: <reason>
Blocked stays no, Last Action reads "Testing blocked on environment; escalating
strong -> max", Next reads "Escalated testing attempt N/M".source=escalation and
escalated_from=<profile>; _signal_history.jsonl gains a status=escalation row.blocked state, do not
restart hoping for another escalation..samocode FileEvery project using samocode MUST have a .samocode file in its root:
MAIN_REPO=~/path/to/main/repo
WORKTREES=~/path/to/worktrees/
SESSIONS=~/path/to/_sessions/
All three keys are REQUIRED:
MAIN_REPO: The main working directory (where the child agent runs)SESSIONS: Where samocode session folders are storedWORKTREES: Where git worktrees are createdSessions are stored in SESSIONS dir (from .samocode file), NOT nested inside projects:
[SESSIONS_DIR]/
└── [YY-MM-DD]-[session-name]/ # Session folder (e.g., 26-01-15-pyright-ci)
├── _overview.md # Main session state
├── _signal.json # Control signal
├── _qa.md # Q&A when waiting for human input
├── _logs/ # Agent iteration logs (JSONL)
│ └── [MM-DD-HHMM]-[NNN]-[phase].jsonl
├── [MM-DD-HH:mm]-plan-*.md # Implementation plans
├── [MM-DD-HH:mm]-dive-*.md # Investigation reports
└── [MM-DD-HH:mm]-*.md # Other artifacts
## Status
Phase: [init|investigation|requirements|planning|implementation|testing|quality|pr-readiness|done]
Iteration: N
Blocked: [yes/no]
Last Action: [what happened]
Next: [what to do next]
## Flow Log
- [NNN @ MM-DD HH:MM] Event description -> optional-file.md
.samocode file in project root with SESSIONS, WORKTREES, MAIN_REPO~/samocode/.env has TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_IDCLAUDE_TIMEOUT or CODEX_TIMEOUT) if iterations need moresamocode install; legacy mode still runs but cannot use semantic profile routing--provider; a process never falls back to another provider mid-runsamocode recover final-polish ... --check only for the reported
final-polish provenance class; never repair history or phase fields manuallyIf samocode exhibits bugs or weird behavior (loops, wrong decisions, missing steps, etc.):
Analyze the issue:
_overview.md to see what went wrongSuggest fixes - DO NOT auto-implement:
Samocode source locations:
~/samocode/main.py, ~/samocode/worker/~/samocode/workflow.md~/samocode/skills/*/SKILL.md~/samocode/commands/*.mdCommon fix patterns:
IMPORTANT: Always propose fixes and wait for user approval. Samocode is critical infrastructure - no cowboy coding.
User: "Run samocode on the hvac project"
→ Find ~/code/hvac-voice-agent/.samocode file
→ Determine session name from context (e.g., "voice-agent")
→ Run: samocode run --config ~/code/hvac-voice-agent/.samocode --session voice-agent
→ Monitor iterations, report progress
User: "Continue the samocode session"
→ Find session name from context or ask user
→ Find .samocode file path
→ Run: samocode run --config [CONFIG_PATH] --session [SESSION_NAME]
→ Monitor iterations, report progress
Remember: You run samocode run; the Python worker resolves the execution target and runs the selected provider (Claude or Codex). You do NOT run phase agents or select their concrete models yourself.
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (yuvasee/samocode) — no native marketplace selected
npx claudepluginhub p/yuvasee-samocode20 skills in this plugin
/claudeRun Anthropic Claude CLI as a subagent for second opinions, code reviews, and questions. Use from a Codex (or other) session when you want Claude's perspective./code-clarityReview changed code for human comprehension cost — names, local reasoning, hidden state, working-memory load — and report findings with an impact/cost/risk assessment table. Review-only; never modifies code. Use when asked for a clarity review, readability review, comprehension-cost analysis of a diff/PR, or when running /code-clarity. Works in Claude Code and Codex./codexRun OpenAI Codex CLI as a subagent for second opinions, code reviews, and questions. Use when you want a different AI model's perspective./comment-hygieneCurate source-code comments and docstrings — delete AI-slop and stale comments, keep only the non-obvious WHY, and never change executable code. Use when cleaning up comments/docstrings, during a samocode cleanup or quality-review step, when running /comment-hygiene, or when reviewing a diff for comment quality. Works in Claude Code and Codex./companionStart and supervise Samocode while the parent does independent scoped work and maintains a human-readable HTML explanation in the session. Use when asked to run Samocode with a live walkthrough, companion, or parallel parent work; not for a standalone status query./create-pr-commentsCreate GitHub PR review comments from review findings. Use after running a code review to post findings as line-bound comments.Other plugins' skills for the same job