cyrus
CLAUDE.md846 starsChanged 2 months agoApache-2.0View on GitHub
Cyrus (Linear Claude Agent) is a monorepo JavaScript/TypeScript application that integrates Linear's issue tracking with Anthropic's Claude Code to automate software development tasks. The project is transitioning to an edge-proxy architecture that separates OAuth/webhook handling (proxy) from Claude processing (edge workers). Key capabilities: - Monitors Linear issues assigned to a specific user - Creates isolated Git worktrees for each issue - Runs Claude Code sessions to process issues - Posts responses back to Linear as comments - Maintains conversation continuity…
- Reads credentials
- Installs packages
- Commits and pushes
In this repository22 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- googleSkill
- release-core-testSkill
- cyrus-setup-claude-authSkill
- cyrus-setup-endpointSkill
- cyrus-setup-githubSkill
- cyrus-setup-gitlabSkill
- cyrus-setup-launchSkill
- cyrus-setup-linearSkill
- cyrus-setup-prerequisitesSkill
- cyrus-setup-repositorySkill
- cyrus-setupSkill
- cyrus-setup-slackSkill
- debugSkill
- f1-test-driveSkill
- implementationSkill
- investigateSkill
- releaseSkill
- summarizeSkill
- verify-and-shipSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
54 rules. About 0 are common, 31 are distinctive, and 23 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈31
Distinctive · estimate
This author's own choices. Worth a look.
23
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
When a Linear issue is assigned to Cyrus, the following sequence occurs:
- Distinctive: line 36
Activity Tracking: Every thought and action is posted back to Linear as activities, providing full visibility into what Claude is doing.
- Distinctive: line 83
When examining or working with a package SDK:
- Distinctive: line 114
Keep subagent files thin wrappers.
- Distinctive: line 115
Put 95%+ workflow logic into canonical shared skills.
- Distinctive: line 116
Update shared skill first.
- Distinctive: line 120
When implementing a new runner/harness (for example Codex, Gemini, OpenCode, or other CLIs), use this checklist before shipping.
- Very specific: line 124
Verify turn-limit behavior (maxTurns, maxSessionTurns, or equivalent).
- Distinctive: line 126
Ensure session stop behavior is explicit and deterministic.
- Distinctive: line 138
Add replay tests from real transcripts.
- Distinctive: line 142
Verify where the final answer lives:
- Very specific: line 146
Ensure we always post a final response activity when work completes successfully.
- Distinctive: line 152
Verify tool calls produce both start and completion signals.
- Distinctive: line 157
Verify whether the SDK supports streaming/incremental prompt input.
- Distinctive: line 162
Verify MCP server config format and merge behavior.
- Distinctive: line 163
Verify custom tool registration/invocation behavior.
- Distinctive: line 164
Ensure MCP/custom-tool events are mapped into consistent runner message shapes.
- Very specific: line 168
Keep agent label and model label separate (example: codex and gpt-5-codex).
- Distinctive: line 170
Add precedence tests for labels vs selectors vs repository defaults.
- Distinctive: line 174
Ensure formatter output is timeline-ready (AgentActivity content fields).
- Distinctive: line 175
Ensure tool lifecycle events are visible as activities (not silently dropped).
- Distinctive: line 176
Use Markdown-compatible formatting for checklists:
- Distinctive: line 184
Keep strict TypeScript compatibility for cross-runner shared contracts.
- Very specific: line 188
Use provider-specific defaults (claudeDefaultModel, geminiDefaultModel, codexDefaultModel).
- Distinctive: line 189
Add config migration logic for renamed or legacy fields.
- Distinctive: line 190
Keep docs/comments provider-specific and explicit.
- Distinctive: line 194
Run unit tests for new runner adapters and formatter behavior.
- Distinctive: line 195
Run replay tests from real CLI transcripts.
- Distinctive: line 212
When you need to examine source code from GitHub repositories (especially when GitHub's authentication blocks normal navigation):
- Distinctive: line 256
Follow the canonical verification policy.
- Distinctive: line 257
Every change needs appropriate verification, not necessarily new automated tests or a full-suite run.
- Very specific: line 270
When working with prompt assembly tests in packages/edge-worker/test/prompt-assembly*.test.ts:
- Very specific: line 274
Use .expectUserPrompt() with the complete expected prompt string
- Very specific: line 275
Use .expectSystemPrompt() with the complete expected system prompt (or undefined)
- Very specific: line 276
Use .expectComponents() to verify all prompt components
- Very specific: line 277
Use .expectPromptType() to verify the prompt type
- Very specific: line 278
Always call .verify() to execute all assertions
- Very specific: line 403
Issue Assignment Behavior: When an issue is assigned to the agent, it automatically transitions to a state with type === 'started' (In …
- Very specific: line 418
Sandbox Egress Proxy & CA Certificates: When sandbox is enabled, the egress proxy generates a CA cert at ~/.cyrus/certs/cyrus-egress-ca.pem …
- Very specific: line 420
systemWideCertconfig flag: When sandbox.systemWideCert: true is set in config.json, all per-session CA cert env vars above are skipped — … - Very specific: line 440
Key invariant: If sandbox is enabled, both systems should restrict home directory reads.
- Very specific: line 478
Prefer direct-dep bumps in the owning
package.json: If the vulnerable dep is transitively pulled in by one of *our* direct dependencies, … - Distinctive: line 493
When you update a direct dependency (security or otherwise), check whether any existing override entry is now satisfied naturally by the …
- Very specific: line 498
Verify with
pnpm audit: After any dependency change, pnpm audit must report zero advisories. - Distinctive: line 509
When working on this codebase, follow these practices:
- Very specific: line 512
Update CHANGELOG.md under the ## [Unreleased] section with your changes
- Very specific: line 513
Use appropriate subsections: ### Added, ### Changed, ### Fixed, ### Removed
- Very specific: line 515
Include the PR number/link: If the PR is already created, include the link (e.g., (#123)).
- Very specific: line 516
Run relevant existing checks per the verification policy.
- Very specific: line 517
Run pnpm typecheck and pnpm build when affected by the change or required by repository hooks/CI
- Distinctive: line 521
Follow the same format as the main changelog.
- Distinctive: line 525
Follow Keep a Changelog format
- Very specific: line 526
Focus only on end-user impact: Write entries from the perspective of users running the cyrus CLI binary
- Distinctive: line 527
Avoid technical implementation details, package names, or internal architecture changes
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Cyrus (Linear Claude Agent) is a monorepo JavaScript/TypeScript application that integrates Linear's issue tracking with Anthropic's Claude Code to automate software development tasks. The project is transitioning to an edge-proxy architecture that separates OAuth/webhook handling (proxy) from Claude processing (edge workers).
Key capabilities:
- Monitors Linear issues assigned to a specific user
- Creates isolated Git worktrees for each issue
- Runs Claude Code sessions to process issues
- Posts responses back to Linear as comments
- Maintains conversation continuity using the
--continueflag - Supports edge worker mode for distributed processing
How Cyrus Works
When a Linear issue is assigned to Cyrus, the following sequence occurs:
- Issue Detection & Routing: The EdgeWorker receives a webhook from Linear and routes the issue to the appropriate repository based on configured patterns or workspace catch-all rules.
- Workspace Isolation: A dedicated Git worktree is created for each issue (e.g.,
worktrees/DEF-1/) with a sanitized branch name derived from the issue identifier. This ensures complete isolation between concurrent tasks. - AI Classification: The issue content is analyzed to determine its type (
code,question,research, etc.) and the appropriate procedure is selected (e.g.,full-developmentfor coding tasks). - Subroutine Execution: For development tasks, Claude executes a sequence of subroutines:
- coding-activity: Implements the requested feature/fix
- verifications: Runs tests, type checks, and linting
- git-gh: Commits changes and creates pull requests
- concise-summary: Generates a final summary for Linear
- Mid-Implementation Prompting: Users can add comments to the Linear issue while Claude is working. These comments are streamed into the active session, allowing real-time guidance (e.g., "Also add a modulo method while you're at it").
- Activity Tracking: Every thought and action is posted back to Linear as activities, providing full visibility into what Claude is doing.
Example Interaction
A typical session flow:
[GitService] Fetching latest changes from remote...
[GitService] Creating git worktree at .../worktrees/DEF-1 from origin/main
[EdgeWorker] Workspace created at: .../worktrees/DEF-1
[EdgeWorker] AI routing decision: Classification: code, Procedure: full-development
[ClaudeRunner] Session ID assigned by Claude: c5c1fc00-...
[AgentSessionManager] Created thought activity activity-6
[AgentSessionManager] Created action activity activity-7
... (Claude implements the feature)
[ClaudeRunner] Session completed with 84 messages
[AgentSessionManager] Subroutine completed, advancing to next: verificationsTest Drives
To see Cyrus in action, refer to the test drives in apps/f1/test-drives/. These documents showcase real interactions demonstrating:
- How issues are processed end-to-end
- Mid-implementation prompting in action
- Subroutine transitions and activity logging
- Final repository state after completion
The F1 (Formula 1) testing framework provides a controlled environment to test Cyrus without affecting production Linear workspaces.
Choose validation by the actual changed behavior, not the size of the task or filenames. Follow the canonical F1 applicability policy: F1-covered product/runtime changes and functional changes to the F1 harness require relevant F1 validation. Changes with no relevant workflow behavior use targeted checks and a brief PR validation note, without running F1 or creating, attaching, or committing an F1 report. For releases, assess the full payload since the previous release, not just the release PR. Preserve historical test-drive evidence.
Linear Webhooks Reference
Cyrus processes Linear webhooks to respond to events like issue assignments, user prompts, and issue updates. The Linear SDK and webhook schemas are documented at:
- EntityWebhookPayload: https://studio.apollographql.com/public/Linear-Webhooks/variant/current/schema/reference/objects/EntityWebhookPayload
- DataWebhookPayload: https://studio.apollographql.com/public/Linear-Webhooks/variant/current/schema/reference/unions/DataWebhookPayload
- IssueWebhookPayload: https://studio.apollographql.com/public/Linear-Webhooks/variant/current/schema/reference/objects/IssueWebhookPayload
Key webhook types handled:
AgentSessionEvent(created/prompted) - When issues are assigned to Cyrus or users send promptsAppUserNotification(issueUnassignedFromYou) - When issues are unassignedIssue(update with title/description changes) - When issue title or description is modified
The EntityWebhookPayload contains an updatedFrom field that holds previous values of changed properties, enabling Cyrus to detect what changed and compare old vs new values.
Working with SDKs
When examining or working with a package SDK:
- First, install the dependencies:
pnpm install - Locate the specific SDK in the
node_modulesdirectory to examine its structure, types, and implementation details. - Review the SDK's documentation, source code, and type definitions to understand its API and usage patterns.
Shared Skills Across Harnesses
For reusable operational workflows (for example F1 test driving), keep a canonical skill in:
skills/<skill-name>/SKILL.md
Then symlink that skill into harness-specific skill directories:
.claude/skills/<skill-name>.codex/skills/<skill-name>.opencode/skills/<skill-name>
Use:
./scripts/symlink-skills.shDesign rule:
- Keep subagent files thin wrappers.
- Put 95%+ workflow logic into canonical shared skills.
- Update shared skill first; avoid duplicating protocol text across harnesses.
Checklist For New Agent CLI Harnesses
When implementing a new runner/harness (for example Codex, Gemini, OpenCode, or other CLIs), use this checklist before shipping.
1) Session Lifecycle And Turn Limits
- Verify turn-limit behavior (
maxTurns,maxSessionTurns, or equivalent). - Confirm what error/result payload is emitted when limits are exceeded.
- Ensure session stop behavior is explicit and deterministic.
2) Prompt Model And Instructions
- Identify how base system prompt is applied.
- Identify whether appended instructions are supported and whether they extend or replace defaults.
- Confirm provider-specific instruction fields (for example
developer_instructions) and expected precedence.
3) Streaming Event Schema
- Capture real JSON event streams and document item types.
- Determine whether events are full objects or deltas/partials that require aggregation.
- Add replay tests from real transcripts.
4) Final Message Semantics
- Verify where the final answer lives:
- in a
resultpayload (Claude-style), or - in the last assistant message (Gemini-style), or
- mixed model/event behavior.
- in a
- Ensure we always post a final
responseactivity when work completes successfully.
5) Tools And Permissions
- Validate
tools,allowedTools, anddisallowedToolssemantics for the SDK. - Validate approval/sandbox behavior for tool execution.
- Verify tool calls produce both start and completion signals.
- For providers that rely on static/project config files (for example Cursor CLI), implement a permission translation layer from Cyrus/Claude tool names to provider-native permission tokens and write that config before session start. This must support subroutine-time updates when allowed/disallowed tools change. For Cursor MCP servers, pre-enable them before session start (
agent mcp list+agent mcp enable <server>per server) so tools are available in headless runs. When using Cursor in Cyrus, only MCP servers configured in.cursor/mcp.jsonshould be treated as project MCP config; use Cursor's MCP config-location and file-format docs as the source of truth: https://cursor.com/docs/context/mcp#configuration-locations. For broad file permissions, map wildcardRead(**)/Write(**)to workspace-scoped patterns (for exampleRead(./**)/Write(./**)) to avoid unintentionally permitting absolute system paths. Reference: https://cursor.com/docs/cli/reference/permissions
6) Prompt Streaming Input
- Verify whether the SDK supports streaming/incremental prompt input.
- Set
supportsStreamingInputcorrectly and gate behavior in runner adapters.
7) MCP Servers And Custom Tools
- Verify MCP server config format and merge behavior.
- Verify custom tool registration/invocation behavior.
- Ensure MCP/custom-tool events are mapped into consistent runner message shapes.
8) Runner Selection Via Labels And Description Selectors
- Keep agent label and model label separate (example:
codexandgpt-5-codex). - Support issue description selectors like
[agent=...],[model=...],[repo=...]. - Add precedence tests for labels vs selectors vs repository defaults.
9) Activity Formatting And Timeline Visibility
- Ensure formatter output is timeline-ready (AgentActivity content fields).
- Ensure tool lifecycle events are visible as activities (not silently dropped).
- Use Markdown-compatible formatting for checklists:
- [ ] item- [x] item
10) Usage, Stop Reasons, And Typing
- Map usage/cost/stop-reason fields to expected shared types.
- Fill required compatibility fields even when provider omits them natively.
- Keep strict TypeScript compatibility for cross-runner shared contracts.
11) Config Schema And Backward Compatibility
- Use provider-specific defaults (
claudeDefaultModel,geminiDefaultModel,codexDefaultModel). - Add config migration logic for renamed or legacy fields.
- Keep docs/comments provider-specific and explicit.
12) Validation Protocol Before Merge
- Run unit tests for new runner adapters and formatter behavior.
- Run replay tests from real CLI transcripts.
- Validate F1 end-to-end scenarios for:
- label-based runner/model selection
- description selector-based runner/model selection
- visible tool/file-edit activities in session timeline
- final response posting behavior
Codex Integration Lesson Learned
Codex emitted tool activity at item.started/item.completed events, but those were initially not mapped to tool_use/tool_result. The result was missing action/file-edit visibility in Linear. For any new harness, treat tool lifecycle mapping as a first-class acceptance criterion, not a formatter-only concern.
Cursor Integration Lesson Learned
Cursor CLI permissions are enforced from config (~/.cursor/cli-config.json or <project>/.cursor/cli.json) instead of dynamic per-request tool allowlists. For Cursor-like providers, do not rely on dynamic SDK tool constraints alone—add a translation layer (for example mcp__server__tool -> Mcp(server:tool), Bash(...) -> Shell(...)) and sync project permissions before each run and between subroutines. Also pre-enable MCP servers via agent mcp list + agent mcp enable <server> using both project-listed and runner-configured server names so headless sessions can invoke MCP tools immediately. In Cyrus Cursor runs, treat .cursor/mcp.json as the project MCP source and follow Cursor's configuration-location and file-syntax docs (these differ from Claude's MCP interpretation): https://cursor.com/docs/context/mcp#configuration-locations. Use workspace-scoped wildcard file permissions (Read(./**), Write(./**)) rather than unscoped Read(**) / Write(**) in translation defaults. Reference: https://cursor.com/docs/cli/reference/permissions
Navigating GitHub Repositories
When you need to examine source code from GitHub repositories (especially when GitHub's authentication blocks normal navigation):
Use uuithub.com instead of github.com:
# Instead of:
https://github.com/google-gemini/gemini-cli/blob/main/src/file.ts
# Use:
https://uuithub.com/google-gemini/gemini-cli/blob/main/src/file.tsThis proxy service provides unauthenticated access to GitHub content, making it ideal for:
- Reading source code files
- Browsing directory structures
- Examining schemas and configuration files
- Investigating third-party library implementations
Simply replace github.com with uuithub.com in any GitHub URL.
Architecture Overview
The codebase follows a pnpm monorepo structure:
cyrus/
├── apps/
│ ├── cli/ # Main CLI application
│ ├── electron/ # Future Electron GUI (in development)
│ └── proxy/ # Edge proxy server for OAuth/webhooks
└── packages/
├── core/ # Shared types and session management
├── claude-parser/# Claude stdout parsing with jq
├── claude-runner/# Claude CLI execution wrapper
├── edge-worker/ # Edge worker client implementation
└── ndjson-client/# NDJSON streaming clientFor a detailed visual representation of how these components interact and map Claude Code sessions to Linear comment threads, see @architecture.md.
Testing Best Practices
Proportionate Verification
Follow the canonical verification policy. Every change needs appropriate verification, not necessarily new automated tests or a full-suite run. Routine release scripts, packaging, CI, documentation, and instruction edits often need only syntax checks, a safe dry run, install smoke checks, or direct review. Add tests for concrete consequential failures when ongoing protection outweighs maintenance. Avoid brittle text/source assertions, implementation-mirroring tests, and scaffolding that costs more than it protects. Preserve safeguards against wrong artifact publication, unintended stable-tag moves, invalid release evidence, and other consequential regressions. Choose by behavior and risk, never filenames alone; retain required CI gates and relevant functional F1 validation.
Prompt Assembly Tests
When working with prompt assembly tests in packages/edge-worker/test/prompt-assembly*.test.ts:
CRITICAL: Always assert the ENTIRE prompt, never use partial checks like .toContain()
- Use
.expectUserPrompt()with the complete expected prompt string - Use
.expectSystemPrompt()with the complete expected system prompt (orundefined) - Use
.expectComponents()to verify all prompt components - Use
.expectPromptType()to verify the prompt type - Always call
.verify()to execute all assertions
This ensures comprehensive test coverage and catches regressions in prompt structure, formatting, and content. Partial assertions with .toContain() are too weak and can miss important changes.
Example:
// ✅ CORRECT - Full prompt assertion
await scenario(worker)
.newSession()
.withUserComment("Test comment")
.expectUserPrompt(`<user_comment>
<author>Test User</author>
<timestamp>2025-01-27T12:00:00Z</timestamp>
<content>
Test comment
</content>
</user_comment>`)
.expectSystemPrompt(undefined)
.expectPromptType("continuation")
.expectComponents("user-comment")
.verify();
// ❌ INCORRECT - Partial assertion (too weak)
const result = await scenario(worker)
.newSession()
.withUserComment("Test comment")
.build();
expect(result.userPrompt).toContain("<user_comment>");
expect(result.userPrompt).toContain("Test User");Common Commands
Monorepo-wide Commands (run from root)
# Install dependencies for all packages
pnpm install
# Build all packages
pnpm build
# Build lint for the entire repository
pnpm lint
# Run tests across all packages
pnpm test
# Run tests only in packages directory (recommended)
pnpm test:packages:run
# Run TypeScript type checking
pnpm typecheck
# Development mode (watch all packages)
pnpm devApp-specific Commands
CLI App (apps/cli/)
# Start the agent
pnpm start
# Development mode with auto-restart
pnpm dev
# Run tests
pnpm test
pnpm test:watch # Watch mode
# Local development setup (link development version globally)
pnpm build # Build all packages first
pnpm uninstall cyrus-ai -g # Remove published version
cd apps/cli # Navigate to CLI directory
pnpm install -g . # Install local version globally
pnpm link -g . # Link local development versionElectron App (apps/electron/)
# Development mode
pnpm dev
# Build for production
pnpm build:all
# Run electron in dev mode
pnpm electron:devProxy App (apps/proxy/)
# Start proxy server
pnpm start
# Development mode with auto-restart
pnpm dev
# Run tests
pnpm testPackage Commands (all packages follow same pattern)
# Build the package
pnpm build
# TypeScript type checking
pnpm typecheck
# Run tests
pnpm test # Watch mode
pnpm test:run # Run once
# Development mode (TypeScript watch)
pnpm devLinear State Management
The agent automatically moves issues to the "started" state when assigned. Linear uses standardized state types:
- State Types Reference: https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference/enums/ProjectStatusType
- Standard Types:
triage,backlog,unstarted,started,completed,canceled - Issue Assignment Behavior: When an issue is assigned to the agent, it automatically transitions to a state with
type === 'started'(In Progress)
Important Development Notes
- Edge-Proxy Architecture: The project is transitioning to separate OAuth/webhook handling from Claude processing.
- Dependencies:
- The claude-parser package requires
jqto be installed on the system - Uses pnpm as package manager (v10.11.0)
- TypeScript for all new packages
- The claude-parser package requires
- Git Worktrees: When processing issues, the agent creates separate git worktrees. If a
cyrus-setup.shscript exists in the repository root, it's executed in new worktrees for project-specific initialization. Symmetrically, if acyrus-teardown.shscript exists in the repository root, it's executed in the worktree directory immediately before the worktree is removed when the issue reaches a terminal state (completed / canceled / deleted). - Testing: Uses Vitest for automated tests. Choose proportionate pre-commit validation using the policy above; do not add tests solely because a file changed.
- Sandbox Egress Proxy & CA Certificates: When sandbox is enabled, the egress proxy generates a CA cert at
~/.cyrus/certs/cyrus-egress-ca.pemfor TLS interception. Per-session env vars are set inRunnerConfigBuilder.buildSandboxConfig()to cover most tools:NODE_EXTRA_CA_CERTS(Node.js),GIT_SSL_CAINFO(Git),SSL_CERT_FILE(OpenSSL/Ruby),REQUESTS_CA_BUNDLE/PIP_CERT(Python),CURL_CA_BUNDLE(curl/OpenSSL),CARGO_HTTP_CAINFO(Rust),AWS_CA_BUNDLE(AWS CLI),DENO_CERT(Deno)systemWideCertconfig flag: Whensandbox.systemWideCert: trueis set inconfig.json, all per-session CA cert env vars above are skipped — the OS cert store handles trust for all tools. Set this after trusting the CA cert system-wide viasudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.cyrus/certs/cyrus-egress-ca.pem(macOS) orsudo cp ~/.cyrus/certs/cyrus-egress-ca.pem /usr/local/share/ca-certificates/cyrus-egress-ca.crt && sudo update-ca-certificates(Linux).- Gotchas — tools that ignore env vars and require system keychain trust: Bun, .NET/nuget, curl on macOS (compiled against SecureTransport, the default). For these, users must trust the cert system-wide (see above) regardless of the
systemWideCertsetting. - Gotcha — parent process env vars: If
GIT_SSL_CAINFO,SSL_CERT_FILE, orCURL_CA_BUNDLEare set in the Cyrus parent process env (e.g., from a previous test or.env), they can break git push/fetch from the Cyrus process itself (not child sessions). The parent process does not route through the egress proxy, so these vars should not be set in~/.cyrus/.env. - Pre-existing
NODE_EXTRA_CA_CERTSfrom the host environment are merged into a combined bundle viaEgressProxy.buildCACertBundle().
Two Separate Permission Systems — Tool vs. Sandbox: Claude Code enforces security through two independent mechanisms that must both be configured correctly:
A. Tool permissions (
allowedTools/disallowedTools→--allowedTools/--disallowedToolsCLI flags)- Checked by Claude Code's permission layer — NOT enforced at the OS level.
Read(~/**)does not work as adisallowedToolspattern —~is not expanded to the home directory path by Claude Code, so the pattern never matches. Other**glob patterns work fine; the problem is specific to the~prefix.disallowedToolsIS an instant deny that takes precedence overallowedTools— if a parent path is denied, all its descendants are blocked. The problem is purely that~is never expanded, soRead(~/**)silently matches nothing.- Absolute paths in tool patterns require a double leading slash — Claude Code's parser requires
//absolute/path(e.g.Read(//Users/alice/.ssh/**)) for absolute paths. This is also the key to working with home directory paths: instead ofRead(~/**)(which doesn't expand), you useRead(///Users/alice/.ssh/**)with the resolved absolute path. The double-slash is added in code as/${fullPath}wherefullPathis already absolute. - Solution:
buildHomeDirectoryDisallowedTools(cwd, allowedDirectories)inpackages/claude-runner/src/home-directory-restrictions.tsenumerates the home directory explicitly using these double-slash absolute paths — bypassing the tilde expansion issue by naming each sibling concretely.allowedDirectoriespaths are excluded so the attachments dir and repo paths remain readable. This is wired intoClaudeRunner.tsautomatically.
B. Sandbox filesystem permissions (
sandbox.filesystem.allowRead/denyRead/allowWrite)- Enforced at the OS level via bubblewrap (Linux) or macOS sandbox — no shell or Claude Code involvement.
- A true deny+whitelist model works here:
denyRead: ["~/"]+allowRead: ["."]is sufficient to deny the entire home directory while allowing the worktree."."resolves to the cwd of the primary folder Claude is working in. - Configured in
buildSandboxConfig()inpackages/edge-worker/src/RunnerConfigBuilder.ts.
Key invariant: If sandbox is enabled, both systems should restrict home directory reads. If sandbox is disabled (e.g. in local dev), only tool permissions apply — and those require explicit enumeration via
buildHomeDirectoryDisallowedTools.- Updating
@anthropic-ai/claude-agent-sdk: Whenever you update theclaude-agent-sdkdependency (which bundles a specific Claude Code version), you must refresh the tool allowance lists inpackages/claude-runner/src/config.ts. Run:
This executes./scripts/extract-claude-tools.shclaude -p "say hi" --output-format stream-json --verboseand extracts the tool names from theinitblock. Compare the output against theavailableToolsarray inconfig.tsand update it to match. Also reviewreadOnlyTools,writeTools, and the helper functions to ensure new tools are categorized correctly. Failing to do this can cause sessions to silently miss new tools or reference removed ones. - Routing Behavior & Self-Describing Prompts: When changing repository routing behavior (e.g., description-tag syntax, label routing, base branch overrides, multi-repo support), you must also update the system prompts that describe these capabilities to Cyrus itself. The product relies on self-describing prompts so that Cyrus can correctly instruct users and create properly-routed sub-issues. Known locations (not exhaustive):
packages/edge-worker/src/PromptBuilder.ts— Generates the<repository_routing_context>XML block included in session system prompts, documenting routing methods and priority orderpackages/edge-worker/src/SlackChatAdapter.ts— Builds the Slack chat system prompt including orchestration notes with repo routing syntaxpackages/edge-worker/src/ZulipChatAdapter.ts— Same, for the Zulip chat system promptpackages/edge-worker/src/ActivityPoster.ts— Posts routing activities to Linear timeline (method display names, formatting)
Adding a new top-level
EdgeWorkerConfigfield: Adding a property to theEdgeConfigSchemaZod schema inpackages/core/src/config-schemas.tsis not enough to make it available at runtime. Two hand-maintained copy sites exist, and both now have guardrails that fail fast when a field is missed (added afterstrictMcpConfigwas silently dropped in CYPACK-1478;slackAllowedTools& friends were dropped the same way in CYHOST-967):- Cold start —
WorkerService.startEdgeWorker()inapps/cli/src/services/WorkerService.tsspreads the entire file config (...edgeConfig) into theEdgeWorkerConfig, so plain pass-through fields flow automatically and need no code change. Only add an explicit line below the spread if the field needs env-var precedence or a computed/param override — never add a redundant pass-through line. The"forwards every EdgeConfig field"test inWorkerService.test.tshas a schema-complete fixture that fails when a new schema field isn't covered. - Hot reload —
ConfigManagerinpackages/edge-worker/src/ConfigManager.tsmerges a hardcoded list of fields inloadConfigSafely()and watches the same list indetectGlobalConfigChanges(). Both are driven by theRELOAD_MERGED_KEYSconst at the top of the file, which has a compile-time exhaustiveness check: adding a schema field without classifying it intoRELOAD_MERGED_KEYS(plus a merge line inloadConfigSafely()) orRELOAD_EXEMPT_KEYSis atscerror that names the missing key.
So the workflow for a new field is: add it to
EdgeConfigSchema, lettscand the CLI test point at the two sites, add the merge line +RELOAD_MERGED_KEYSentry (hot reload) and — only if it needs env precedence — an explicit override instartEdgeWorker().- Cold start —
- Changing the
cyrus-toolsMCP server's exposed tools: When you add or remove a tool from the inlinecyrus-toolsMCP server (the one served byapps/proxy/ wired up inMcpConfigService.buildMcpConfig), you must also update the catalogcyrus-hostedkeeps for the/settings/toolsUI. cyrus-hosted maintains a per-server tool list so its grid can render a row per tool (with the right per-platform toggle) without having to introspect a live MCP server. Today that catalog lives inapps/app/src/lib/cyrus-config/builder.tsunder theKNOWN_MCP_TOOLSmap (look for the"mcp__cyrus-tools"key); update that array in the same PR — the same constants are also imported by the platform-default lists inpackages/core/src/allowed-tools-defaults.tswhen a particularcyrus-toolstool is enabled by default, so reflect that there too if the new tool should be on out of the box.
Symptom of forgetting this: the new tool is callable at runtime (the runtime knows about it via the live MCP server) but it never appears in the /settings/tools MCP Servers section — so operators can't see it, can't toggle it on/off per platform, and per-repo overrides treat it as unknown.
- Adding a new path-bearing field to
EdgeWorkerConfig: cyrus-hosted emits self-host paths with literal~/prefixes (e.g.~/.cyrus/mcp-configs/mcp-supabase.json) because the user's home directory is not known server-side. Node'sfs.readFileSyncdoes not expand~, so any path string that flows fromconfig.jsontoreadFileSync(or to a child SDK that does the same) must be run throughresolvePathfromcyrus-corefirst.
Per-repository paths (repositoryPath, workspaceBaseDir, mcpConfigPath, promptTemplatePath) are already normalized at three sites in EdgeWorker.ts: the constructor, addNewRepositories, and updateModifiedRepositories. Each builds a resolvedRepo via resolvePath(...) before inserting into this.repositories, so downstream consumers (e.g. RunnerConfigBuilder, McpConfigService.buildMergedMcpConfigPath) get already-absolute paths.
Top-level (non-repo-scoped) path fields are a separate, easy-to-miss codepath. They live directly on EdgeWorkerConfig and are read straight off this.config.<field> — they do not go through the repo-resolution loop. When you add one, you must also normalize it. The canonical site for this is EdgeWorker.normalizeConfigPaths() (called once in the constructor and once on configChanged); add your field there alongside slackMcpConfigs / linearMcpConfigs / githubMcpConfigs.
Symptom of forgetting this: self-host sessions crash with ENOENT: no such file or directory, open '~/.cyrus/...' while cloud sessions (which get absolute paths from cyrus-hosted) work fine. This bit us with the three platform MCP config arrays added in CYHOST-967 / v0.2.53 — they were the only path-bearing fields on EdgeWorkerConfig that bypassed normalization, and crashed every self-host session that had a connected platform MCP integration.
Dependency Security Policy (MANDATE)
Our team's mandated approach for addressing Dependabot advisories and other transitive-dependency vulnerabilities:
- Prefer direct-dep bumps in the owning
package.json. If the vulnerable dep is transitively pulled in by one of our direct dependencies, bump that direct dep (in the specific package that owns it —packages/*orapps/*, not the root) to a version whose resolved dep graph includes the patched transitive. Regenerate the lockfile and let pnpm's natural resolution do the work. - Only use workspace-level overrides in
pnpm-workspace.yamlwhen a direct-dep bump cannot reach the vulnerable transitive. This is the fallback for deep transitives (3+ levels deep) whose owning direct dep has no released version that resolves to the patched transitive — typically because upstream hasn't released yet or pins its transitive too loosely for us to reach. Document the reason inline with a brief comment or commit message. - Always clean up overrides when a future dep bump makes them redundant.
When you update a direct dependency (security or otherwise), check whether
any existing override entry is now satisfied naturally by the
new resolution. If so, remove that override in the same change. Verify
with
pnpm install && pnpm auditthat the removal is safe before committing. - Verify with
pnpm audit. After any dependency change,pnpm auditmust report zero advisories. Commit the regeneratedpnpm-lock.yamlalongside thepackage.jsonchange.
Why this matters: overrides are a blunt instrument that hide the real source of a dep. Bumping the owning direct dep is precise, gets picked up by Dependabot, keeps our graph honest, and prevents override rot where entries live on long after they stop doing anything.
Development Workflow
When working on this codebase, follow these practices:
- As part of submitting a Pull Request:
- Update
CHANGELOG.mdunder the## [Unreleased]section with your changes - Use appropriate subsections:
### Added,### Changed,### Fixed,### Removed - Include brief, clear descriptions of what was changed and why
- Include the PR number/link: If the PR is already created, include the link (e.g.,
([#123](https://github.com/ceedaragents/cyrus/pull/123))). If not, create the PR first, then update the changelog with the link, commit, and push. - Run relevant existing checks per the verification policy; use
pnpm test:packages:runwhen package-wide regression coverage is warranted - Run
pnpm typecheckandpnpm buildwhen affected by the change or required by repository hooks/CI
- Update
- Internal Changelog:
- For internal development changes, refactors, tooling updates, or other non-user-facing modifications, update
CHANGELOG.internal.md. - Follow the same format as the main changelog.
- This helps track internal improvements that don't need to be exposed to end-users.
- For internal development changes, refactors, tooling updates, or other non-user-facing modifications, update
- Changelog Format:
- Follow Keep a Changelog format
- Focus only on end-user impact: Write entries from the perspective of users running the
cyrusCLI binary - Avoid technical implementation details, package names, or internal architecture changes
- Be concise but descriptive about what users will experience differently
- Group related changes together
- Example: "New comments now feed into existing sessions" NOT "Implemented AsyncIterable
<SDKUserMessage>for ClaudeRunner"
Key Code Paths
- Linear Integration:
apps/cli/services/LinearIssueService.mjs - Claude Execution:
packages/claude-runner/src/ClaudeRunner.ts - Session Management:
packages/core/src/session/ - Edge Worker:
packages/edge-worker/src/EdgeWorker.ts - GitHub Token Resolution:
EdgeWorker.resolveGitHubToken()— three-tier fallback: proxy-forwarded installation token → self-minted GitHub App token (viaGitHubAppTokenProvider) →GITHUB_TOKENPAT. Self-hosted users with a GitHub App use the middle tier; cloud/proxy users get tokens forwarded; legacy users fall back to a PAT. - GitHub App Token Minting:
packages/github-event-transport/src/GitHubAppTokenProvider.ts— signs JWTs with the App's private key and exchanges them for short-lived installation tokens. Caches tokens and refreshes 5 minutes before expiry. - OAuth Flow:
apps/proxy/src/services/OAuthService.mjs
Testing MCP Linear Integration
To test the Linear MCP (Model Context Protocol) integration in the claude-runner package:
- Setup Environment Variables:
cd packages/claude-runner # Create .env file with your Linear API token echo "LINEAR_API_TOKEN=your_linear_token_here" > .env - Build the Package:
pnpm build - Run the Test Script:
node test-scripts/simple-claude-runner-test.js
The test script demonstrates:
- Loading Linear API token from environment variables
- Configuring the official Linear HTTP MCP server
- Listing available MCP tools
- Using Linear MCP tools to fetch user info and issues
- Proper error handling and logging
The script will show:
- Whether the MCP server connects successfully
- What Linear tools are available
- Current user information
- Issues in your Linear workspace
This integration is automatically available in all Cyrus sessions - the EdgeWorker automatically configures the official Linear MCP server for each repository using its Linear token.
Publishing
For publishing and release instructions, use the /release skill (within Claude Code or Claude Agent SDK) which provides a complete guide for publishing packages to npm in the correct dependency order. Invoke it with:
/releaseGemini CLI for Testing
The project uses Google's Gemini CLI for testing the GeminiRunner implementation. Install the specific version:
npm install -g @google/gemini-cli@0.17.0This ensures consistency when running integration tests that interact with the Gemini API.
Gemini Configuration Reference
For detailed information about Gemini CLI configuration options (settings.json structure, model aliases, previewFeatures, etc.), refer to:
- Official Documentation: https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/configuration.md
The GeminiRunner automatically generates a ~/.gemini/settings.json file with single-turn model aliases and preview features enabled if one doesn't already exist.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

