or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdcli-interface.mdcli-options.mdconfiguration.mdcustom-commands.mdhooks.mdide-integration.mdindex.mdmcp-integration.mdsdk-integration.mdslash-commands.md
tile.json

index.mddocs/

Claude Code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows through natural language commands. It integrates directly into terminal environments and IDEs, providing AI-assisted coding capabilities.

Package Information

  • Package Name: @anthropic-ai/claude-code
  • Package Type: npm
  • Language: JavaScript (distributed as binary)
  • Installation: npm install -g @anthropic-ai/claude-code
  • CLI Command: claude
  • SDK Support: TypeScript, Python

Core Imports

For TypeScript SDK integration:

import { ClaudeCodeSDK } from '@anthropic-ai/claude-code';

For Python SDK integration:

from claude_code_sdk import ClaudeCodeSDK

Installation

# Global CLI installation
npm install -g @anthropic-ai/claude-code

# SDK installation for TypeScript projects
npm install @anthropic-ai/claude-code

# SDK installation for Python projects
pip install claude-code-sdk

Basic Usage

Interactive Mode

# Navigate to your project directory
cd /path/to/your/project

# Start Claude Code interactive session
claude

# Natural language commands:
# - "Help me fix this bug in authentication.js"
# - "Create a new component for user profiles"
# - "Explain what this function does"
# - "Run the tests and fix any failures"

# Slash commands for specific actions:
# /add-dir path/to/directory  # Add directories to context
# /bug "Issue description"     # Report bugs
# /cost                        # View usage costs
# /todos                       # List current todos

Print Mode (Non-interactive)

# Run Claude Code with a single prompt
claude --print "Fix the bug in auth.js"

# JSON output for programmatic use
claude --print "Analyze code quality" --output-format=stream-json

SDK Usage

// TypeScript SDK
import { ClaudeCodeSDK } from '@anthropic-ai/claude-code';

const sdk = new ClaudeCodeSDK({
  apiKey: 'your-api-key'
});

const session = await sdk.createSession();
const response = await session.sendMessage("Fix the bug in auth.js");

Architecture

Claude Code is built around several key components:

  • CLI Interface: Interactive terminal-based chat interface with slash commands and natural language processing
  • Print Mode: Non-interactive mode for programmatic usage and automation
  • Hook System: Extensible event-driven hooks for validation, transformation, and control of tool executions
  • Custom Commands: User-defined markdown-based commands with tool permissions and agent capabilities
  • Configuration System: JSON-based configuration with project-level and global settings
  • SDK Integration: TypeScript and Python SDKs for programmatic access
  • MCP Integration: Model Context Protocol servers for extended tool capabilities
  • IDE Integration: Native VS Code extension and editor integration features
  • Authentication: API key management, OAuth, and subscription-based access

Capabilities

CLI Interface and Options

Interactive and non-interactive command-line interface with comprehensive options for different usage modes.

# Interactive mode
claude

# Print mode (non-interactive)
claude --print "prompt text"

# Configuration options
claude --settings settings.json
claude --mcp-config server1.json server2.json
claude --add-dir additional/directory

# Output formats
claude --output-format=stream-json
claude --system-prompt-file custom-prompt.txt

CLI Interface | CLI Options

Slash Commands

Built-in commands for specific actions and workflow management.

# File and project management
/add-dir path/to/directory     # Add directories to context
/memory                        # Edit memory files
/context                       # Debug context issues
/export                        # Export conversations
/resume                        # Switch conversations

# Development workflow
/bug "issue description"       # Report bugs
/cost                          # View usage and costs
/todos                         # List current todos
/pr-comments                   # Handle PR comments
/install-github-app           # Install GitHub integration

# Configuration and tools
/doctor                        # Validate configuration
/permissions                   # Manage tool permissions
/model                         # Model selection
/statusline                    # Customize status line
/vim                          # Enable vim bindings
/mcp                          # MCP server management
/agents                       # Create custom subagents

Slash Commands

Hook System

Event-driven extension system with multiple hook types for comprehensive customization.

// Hook types
{
  "hooks": {
    "SessionStart": [...],        // Session initialization
    "SessionEnd": [...],          // Session termination
    "PreToolUse": [...],          // Before tool execution
    "UserPromptSubmit": [...],    // User input processing
    "PreCompact": [...],          // Before conversation compaction
    "Stop": [...],                // Task completion
    "SubagentStop": [...]         // Subagent completion
  }
}

Hook System

Custom Commands and Agents

Markdown-based command definitions with agent capabilities for specialized workflows.

# Custom command with agent support
---
allowed-tools: Bash(git checkout --branch:*), Bash(git add:*), Bash(git status:*)
description: Brief description of the command
model: claude-3-sonnet-20240229
namespace: frontend
---

# Command instructions with dynamic context
## Context
- Current status: !`git status`
- Recent changes: !`git diff HEAD~1..HEAD`

## Your task
Step-by-step instructions for Claude to follow

Custom Commands

Configuration System

Comprehensive configuration management with project and global settings.

// Main configuration locations
~/.claude/settings.json         // Global settings
.claude/settings.json          // Project settings
CLAUDE.md                      // Project context
.mcp.json                      // MCP server config

// Environment variables
CLAUDE_CONFIG_DIR              // Override config directory
ANTHROPIC_DEFAULT_SONNET_MODEL // Control model selection
CLAUDE_CODE_AUTO_CONNECT_IDE   // IDE auto-connection

Configuration

SDK Integration

Programmatic access through TypeScript and Python SDKs.

// TypeScript SDK
interface ClaudeCodeSDK {
  createSession(options?: SessionOptions): Promise<Session>;
  canUseTool(toolName: string): boolean;
  onUserInput(callback: (input: string) => void): void;
  cancelRequest(requestId: string): void;
}

interface Session {
  sendMessage(message: string): Promise<Response>;
  addCustomTool(name: string, callback: ToolCallback): void;
  getPermissions(): ToolPermissions;
}

SDK Integration

MCP Integration

Model Context Protocol servers for extended capabilities.

// MCP server configuration
{
  "servers": {
    "filesystem": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "/path/to/allowed-dir"]
    },
    "git": {
      "command": "mcp-server-git",
      "args": ["--repository", "/path/to/repo"]
    }
  }
}

MCP Integration

IDE Integration

Native editor integration with VS Code extension.

// VS Code extension features
- Real-time diff display
- Diagnostics integration
- Image paste support
- WSL compatibility
- File watching and suggestions

IDE Integration

Authentication

Multiple authentication methods and subscription management.

# Authentication methods
- API keys (stored in system keychain)
- OAuth authentication
- Claude Pro/Max subscriptions
- Bedrock/Vertex AI integration

# Environment variables
ANTHROPIC_API_KEY              # Direct API key
AWS_BEARER_TOKEN_BEDROCK       # Bedrock authentication

Authentication

Types

// CLI and SDK Types
interface ClaudeCodeSDK {
  createSession(options?: SessionOptions): Promise<Session>;
  canUseTool(toolName: string): boolean;
  onUserInput(callback: (input: string) => void): void;
  cancelRequest(requestId: string): void;
}

interface Session {
  sendMessage(message: string): Promise<Response>;
  addCustomTool(name: string, callback: ToolCallback): void;
  getPermissions(): ToolPermissions;
}

interface SessionOptions {
  apiKey?: string;
  model?: string;
  workingDirectory?: string;
  permissions?: ToolPermissions;
}

// Hook System Types
interface HookConfiguration {
  hooks: {
    SessionStart?: HookTrigger[];
    SessionEnd?: HookTrigger[];
    PreToolUse?: HookTrigger[];
    UserPromptSubmit?: HookTrigger[];
    PreCompact?: HookTrigger[];
    Stop?: HookTrigger[];
    SubagentStop?: HookTrigger[];
  };
}

interface HookTrigger {
  matcher: string;
  hooks: HookAction[];
}

interface HookAction {
  type: "command";
  command: string;
  timeout?: number;
}

interface HookInput {
  tool_name: string;
  tool_input: Record<string, any>;
  environment?: Record<string, string>;
}

// Custom Command Types
interface CustomCommandFrontmatter {
  "allowed-tools": string[];
  description: string;
  model?: string;
  namespace?: string;
}

// MCP Types
interface MCPServerConfig {
  servers: Record<string, MCPServer>;
}

interface MCPServer {
  command: string;
  args: string[];
  env?: Record<string, string>;
}

// Configuration Types
interface Settings {
  hooks?: HookConfiguration;
  mcpServers?: MCPServerConfig;
  permissions?: ToolPermissions;
  model?: string;
  outputStyle?: string;
}

interface ToolPermissions {
  allowedTools: string[];
  blockedTools?: string[];
}