This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Chaterm is an Electron-based AI-driven terminal tool with intelligent command completion, multi-device management, AI Agent capabilities, and enterprise-grade security.
Tech Stack: Vue 3 + TypeScript + Pinia + Ant Design Vue + Monaco Editor + xterm.js + Electron 30 + better-sqlite3 + ssh2 + node-pty + Anthropic/OpenAI/Bedrock/Ollama + Vitest + Playwright
Three-layer: Renderer (Vue 3 SPA) → Preload (contextBridge IPC) → Main (Agent, SSH, Storage).
Main Process Aliases: @shared @core @services @integrations @utils @api → src/main/agent/*
Renderer Process Aliases: @renderer @views @router @store @utils @api @config @ → src/renderer/src/*
node scripts/patch-package-lock.js && npm install # setup
npm run dev # dev server
npm run lint && npm run typecheck && npm test # pre-commit checksState assumptions explicitly. If uncertain, ask rather than guess. Push back when a simpler approach exists. Stop when confused — name what's unclear.
Minimum code that solves the problem. No speculative features. No abstractions for single-use code. If a senior engineer would call it overcomplicated, simplify.
Touch only what you must. Don't "improve" adjacent code, comments, or formatting. Don't refactor what isn't broken. Match existing style.
If two existing patterns contradict, pick one (more recent / more tested), explain why, and flag the other for cleanup. Don't blend conflicting patterns.
Before adding code in a file, read its exports, the immediate caller, and any obvious shared utilities. "Looks orthogonal to me" is dangerous — if unsure why code is structured a certain way, ask.
"Completed" is wrong if anything was skipped silently. "Tests pass" is wrong if any were skipped. Default to surfacing uncertainty, not hiding it.
- Minimize Change Scope: Only modify files directly related to current requirements
- Type Safety First: Strict TypeScript, avoid
any; new IPC channels must define types insrc/preload/index.d.ts - Maintain Contract Stability: Do not break existing IPC interfaces, Pinia Stores, or database table structures
- Test Coverage: Core logic changes require adding or updating unit tests
- No Emojis: Prohibited in code, comments, logs, strings
- English Comments: All code comments must be in English
- No Console Logging: Use
createLogger(module)from the project logger — neverconsole.* - Log Sanitization: Never log objects that may contain credentials (configs, API configs, keychain objects). Never use string interpolation to embed sensitive values (hostnames, IPs, API keys, passwords). Use safe fields only:
logger.info('msg', { event: 'name', id, count, hasPassword: !!password }). Use boolean flags (hasApiKey,hasPrivateKey) instead of actual values.
- No auto git operations: Never run
git addorgit commitautomatically - After changes, only show
git statusandgit difffor user review
- Main: no blocking event loop; IPC payloads must be serializable. Entry:
src/main/index.ts. Window management:src/main/windowManager.ts - Preload:
contextBridgeonly; minimal API surface; types insrc/preload/index.d.ts - Renderer: Vue 3 Composition API; Pinia for state. Entry:
src/renderer/src/main.ts. Routes:src/renderer/src/router/routes.ts. Guards:src/renderer/src/router/guards.ts
api/— AI provider adapters (Anthropic, OpenAI, Bedrock, Ollama)core/— controller, prompts, storage, contextservices/— telemetry, diff, terminalintegrations/— remote-terminal, toolsshared/— shared types and constantsutils/— utility functions
Extending a provider: create file in api/providers/, register in api/providers/types.ts, complete in api/index.ts, route network requests through api/retry.ts.
New tables or schema changes:
- Create timestamped file in
migrations/ - Ensure idempotent and replayable
- Add service methods in corresponding
.service.ts - Define types in
types.ts
All user-facing text must be translated into all 11 locale files: zh-CN zh-TW en-US ja-JP ko-KR de-DE fr-FR it-IT pt-PT ru-RU ar-AR
npm run lint && npm run typecheck && npm testpasses- No formatting changes to unrelated files
- Commit message follows Conventional Commits
- UI changes: all 11 locale files updated
- DB changes: migration file created
- New IPC channels: types defined in
src/preload/index.d.ts - No sensitive data committed
- No API keys, tokens, private domains in commits
- All IPC via
contextBridge; validate all renderer IPC messages - Evaluate security and bundle size before adding dependencies
- Contribution:
CONTRIBUTING.md/CONTRIBUTING_zh.md - Agent development:
AGENTS.md - Security policy:
SECURITY.md