Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/zjshen14/opencli/claude-mdgit clone --depth 1 https://github.com/zjshen14/opencliWhat 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 | $0.03561 | $0.03561 |
| Opus 5 | $0.01781 | $0.01781 |
| Sonnet 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 2d 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.
- 2d 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 10d ago), licensed MIT. It adds 3,561 tokens to every session, about $0.0178 per session on Opus 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.
Other instructions, from other repositories
deer-flow CLAUDE.md
Claude Code instructions for bytedance/deer-flow: The repo's agent guidance lives in AGENTS.md so it is shared across coding agents (Claude Code, Codex, and others). Claude Code imports it below.
zeroclaw CLAUDE.md
Claude Code instructions for zeroclaw-labs/zeroclaw, covering claude.md — zeroclaw (claude code), claude code settings, hooks and slash commands.
nuwax AGENTS.md
Instructions for nuwax-ai/nuwax, covering ai agent system documentation, 系统概述, ai agent 架构, 核心组件 and ai 功能特性.
AgentEval memory-benchmarks.instructions.md
Guidelines for working with AgentEval Memory module — benchmarks, reporting, HTML reports, and LongMemEval integration.
AgentEval copilot-instructions.md
Instructions for AgentEvalHQ/AgentEval, covering agenteval - ai coding agent instructions, architecture overview, environment setup, optional: secondary models for comparison and build & test commands.
framework AGENTS.md
Instructions for ai-driven-dev/framework, covering agents.md, behavior, communication, action and memory management.