Skip to content
Back to skills

Nyxs Claude Code Stream

ASecurity

How Nyxs reads Claude Code's stream-json output and when a turn starts and ends. Use whenever changing src/lib/claudeCode*.ts (claudeCode, claudeCodeStream, claudeCodeProcesses, claudeCodeTasks), the "Working…" state of a Claude Code session, background sub-agents or commands, wake turns, or when a Claude Code session shows working while nothing runs.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
ai-agentsgobash

Works with

  • claude code
  • cli
  • mcp

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add nyxs-code/nyxs-code --skill nyxs-claude-code-stream --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nyxs Claude Code Stream?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nyxs Claude Code Stream
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nyxs-code-nyxs-claude-code-stream/badge)](https://www.skillsdirectory.com/skills/nyxs-code-nyxs-claude-code-stream)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nyxs-claude-code-stream
description: How Nyxs reads Claude Code's stream-json output and when a turn starts and ends. Use whenever changing src/lib/claudeCode*.ts (claudeCode, claudeCodeStream, claudeCodeProcesses, claudeCodeTasks), the "Working…" state of a Claude Code session, background sub-agents or commands, wake turns, or when a Claude Code session shows working while nothing runs.
---

# Claude Code's stream in Nyxs

Nyxs runs the Claude Code CLI as a long-lived process (`--input-format stream-json
--output-format stream-json --verbose --include-partial-messages --forward-subagent-text
--replay-user-messages --permission-prompt-tool=stdio`, built in
`src-tauri/src/agent/claude_code/args.rs`) and turns its lines into a chat turn.

## When a turn starts and ends

- A turn of ours ends at the `result` line (`onResultMessage` in `claudeCodeStream.ts`), unless
  queued messages are still on their way (`inflight`). Claude Code sends `result` **while
  background sub-agents and commands keep running**: their work is not the turn's.
- After `result`, a message with no turn attached goes to `onUnattended`
  (`claudeCodeProcesses.ts`). Only Claude Code's **own** `assistant` / `stream_event` lines mean
  it started a turn on its own (a wake turn after a task notification): those open a turn the
  app shows.
- **A line with `parent_tool_use_id` is a sub-agent's, never the start of a turn.** Taking it as
  one left the chat on "Working…" until the sub-agent ended, and marked the session busy so the
  next message waited up to two minutes (`AUTONOMOUS_WAIT_MS`). Both checks
  (`onUnattended` and `unattendedDefault`) skip it; keep it that way.

## Hooks Nyxs registers (`claudeCodeProcesses.ts`)

The `initialize` control request carries `hooks` (`hooksFor`); the CLI then sends
`hook_callback` control requests, answered at once in `answerHook`, turn or no turn.

- **No hook ends the turn at `mcp__nyxs-sessions__wrap_up`.** One did (`nyxs_wrap_up_ends_turn`,
  `{ continue: false }`, 2c983a7) and lost the final message: models write it after the wrap-up
  (about 3 in 4 turns in the transcripts), or in their reasoning when told to write nothing after,
  so only the recap card was left. The prompt now asks for the wrap-up first and the final message
  after it; a real repeat is hidden by `withoutRepeatAfterWrapUp` (`turnWrapUp.ts`).
- **`nyxs_reply_language`** (PostToolUse, every tool) answers every `LANGUAGE_EVERY` calls of the
  main agent with `hookSpecificOutput.additionalContext`: a short reminder of the language of the
  user's latest message (`proc.replyLanguage`, read from the language check `sendTo` sends). Long
  turns drifted into English among English tool results. A sub-agent's calls (`agent_id`) don't
  count.
- Hooks only go with the `initialize` that hosted MCP servers or prompt suggestions already need:
  an `initialize` for them alone would hold up a CLI that doesn't answer it.
- Checked with the real CLI (haiku): `continue: false` ends with `result` right after the tool's
  `user` line; `additionalContext` reaches the model; a hook without `matcher` runs on every tool.

## Tasks (`claudeCodeTasks.ts`)

| Line | What it means |
|---|---|
| `system/task_started` | A task: `task_type` (`local_agent`, `local_bash`, `monitor`…), `description`, `tool_use_id` (the tool call that started it), `is_backgrounded`. |
| `system/task_progress` | A sub-agent's one-line `description` of what it does now. |
| `system/task_updated` | `patch.status` (`completed`, `failed`, `killed`…). |
| `system/task_notification` | It ended: `status`, `output_file`, and a `summary` of what it found (Markdown). |

- `is_backgrounded: false` is part of the turn, or a step of a background sub-agent (its own
  Bash): never counted as background work of its own (`foreground`).
- Each task keeps the chat it was started from (`chatKey`): the sidebar's "N in background"
  (`runningTasksByChat`) and the Agents card (`AgentsCard.tsx`, matched by `toolUseId`) read it.
- A summary is Markdown: strip it to plain text before showing it in a line.

## Checking the CLI's real behaviour

Don't guess the order of events: run the CLI once with a cheap model and log the lines.

```bash
mkdir -p /tmp/probe && cd /tmp/probe   # a scratch folder outside the project
# probe.mjs: spawn("C:/Users/<you>/.local/bin/claude.exe", ["-p", "--input-format", "stream-json",
#   "--output-format", "stream-json", "--verbose", "--model", "haiku", ...the flags above...]),
# write one {"type":"user","message":{...}} line, print type/subtype and seconds per line.
```

- Claude Code **blocks a plain `sleep`** in Bash: for a long-running test step use
  `ping -n 30 127.0.0.1` (Windows).
- `get_settings` (a control request, no tokens) answers what applies to the session (model,
  effort, `ultracode`, `ultracodeAvailable`…): use it to check a setting without a turn.
- Delete the scratch folder afterwards.

## Tests

`src/lib/__tests__/claudeWake.test.ts` drives a fake CLI (`out({...})`); add a case there for any
change to wake turns or tasks, and check it fails without the fix.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.