Skip to content

InferHaven/agent-skills / codetrain

codetrain

Flagged

CodeTrain is an open-source Socratic coding tutor with a local lesson page where the learner writes every line while the agent sets small steps, gives hints and reviews the work without putting the solution into the lesson. Use when the user wants to be taught/walked through code one tiny step at a time — triggers like "teach me this code", "walk me through this", "hold my hand", "explain step by step", "tutor me", "guide me through", "I want to learn this", or asks for a safe practice exercise to learn a concept.

FileKindSize
LICENSEother11.1 KB
NOTICEother768 B
README.mdmarkdown22.7 KB
SKILL.mdskill md20.1 KB
app/answer_guard.pyscript7.8 KB
app/checkpoint-hook.shexecutablescript1.2 KB
app/ctl.shexecutablescript4.5 KB
app/install-permissions.pyscript6.8 KB
app/patch.pyexecutablescript4.1 KB
app/profile.pyexecutablescript9.3 KB
app/server.pyexecutablescript23.1 KB
app/static/Archivo.woff2binary88.0 KB
app/static/JetBrainsMono.woff2binary30.7 KB
app/static/app.jsscript57.1 KB
app/static/docklint.jsscript4.3 KB
app/static/editor.jsscript4.4 KB
app/static/fonts-OFL.txtmarkdown9.0 KB
app/static/glossary.jsscript50.8 KB
app/static/index.htmlother8.0 KB
app/static/js-worker.jsscript3.9 KB
app/static/liveness.jsscript1.8 KB
app/static/logo-anim.svgother1.9 KB
app/static/prism.jsscript20.6 KB
app/static/prose.jsscript18.8 KB
app/static/pyodide-worker.jsscript7.0 KB
app/static/runner.jsscript4.5 KB
app/static/sheet.cssother32.7 KB
app/static/styles.cssother51.4 KB
app/static/theme-toggle.jsscript9.5 KB
app/static/theme.jsscript5.2 KB
app/static/visuals.jsscript14.8 KB
app/watch.shexecutablescript2.5 KB
install.shexecutablescript2.0 KB
references/session-protocol.mdmarkdown19.6 KB
references/spaced-repetition.mdmarkdown3.4 KB
references/teach-on-diff.mdmarkdown2.5 KB

app/ctl.sh

View on GitHub
#!/usr/bin/env bash
# CodeTrain control script.
#
# A single, stable entry point for the tutor's lifecycle commands, so they can be
# allow-listed once in settings.json (no per-turn permission prompts). It avoids
# inline `ENV=… python3 …` prefixes, which break Bash permission prefix-matching.
#
#   ctl.sh sandbox                         # make a throwaway /tmp/codetrain-* dir; prints its path
#   ctl.sh serve <session-dir> [code-root] # start the UI server, DETACHED (survives the session)
#   ctl.sh watch <session-dir> [iters]     # arm the event watcher (run in background)
#   ctl.sh stop  <session-dir>             # stop the server for this session
#   ctl.sh patch <session-dir>             # apply .tutor/patch.json (write it with the Write tool)
#   ctl.sh run   <session-dir>             # run the active step's tests.cmd / submitted file
#   ctl.sh profile [full]                  # the learner's brief (full profile only when they ask)
#   ctl.sh profile-update <session-dir>    # apply .tutor/profile-delta.json (write it first)
#
# Call each command STANDALONE (never inside a pipe, `;`, `&&`, or `$( )`) so one
# `Bash(bash .../ctl.sh:*)` allow-rule covers the whole live loop prompt-free.
set -u
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cmd="${1:-}"; ws="${2:-}"

case "$cmd" in
  sandbox)
    ws="$(mktemp -d /tmp/codetrain-XXXXXX)" || { echo "mktemp failed" >&2; exit 1; }
    mkdir -p "$ws/.tutor"
    printf '%s\n' "$ws" ;;
  serve)
    # <ws> = session-dir (.tutor state lives here — keep it under /tmp so it's allow-listed).
    # Optional [code-root] is where submitted code is written (local code); defaults to <ws>.
    # Detached (setsid + nohup) so the page outlives the Claude session that started it.
    [ -n "$ws" ] || { echo "usage: ctl.sh serve <session-dir> [code-root]" >&2; exit 2; }
    code="${3:-$ws}"
    mkdir -p "$ws/.tutor"
    rm -f "$ws/.tutor/url.txt"
    TUTOR_SESSION="$ws/.tutor/session.json" TUTOR_WORKSPACE="$code" \
      setsid nohup python3 "$HERE/server.py" >"$ws/.tutor/serve.log" 2>&1 </dev/null &
    for _ in $(seq 1 40); do [ -f "$ws/.tutor/url.txt" ] && break; sleep 0.1; done
    url="$(cat "$ws/.tutor/url.txt" 2>/dev/null || true)"
    [ -n "$url" ] && echo "TUTOR_URL=$url" || { echo "server failed to start; see $ws/.tutor/serve.log" >&2; exit 1; } ;;
  watch)
    [ -n "$ws" ] || { echo "usage: ctl.sh watch <workspace> [iters]" >&2; exit 2; }
    exec bash "$HERE/watch.sh" "$ws/.tutor/session.json" "${3:-900}" ;;
  stop)
    pid="$(cat "$ws/.tutor/server.pid" 2>/dev/null || true)"
    [ -n "${pid:-}" ] && kill "$pid" 2>/dev/null && echo "stopped $pid" || echo "no server running"
    ;;
  patch)
    # Applies <ws>/.tutor/patch.json (the tutor writes it with the Write tool — robust,
    # no shell quoting, no prompt). Falls back to a delta arg / stdin for back-compat.
    [ -n "$ws" ] || { echo "usage: ctl.sh patch <session-dir>  (write .tutor/patch.json first)" >&2; exit 2; }
    exec python3 "$HERE/patch.py" "$ws/.tutor/session.json" "${3-}" ;;
  run)
    # Run the active step's declared tests.cmd, else `sh <submitted file>`, in the
    # workspace. Only runs the lesson's own command / the user's own file — never
    # arbitrary input — so it's safe to allow-list for prompt-free tutor reviews.
    [ -n "$ws" ] || { echo "usage: ctl.sh run <workspace>" >&2; exit 2; }
    S="$ws/.tutor/session.json"
    line="$(python3 - "$S" <<'PY'
import json, sys
try: s=json.load(open(sys.argv[1]))
except Exception: print("\t"); raise SystemExit
steps=s.get("steps")
st=steps[((s.get("progress") or {}).get("step",1) or 1)-1] if isinstance(steps,list) and steps else (s.get("step") or {})
t=(st.get("tests") or s.get("tests") or {})
print((t.get("cmd") or "")+"\t"+(st.get("file") or ""))
PY
)"
    cmd_str="${line%%$'\t'*}"; file_str="${line#*$'\t'}"
    cd "$ws" || exit 1
    if [ -n "$cmd_str" ]; then
      eval "$cmd_str"
    elif [ -n "$file_str" ] && [ -f "$file_str" ]; then
      sh "$file_str"
    else
      echo "(nothing to run for this step)"
    fi
    ;;
  profile)
    # The tutor never reads ~/.codetrain itself: it gets this brief instead.
    if [ "${2:-}" = "full" ]; then exec python3 "$HERE/profile.py" brief --full; fi
    exec python3 "$HERE/profile.py" brief ;;
  profile-update)
    [ -n "$ws" ] || { echo "usage: ctl.sh profile-update <session-dir>  (write .tutor/profile-delta.json first)" >&2; exit 2; }
    exec python3 "$HERE/profile.py" update "$ws/.tutor/profile-delta.json" ;;
  *) echo "usage: ctl.sh {sandbox|serve|watch|stop|patch|run|profile|profile-update} <workspace>" >&2; exit 2 ;;
esac
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall