Borrowing it
Nothing to install: this file belongs to zjshen14/opencli. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/zjshen14/opencli/main/CLAUDE.mdgit clone --depth 1 https://github.com/zjshen14/opencliWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/zjshen14/opencli/claude-md)<a href="https://agentmods.dev/instructions/zjshen14/opencli/claude-md"><img src="https://agentmods.dev/badge/instructions/zjshen14/opencli/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/zjshen14/opencli/claude-md"><img src="https://agentmods.dev/badge/instructions/zjshen14/opencli/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.03561 | $0.03561 |
| Opus 5.5 | $0.01424 | $0.01424 |
| Sonnet 5.5 | $0.00712 | $0.00712 |
| Haiku 4.5 | $0.00356 | $0.00356 |
Grade A, and why
opencli CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
This is a copy
95% identical to opencli AGENTS.md — 7 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 175 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Keep in sync with
AGENTS.md— both files carry the same content; only the first-line header differs. Update both in the same commit whenever either changes.
Project Overview
OpenCLI — an open-source AI agent CLI that supports Google Gemini and Anthropic Claude models, modeled after Claude Code. The implementation is a working prototype in TypeScript/Node.js (ESM, Node 20+).
Getting Started with a Task
New to this project? Start here: Task Workflow — it walks you through the typical task lifecycle, from reading the issue to committing your work. It references this document and docs/engineering-practices.md for the conventions you need to know.
Commands
npm run dev # Run interactive REPL (auto-loads .env)
npm run dev run "<prompt>" # One-shot prompt
npm run build # Bundle with tsup → dist/
npm run typecheck # tsc --noEmit
npm run lint # ESLint
npm run lint:fix # ESLint with auto-fix
npm run format # Prettier --write src/**/*.ts
npm run format:check # Prettier check (no write)
npm test # Vitest
npm run test:single # Vitest verbose (single run)
API keys are loaded from .env (GEMINI_API_KEY for Gemini models, ANTHROPIC_API_KEY for Claude models). Default model: gemini-3.1-flash-lite-preview.
Source Structure
src/
cli/ # Thin adapter — reads config/env, wires dependencies, runs the REPL
index.ts # Entry point — commander CLI (chat / run / sessions / config commands)
repl.ts # Interactive REPL, /slash command interception, skill loading, session logging
renderer.ts # MarkdownStreamRenderer (paragraph-level streaming), tool call display
input.ts # Raw-mode readline, /slash popup with arrow-key navigation
confirm.ts # HITL confirmation dialog (y/n/always); reads and writes settings
keys.ts # API key resolution — env var → config file lookup
mcp-cmd.ts # /mcp slash command handler (list, add, remove, test)
mentions.ts # @-mention expansion — resolves @file references before the agent sees them
plan.ts # /plan slash command handler — plan pass → approval → react execution
runner.ts # runAgentTurn() helper extracted from repl.ts
core/ # Pure library — no process.env reads, no CLI/state imports
agent.ts # Agentic loop: stream → collect function calls → execute → feed back
executor.ts # Parallel tool execution, skill activation dispatch, HITL confirmation gate,
# provenance-tracking confirmation bump (#309): results from web_fetch/mcp__*/
# out-of-project reads are tagged untrusted; while any is consumed this turn,
# outbound/mutating tools (bash/write/edit/multi_edit/web_fetch/mcp__*) are forced
# through the gate (same-batch reads arm it pre-dispatch)
context.ts # Conversation history, skill content injection, context pruning
prompt.ts # DEFAULT_SYSTEM_INSTRUCTION template + loadSystemInstruction() (OPENCLI_SYSTEM_MD)
compact.ts # compactContext() — LLM-based context compaction for /compact command
observability.ts # ObservabilityEvent types; token + turn metrics emitted by the agent loop
providers/ # LLM clients — no CLI/state imports
types.ts # Shared types: Message, StreamEvent, ToolDefinition, ToolResult, thoughtSignature
client.ts # LLMClient interface — the provider plug point
registry.ts # PRESETS — single source of truth for provider wire format, base URL, key env
# vars, context windows, capabilities. Adding a provider is a data change.
gemini.ts # GeminiClient implements LLMClient; Gemini-specific schema conversion internal
anthropic.ts # AnthropicClient implements LLMClient; translates role/tool formats internally
openai.ts # OpenAIClient implements LLMClient; also serves every OpenAI-compatible OSS
# provider and local Ollama
salvage.ts # Recovers tool calls OSS models emit as text instead of structured tool_calls
ollama-discovery.ts # Best-effort /api/tags query — local context window + tool capability
factory.ts # createClient(model, apiKey) — picks provider via the registry
schema.ts # Generic toolToDefinition() + activateSkillDefinition (plain JSONSchema, no provider deps)
retry.ts # withRetry() — shared exponential-backoff retry wrapper for provider streams
errors.ts # toFriendlyError() — normalises provider errors to human-readable messages
tools/
base.ts # Tool interface + JSONSchema type
registry.ts # ToolRegistry: register, execute, list
file/ # read, write, edit, multi_edit, glob, grep, ls; paths.ts (symlink-aware containment + credential-path checks)
exec/ # bash (with requiresConfirmation for non-safe commands); sandbox/ (bwrap, sandbox-exec, passthrough)
web/ # web_fetch tool
task/ # todo_write and todo_read tools
think.ts # think tool — private scratchpad; skipped for native-thinking models
index.ts # createDefaultRegistry(model?, runner?) factory — omits think for native-thinking models
skills/
registry.ts # Discover SKILL.md files across 4 scoped directories
loader.ts # Parse SKILL.md frontmatter, !{cmd} preprocessing, $ARGUMENTS substitution
builtin/ # review, commit, explain, debug, test, gh-issue, gh-pr, branch, run-tests, typecheck, lint, new-skill, changelog
mcp/ # MCP integration — bridges external tool servers into ToolRegistry
types.ts # McpStdioServer, McpHttpServer, McpServerConfig, McpConfig, McpToolInfo
config.ts # loadMcpConfig(agentDir) — reads ~/.opencli/mcp.json; expands ${VAR} refs
client.ts # McpClient — connects via stdio or HTTP, enforces per-server callTimeout
adapter.ts # mcpToolToTool() — wraps one MCP tool as a Tool (name: mcp__server__tool)
manager.ts # McpManager — connects all servers in parallel, registers adapters
index.ts # Re-exports all public types and classes
state/
config.ts # ~/.opencli/config.json load/save; exports AGENT_DIR, Config (incl. anthropicApiKey)
session.ts # JSONL session logs at ~/.opencli/projects/<cwd>/; create, list, resume
settings.ts # .opencli/settings.json load/save; holds project-level Permissions (HITL allow/ask/deny list)
snapshot.ts # SnapshotManager — git stash create/restore for per-session working-tree snapshots
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 175 lines · 3,561 tokens per session scan A 372c75bceb61
opencli CLAUDE.md is an instructions file published in the GitHub repository zjshen14/opencli (2 stars, last pushed 2mo ago), licensed MIT. It adds 3,561 tokens to every session, about $0.0142 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 95% identical to opencli AGENTS.md, differing in 7 lines, and is treated as a copy.
opencli CLAUDE.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| opencli CLAUDE.mdzjshen14/opencli | Instructions file | 2 | 2mo ago | MIT | A | 3,561 | Claude Code |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | yesterday | MIT | A | 7,461 | Codex, OpenCode |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | yesterday | MIT | A | 4,680 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 5,516 | GitHub Copilot |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 3,093 | GitHub Copilot |
| deepseek-harness AGENTS.mddeepseek-ai/deepseek-harness | Instructions file | 274k | 2d ago | MIT | A | 4,313 | Codex, OpenCode |