Last active
November 17, 2025 11:04
-
-
Save imaman/716e0ebb75058d5799a567b562bc4df6 to your computer and use it in GitHub Desktop.
lists the subagents that were actually used by claude code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs') | |
| const path = require('path') | |
| const os = require('os') | |
| const d = path.join(os.homedir(), PICK_YOUR_CLAUDE_CODE_DIRECTORY) | |
| const objects = fs.readdirSync(d).map(at => path.join(d, at)).filter(at => at.endsWith('.jsonl')).flatMap(at => { | |
| return fs.readFileSync(at, 'utf-8').split('\n').flatMap((line, i) => { | |
| if (!line.trim()) { | |
| return [] | |
| } | |
| try { | |
| return [JSON.parse(line)] | |
| } catch (e) { | |
| console.error(`Failed to parse ${at} line ${i+1}: "${line}"`) | |
| throw e | |
| } | |
| }) | |
| }) | |
| const subagents = objects.flatMap(obj => { | |
| if (obj.type !== 'assistant') { | |
| return [] | |
| } | |
| if (!obj.message) { | |
| console.log(JSON.stringify(obj, null, 2)) | |
| process.exit(1) | |
| } | |
| return [...obj.message.content].flatMap(c => c.type === 'tool_use' && Boolean(c.input.subagent_type) ? [{subagent: c.input.subagent_type, sessionId: obj.sessionId, timestamp: String(obj.timestamp)}] : [String(obj.timestamp)]) | |
| }) | |
| const timestamps = subagents.map(at => typeof at === 'string' ? at : at.timestamp).sort((lhs, rhs) => lhs.localeCompare(rhs)) | |
| const output = subagents.flatMap(at => typeof at === 'string' ? [] : at) | |
| output.sort((lhs, rhs) => lhs.timestamp.localeCompare(rhs.timestamp)) | |
| console.log(JSON.stringify([{from: timestamps.at(0)}, ...output, {to: timestamps.at(-1)}], null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment