KilimcininKorOglu/claude-code-mods/tree/main/plugins/orphan-server
orphan-server
이 저장소에서 시작되어 포트에서 수신 대기 중인 모델의 Bash 호출을 해당 기간 및 세션과 함께 서버에 나열하고 SIGTERM, SIGKILL을 사용하여 서버를 중지합니다.
이 mod 소개
모델은 (cmd &)를 사용하여 개발 서버를 시작하고 세션이 종료되며 서버는 해당 포트를 계속 유지합니다. 며칠 후 address already in use를 받게 되며 서버가 여전히 실행 중이라는 것을 알려주는 다른 어떤 것도 없습니다. 이 모드는 이 저장소에서 시작되어 포트에서 수신 대기 중인 모델의 Bash 호출을 서버의 수명과 세션 및 각각에 대한 중지 버튼과 함께 나열합니다.
수신 중인 TCP 프로세스를 읽고, 세션의 git 저장소에 고아(상위 1)만 유지하고, 이를 기록의 원래 Bash 호출과 일치시키고, 행당 중지 버튼이 있는 사이드바 섹션에 표시합니다. 중지하면 SIGTERM이 전송되고 5 초 후에 SIGKILL이 전송됩니다. 명령: /orphan-server, /orphan-server stop <pid>, /orphan-server on | off. L2에 도달하세요. claude plugin validate로 검증되었습니다.
설치
먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.
claude plugin marketplace add KilimcininKorOglu/claude-code-mods claude plugin install orphan-server
원문 / README
orphan-server
The model starts a dev server with (cmd &), the session ends, and the server keeps holding its port. Days later you get address already in use, and nothing else tells you the server still runs. This mod lists the servers a Bash call of the model started in this repository and left listening on a port, with their age and session and a stop button for each.
What it does
-
At session start, at the end of each main-loop turn, every 60 s in an interactive session and at
/orphan-server, the mod reads the processes that listen on a TCP port (lsof -nP -iTCP -sTCP:LISTEN). The 60 s scan shows a server another session left, or takes down the row of one stopped elsewhere, while this session is idle. A 60 s scan that fails logs its reason once, until a scan passes again. -
It keeps only a process whose parent is 1 (it outlived the shell that started it) and whose working directory is the session's git repository or a directory under it.
-
It reads this repository's transcripts for the Bash call that started each one: a call that ran while the process started (after the model wrote it, before its result) and whose command holds the process's arguments. Only the transcript lines of the minutes that call can sit in are read, and each process is looked up once.
-
The servers found stand in one sidebar section, oldest first, with a stop button each. In each row the ports are yellow, the age yellow and red past one day, and another session's id faint;
this sessionstays in the default colour::8787 Python -m http.server 8787 · 3h · session 450600b2 [ stop :8787 ]While the sidebar is closed, one transcript line names them with their pids, once per set of servers, and the section is drawn at the next scan after the sidebar opens.
-
The button runs
/orphan-server stop <pid>. The mod reads the process again first; a pid that no longer belongs to the listed server (another parent, other arguments, another start time) gets no signal. Otherwise it sends SIGTERM, and SIGKILL after 5 seconds if the server still runs. A line saysstopped :8787 ...withstoppedgreen, or says the serverstill runs after SIGKILL, those words red.
Command
/orphan-server reads the servers now and lists them with their pids
/orphan-server stop <pid> SIGTERM, then SIGKILL after 5 s, to a listed server
/orphan-server on | off on by default; off reads only at /orphan-server
Install
claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install orphan-server@kilimcininkoroglu-mods
Function hooks are early access. Claude Code 2.1.288 and later load them by default, so there is nothing to switch on.
After installing
- Restart Claude Code.
- Install the sidebar mod for the section and its stop buttons. Without it the mod writes one transcript line and
/orphan-server stop <pid>stops a server.
What it can reach
Validated with claude plugin validate on Claude Code 2.1.284:
❯ ./register.ts hooks: session.start, command.run{command=orphan-server}, turn.complete
❯ ./register.ts calls: $.clock.after (via later, stop), $.clock.every, $.clock.now (via listenersIn, readProc, runCommand, show, toSidebar), $.command.register, $.env.get, $.process.run (via output, rootOf), $.session.id, $.sidebar.clear (via toSidebar), $.sidebar.set (via toSidebar, toStream), $.store.get (via readSettings), $.store.set (via setEnabled), $.ui.log (via later, show, stop, tick, toStream)
❯ ./register.ts env writes: nothing
❯ ./register.ts env reads: CLAUDE_CONFIG_DIR, HOME
Reach L2, it runs processes and sends signals.
1. Reads: the listening TCP processes (pid, ports, parent, age, arguments, working directory), and the transcript lines of this repository's sessions for the minutes around each one's start
2. Runs: git rev-parse --show-toplevel once per session; lsof, ps and grep at session start, at each turn's end, every 60 s in an interactive session and at /orphan-server; kill -TERM and kill -KILL for a server you stop
3. Sends: nothing to the model and nothing to the network
4. Persists: in $.store, the on/off setting
5. Hostile input: a process's arguments and a transcript's commands are drawn as text and compared as text, never run; the pid of a stop is read again before a signal is sent
Limits
- Only the transcripts of the repository root and of the session's start directory are read. A server that an old session opened in another subdirectory started is not listed.
- A server started through a wrapper that still runs (
npm run dev,make serve) is not listed, because its parent is the wrapper and not 1. - The match is by time and command text. Two processes started in the same call with the same arguments read as one server each, and both are listed.
- A process with arguments shorter than 3 characters is never matched.
- A server you started by hand outside Claude Code is never listed, because no transcript holds its Bash call.
lsofandpsanswer for your own processes only.
Development
make install # eslint, typescript-eslint, typescript
make lint # complexity limit 10, the build fails above it
make typecheck # needs .claude/types/ from /plugin-types
make validate
make test # claude plugin test

