Docs

Agents

Junie

Set up Comity for JetBrains Junie with native hooks (user config or --config-location), a project MCP server and AGENTS.md instructions.

On this page

Junie CLI runs Comity's hooks on session start, prompts, tool calls (Bash, Write, Edit), stop and session end. Junie never runs hooks from repo files on its own, so you load them explicitly. The MCP server is a project-scope stdio entry, with no token. Junie in JetBrains IDEs shares the MCP config; the hooks are a Junie CLI feature.

Set up

Terminal
cd your-repo
comity init --tools junie
git add .junie/comity-hooks.json .junie/mcp/mcp.json AGENTS.md
git commit -m "Set up Comity for Junie"

Then load the hooks: start Junie with junie --config-location .junie/comity-hooks.json, or copy the file's "hooks" object into ~/.junie/config.json. Junie skips hooks in <project>/.junie/config.json for safety (Junie hooks).

Junie loads the project MCP server only in trusted projects.

What init writes

.junie/mcp/mcp.json

JSON
{
  "mcpServers": {
    "comity": {
      "command": "node",
      "args": ["-e", "const c=require('child_process').spawn('comity '+process.argv.slice(1).join(' '),{stdio:'inherit',shell:true});c.on('error',()=>process.exit(1));c.on('exit',(k)=>process.exit(k===null?1:k))", "mcp"]
    }
  }
}

A project-scope server (Junie MCP) running the stdio bridge. There's no token in it; comity login is enough. Your other servers in the file are kept. The node -e launcher runs comity mcp through the shell, so the file is the same on every OS and for every teammate. Node must be on PATH, which the CLI needs anyway.

.junie/comity-hooks.json

Junie event Matcher Timeout (s)
SessionStart 5
UserPromptSubmit 5
PreToolUse Bash|Write|Edit 5
Stop 10
SessionEnd 2

Every command runs comity hook --tool junie --event <Event> through a node -e launcher that works under both sh -c and Windows cmd /c, so the file is the same on every OS. On a machine without the CLI the hook exits 0 and the tool runs.

AGENTS.md

Comity's coordination instructions in a marked block, in .junie/AGENTS.md if the repo has one (Junie reads that first), otherwise in AGENTS.md (guidelines).

What your agent sees

  • Prompts: the briefing and new messages as additionalContext, prepended to the prompt.
  • Before a Bash, Write or Edit call: a block answers {"decision":"block","reason":"…"} and the model gets the reason. Warnings arrive as additionalContext for that step.
  • Session start: Junie ignores context from SessionStart hooks, so the first briefing arrives with the first prompt.

Verify

Terminal
comity doctor

Expect junie hooks comity hooks in ~/.junie/config.json (or a warning that the hooks only run with --config-location) and junie mcp mcpServers.comity in …. In Junie, /mcp should show comity as Active.

Limits

  • Junie has no PostToolUse event: Comity sees edits before they happen, not their result.
  • Hooks run in the interactive TUI and batch mode only. In ACP and server mode, Junie runs no hooks.
  • UserPromptSubmit fires only in the interactive TUI.
  • The documented PreToolUse and Stop payloads carry no session id. When it's missing, Comity treats each project directory as one session.