Skip to content
clawd-skill logo

Clawd — Repository Skill

clawd-skill

Development conventions and architecture guide for the Clawd CLI repository.

Piyush-Goenka/Clawd0installs0stars

SKILL.md

Full skill instructions

Clawd — Repository Skill

Project Overview

Clawd is a terminal coding assistant: file editing, shell commands, git workflows, code review, multi-agent coordination, IDE integration (VS Code, JetBrains), and Model Context Protocol (MCP), backed by the Anthropic API where configured.

Codebase: ~1,900 files, 512,000+ lines of TypeScript under src/.

Tech Stack

ComponentTechnology
LanguageTypeScript (strict mode, ES modules)
RuntimeBun (JSX support, bun:bundle feature flags)
Terminal UIReact + Ink (React for CLI)
CLI ParserCommander.js (@commander-js/​extra-typings)
API Client@anthropic-ai/​sdk
ValidationZod v4
Linter/​FormatterBiome
AnalyticsGrowthBook (feature flags & A/​B testing)
ProtocolModel Context Protocol (MCP)

Architecture

Directory Map (src/)

DirectoryPurpose
commands/~50 slash commands (/​commit, /​review, /​config, etc.)
tools/~40 agent tools (Bash, FileRead, FileWrite, Glob, Grep, etc.)
components/~140 Ink/​React UI components for terminal rendering
services/External integrations (API, OAuth, MCP, LSP, analytics, plugins)
bridge/Bidirectional IDE communication layer
state/React context + custom store (AppState)
hooks/React hooks (permissions, keybindings, commands, settings)
types/TypeScript type definitions
utils/Utilities (shell, file ops, permissions, config, git)
screens/Full-screen UIs (Doctor, REPL, Resume, Compact)
skills/Bundled skills + skill loader system
plugins/Plugin system (marketplace + bundled plugins)
coordinator/Multi-agent coordination & supervisor logic
tasks/Task management (shell tasks, agent tasks, teammates)
context/React context providers (notifications, stats, FPS)
memdir/Persistent memory system (CLAUDE.md, user/​project memory)
entrypoints/Initialization logic, Agent SDK, MCP entry
voice/Voice input/​output (STT, keyterms)
vim/Vim mode keybinding support
schemas/Zod configuration schemas
keybindings/Keybinding configuration & resolver
migrations/Config migrations between versions
outputStyles/Output formatting & theming
query/Query pipeline & processing
server/Server/​daemon mode
remote/Remote session handling

Key Files

FileRole
src/​main.tsxCLI entry point (Commander parser, startup profiling)
src/​QueryEngine.tsCore LLM API caller (streaming, tool-call loops)
src/​Tool.tsTool type definitions & buildTool factory
src/​tools.tsTool registry & presets
src/​commands.tsCommand registry
src/​context.tsSystem/​user context collection (git status, memory)
src/​cost-tracker.tsToken cost tracking

Entry Points & Initialization Sequence

  1. src/​main.tsx — Commander CLI parser, startup profiling
  2. src/​entrypoints/​init.ts — Config, telemetry, OAuth, MDM
  3. src/​entrypoints/​cli.tsx — CLI session orchestration
  4. src/​entrypoints/​mcp.ts — MCP server mode
  5. src/​entrypoints/​sdk/ — Agent SDK (programmatic API)
  6. src/​replLauncher.tsx — REPL session launcher

Startup performs parallel initialization: MDM policy reads, Keychain prefetch, feature flag checks, then core init.

Patterns & Conventions

Tool Definition

Each tool lives in src/​tools/​{ToolName}/ and uses buildTool:

export const MyTool = buildTool({
  name: 'MyTool',
  aliases: ['my_tool'],
  description: 'What this tool does',
  inputSchema: z.object({
    param: z.string(),
  }),
  async call(args, context, canUseTool, parentMessage, onProgress) {
    // Execute and return { data: result, newMessages?: [...] }
  },
  async checkPermissions(input, context) { /​* Permission checks */ },
  isConcurrencySafe(input) { /​* Can run in parallel? */ },
  isReadOnly(input) { /​* Non-destructive? */ },
  prompt(options) { /​* System prompt injection */ },
  renderToolUseMessage(input, options) { /​* UI for invocation */ },
  renderToolResultMessage(content, progressMessages, options) { /​* UI for result */ },
})

Directory structure per tool: {ToolName}.ts or .tsx (main), UI.tsx (rendering), prompt.ts (system prompt), plus utility files.

Command Definition

Commands live in src/​commands/ and follow three types:

  • PromptCommand — Sends a formatted prompt with injected tools (most commands)
  • LocalCommand — Runs in-process, returns text
  • LocalJSXCommand — Runs in-process, returns React JSX
const command = {
  type: 'prompt',
  name: 'my-command',
  description: 'What this command does',
  progressMessage: 'working...',
  allowedTools: ['Bash(git *)', 'FileRead(*)'],
  source: 'builtin',
  async getPromptForCommand(args, context) {
    return [{ type: 'text', text: '...' }]
  },
} satisfies Command

Commands are registered in src/​commands.ts and invoked via /​command-name in the REPL.

Component Structure

  • Functional React components with Ink primitives (Box, Text, useInput())
  • Styled with Chalk for terminal colors
  • React Compiler for optimized re-renders
  • Design system primitives in src/​components/​design-system/

State Management

  • AppState via React context + custom store (src/​state/​AppStateStore.ts)
  • Mutable state object passed to tool contexts
  • Selector functions for derived state
  • Change observers in src/​state/​onChangeAppState.ts

Permission System

  • Modes: default (prompt per operation), plan (show plan, ask once), bypassPermissions (auto-approve), auto (ML classifier)
  • Rules: Wildcard patterns — Bash(git *), FileEdit(/​src/​*)
  • Tools implement checkPermissions() returning { granted: boolean, reason?, prompt? }

Feature Flags & Build

Bun's bun:bundle feature flags enable dead-code elimination at build time:

import { feature } from 'bun:bundle'
if (feature('PROACTIVE')) { /​* proactive agent tools */ }

Notable flags: PROACTIVE, KAIROS, BRIDGE_MODE, VOICE_MODE, COORDINATOR_MODE, DAEMON, WORKFLOW_SCRIPTS.

Some features are also gated via process.env.USER_TYPE === 'ant'.

Naming Conventions

ElementConventionExample
FilesPascalCase (exports) or kebab-case (commands)BashTool.tsx, commit-push-pr.ts
ComponentsPascalCaseApp.tsx, PromptInput.tsx
TypesPascalCase, suffix with Props/​State/​ContextToolUseContext
Hooksuse prefixuseCanUseTool, useSettings
ConstantsSCREAMING_SNAKE_CASEMAX_TOKENS, DEFAULT_TIMEOUT_MS

Import Practices

  • ES modules with .js extensions (Bun convention)
  • Lazy imports for circular dependency breaking: const getModule = () => require('./​heavy.js')
  • Conditional imports via feature flags or process.env
  • biome-ignore markers for manual import ordering where needed

Services

ServicePathPurpose
APIservices/​api/Anthropic SDK client, file uploads
MCPservices/​mcp/MCP client, tool/​resource discovery
OAuthservices/​oauth/OAuth 2.0 auth flow
LSPservices/​lsp/Language Server Protocol manager
Analyticsservices/​analytics/GrowthBook, telemetry, events
Pluginsservices/​plugins/Plugin loader, marketplace
Compactservices/​compact/Context compression
Policy Limitsservices/​policyLimits/Org rate limits, quota checking
Remote Settingsservices/​remoteManagedSettings/Managed settings sync (Enterprise)
Token Estimationservices/​tokenEstimation.tsToken count estimation

Configuration

Settings locations:

  • Global: ~/​.claude/​config.json, ~/​.claude/​settings.json
  • Project: .claude/​config.json, .claude/​settings.json
  • System: macOS Keychain + MDM, Windows Registry + MDM
  • Managed: Remote sync for Enterprise users

Guidelines

  1. Read relevant source files before making changes — understand existing patterns first.
  2. Follow the tool/​command/​component patterns above when adding new ones.
  3. Keep edits minimal and focused — avoid unnecessary refactoring.
  4. Use Zod for all input validation at system boundaries.
  5. Gate experimental features behind bun:bundle feature flags or env checks.
  6. Respect the permission system — tools that modify state must implement checkPermissions().
  7. Use lazy imports when adding dependencies that could create circular references.
  8. Update this file as project conventions evolve.

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View