Subagents
A Claude Code subagent starts with the prompt its parent wrote and nothing else. It has none of the recall /cs did, so it would edit files without knowing the fixes and risks the team has stored for them. The hooks treat it as its own agent.
What happens
- When it starts, the
subagent-start.shhook (SubagentStart) adds a short note to its context: it is in a Cortex session, the parent's recall is not in its context, and it must runcortex_knowledge_searchandcortex_memory_searchon its own task before editing. It also gets the rules for finding code. - When it tries to edit,
enforce-session.shlooks for recall markers filed under the subagent's own id (.cortex/.session-state/agents/<agent_id>/). The parent's markers do not count. Until the subagent has run both searches, its edits are refused. - When it reads or edits a file with linked notes,
recall-notes.shshows them to it, once per subagent. See file notes.
The session itself is shared: a subagent does not call cortex_session_start. If the checkout has no Cortex session, or the gates are declared off, the SubagentStart hook says nothing.
Writing a subagent prompt
The subagent searches on its own task, so say what the task is in terms a search can use: the error message, the feature, the files. A prompt like "fix the bug we discussed" gives it nothing to recall with.