hawk

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 6 Imported by: 0

README

🦅 hawk

AI coding agent that reads, writes, and runs code in your terminal.

Built on eyrie (universal LLM provider), tok (tokenizer/compression), yaad (graph memory), and trace (session capture).

Install

# Homebrew (macOS/Linux)
brew install GrayCodeAI/tap/hawk

# Go
go install github.com/GrayCodeAI/hawk@latest

# Script (with checksum verification)
curl -fsSL https://raw.githubusercontent.com/GrayCodeAI/hawk/main/install.sh | sh

# From source
git clone https://github.com/GrayCodeAI/hawk && cd hawk && go install .

Quick Start

export ANTHROPIC_API_KEY=sk-ant-...
hawk

Model Agnostic

Hawk is fully model-agnostic. Model discovery, pricing, and routing are handled by eyrie. Hawk stores only provider, model, and API-key configuration.

# One-time setup
hawk config provider openai
hawk config key openai sk-...
hawk config model gpt-4o

# Per-run override
hawk --provider openai --model gpt-4o

# Non-interactive
hawk -p "summarize this repo" --provider anthropic --model claude-sonnet-4-20250514

In chat: /config provider <name>, /config key <provider> <api-key>, /model <name>.

Usage

hawk                          # Interactive REPL
hawk -p "explain this code"   # Print response and exit
hawk -m gpt-4o                # Specify model
hawk --provider openai        # Force provider
hawk -r abc123                # Resume session
hawk -c                       # Continue latest session
hawk --fork-session -r abc123 # Resume as new session
hawk --mcp "npx @mcp/server"  # Connect MCP server
hawk -p "fix tests" --allowed-tools "Bash(go test:*) Edit Read"
hawk -p "plan only" --permission-mode plan --tools "Read,Grep,Glob"
hawk exec "fix all tests"     # Non-interactive with full engine
hawk exec --auto full -o json "add error handling"
hawk exec --worktree "refactor auth module"
hawk exec --agent reviewer "review last commit"
hawk daemon start             # Background HTTP server
hawk daemon status            # Check if daemon running
hawk mission "add auth, rate limiting, and tests"
hawk mission --dry-run "decompose this into features"
hawk search "authentication"  # Search across all sessions
hawk agent list               # List custom personas
hawk agent create debugger    # Create new persona
hawk doctor                   # Run diagnostics
hawk config                   # Show effective settings
hawk sessions                 # List saved sessions
hawk tools                    # List built-in tools
hawk skills search api        # Search community skills
hawk skills install GrayCodeAI/hawk-skills go-review
hawk skills audit             # Security scan installed skills
hawk --auto-skill             # Auto-detect project, install matching skills

Skills

Hawk has a community skill registry — modular instruction packages that teach the agent specialized workflows.

# In the REPL
/skills                          # List installed skills
/skills search <query>           # Search community registry
/skills trending                 # Most popular skills
/skills install <owner/repo>     # Install from GitHub
/skills use <name>               # Activate for this session
/skills deactivate <name>        # Deactivate
/skills new <description>        # Create a new skill (LLM wizard)
/skills info <name>              # Show details
/skills remove <name>            # Uninstall
/skills feedback <name> <1-5>    # Rate a skill
/skills audit                    # Security scan for hidden Unicode threats
/skills publish <dir>            # Validate and publish

/learn                           # LLM-powered skill advisor
/learn deep                      # Advisor with source file analysis
/learn update                    # Re-analyze and flag outdated skills

# Non-interactive (CI/scripts)
hawk skills list
hawk skills search api --category engineering --json
hawk skills install GrayCodeAI/hawk-skills go-review --scope user
hawk skills audit --json
hawk --auto-skill

Skills are discovered from .hawk/skills/, .agents/skills/ (agentskills.io), ~/.hawk/skills/, and Claude/Codex directories for cross-agent compatibility. Install includes automatic security scanning — skills with dangerous hidden Unicode are sanitized on install.

Tools (40)

Tool Description
Bash Run shell commands
Read Read files with line ranges
Write Create/overwrite files
Edit String replacement editing
LS Directory listing
Glob File pattern matching
Grep Regex search in files
WebFetch Fetch URLs, HTML→text
WebSearch DuckDuckGo search
ToolSearch Search available tools
Skill Load local skill instructions
Agent Spawn sub-agents for parallel tasks
AskUserQuestion Ask clarifying questions
TodoWrite Task list management
TaskCreate/Get/List/Update Persistent task CRUD
TaskOutput Read background task output
TaskStop Stop a background task
LSP Code diagnostics (go vet, tsc, etc.)
EnterPlanMode / ExitPlanMode Plan mode control
EnterWorktree / ExitWorktree Git worktree isolation
NotebookEdit Edit Jupyter notebook cells
ListMcpResources / ReadMcpResource MCP resource access
Config Read/modify hawk config
SendUserMessage Send brief status update
Sleep Pause execution
CronCreate/Delete/List Scheduled task management
VerifyPlanExecution Verify plan completion
Workflow Execute scripted workflows
McpAuth MCP authentication
Diagnostics System diagnostics
CodeSearch Semantic code search via yaad
PowerShell PowerShell commands (cross-platform)

Plus any tools from connected MCP servers.

Slash Commands (91)

Core commands:

Command Description
/help Show commands
/model Show or switch model
/config Open config panel
/env Show provider environment
/cost Token usage and cost
/diff Show git diff (preview before commit)
/commit Auto-commit with AI message
/undo Restore last file change from backup
/focus <path> Narrow agent to specific files/dirs
/pin [n] Protect last N messages from compaction
/compact Compact context
/clear Clear display
/branch Show git branch/status
/files Show modified files
/review Ask hawk to review changes
/test Run project tests
/lint Run linter
/think <topic> Plan before coding (Waza method)
/hunt <symptom> Root-cause diagnosis before fixing (Waza method)
/check Pre-ship review with auto-fix (Waza method)
/design <goal> Screenshot-driven UI iteration (Waza method)
/bughunter Hunt for bugs
/security-review Review security risks
/power <level> Set power level (1-10)
/vibe Enter vibe coding mode
/research <cmd> Autonomous optimization loop
/tools List enabled tools
/skills List local skills
/memory Show loaded project instructions
/history List sessions
/resume <id> Resume session
/doctor Run diagnostics
/init Analyze project
/vim Toggle vim keybindings
/permissions Manage tool permissions

Run /help for the full list of 91 commands.

Providers

Hawk passes configured provider/model values to eyrie. API keys via hawk config key <provider> <api-key> or environment variables:

Provider Env Variable
Anthropic ANTHROPIC_API_KEY
OpenAI OPENAI_API_KEY
Gemini GEMINI_API_KEY
OpenRouter OPENROUTER_API_KEY
Grok XAI_API_KEY
Groq GROQ_API_KEY
DeepSeek DEEPSEEK_API_KEY
Mistral MISTRAL_API_KEY
Bedrock AWS_ACCESS_KEY_ID
Vertex GOOGLE_APPLICATION_CREDENTIALS
Ollama OLLAMA_BASE_URL

Architecture

Layer Technology
CLI cobra
TUI Bubbletea + lipgloss
LLM eyrie — model-agnostic provider
Tokenizer tok — BPE counting + context compression
Memory yaad — graph-based persistent memory
Session capture trace — git-native session recording
MCP JSON-RPC over stdio
Hooks Event-driven plugin system
Plugins Manifest-based external commands
LSP JSON-RPC language server client
Sandbox Namespace/docker/chroot/seatbelt/landlock/seccomp isolation
Package Structure
cmd/          CLI commands and TUI (split: chat, commands, config, view, stream, print, welcome)
engine/       Agent loop, compaction, beliefs, backtracking, cascade router, context budget,
              reflection, self-review, session lifecycle (self-improvement loop)
tool/         40 built-in tools with safety layer (credentials, sensitive paths, backups)
config/       Settings loading, validation, budget, aliases, templates
session/      Session persistence (JSONL), WAL, snapshots, checkpoints, compression
prompt/       System prompt preamble (identity, safety)
prompts/      Modular prompt templates (role, tools, practices, communication, examples)
repomap/      Code intelligence (PageRank, BM25, TF-IDF, Shapley, import graph, change-set context)
memory/       Unified MemoryManager (auto, evolving, zenbrain, yaad bridge)
model/        Provider routing, health checking, roles (delegates catalog to eyrie)
mcp/          MCP client with buffered I/O and timeout
lsp/          LSP client with persistent reader
plugin/       Plugin runtime and smart skill auto-invocation
permissions/  Advanced permission system (auto-mode, classifier, killswitch)
hooks/        Event hook system with decision hooks
analytics/    Session traces, activity tracking, cost optimization, model cascade
trace/        Built-in tracer + optional OTel SDK (build tag)
sandbox/      Command isolation (namespace, docker, chroot, seatbelt, landlock, seccomp)
mission/      Multi-agent orchestration (parallel feature execution in worktrees)
daemon/       Background HTTP server (JSON + SSE streaming)
agents/       Custom agent persona loader (markdown + frontmatter)
parallel/     Worktree-based parallel task execution
retry/        Exponential backoff with jitter
circuit/      Circuit breaker (closed/open/half-open)
ratelimit/    Token bucket rate limiting

Zero CGO. Single static binary. Cross-compiled for linux/darwin/windows amd64/arm64.

Exec Mode

Run hawk non-interactively for scripting and CI:

hawk exec "fix all failing tests"
hawk exec --auto full "refactor to use context"
hawk exec --output-format json "list all TODO comments"
hawk exec --worktree "add rate limiting"           # isolated branch
hawk exec --agent reviewer "review the last 3 commits"
hawk exec -s exec-123456 "continue from last time" # resume session
echo "explain main.go" | hawk exec -               # stdin

Mission Mode

Decompose work into parallel features:

hawk mission "Add auth, rate limiting, and logging"
hawk mission --workers 6 --model claude-sonnet-4-6 "Refactor into microservices"
hawk mission --dry-run "What would this decompose into?"

Each feature runs in its own git worktree with full autonomy. Results are committed on separate branches.

Daemon

Background HTTP server for programmatic access:

hawk daemon start              # Start on port 4590
hawk daemon start --port 8080  # Custom port
hawk daemon status             # Check if running
hawk daemon stop               # Graceful shutdown

Endpoints:

  • GET /v1/health — server status
  • POST /v1/chat — send prompt, get response (JSON or SSE streaming)
  • GET /v1/sessions — list active sessions

SSE streaming: set Accept: text/event-stream header.

Custom Agents

Define reusable personas in ~/.hawk/agents/:

hawk agent create reviewer -d "Security-focused code reviewer"
hawk agent list
hawk agent show reviewer
hawk exec --agent reviewer "check the auth module"

Agent files are markdown with YAML frontmatter:

---
name: reviewer
description: Security-focused code reviewer
model: claude-sonnet-4-6
---
You are a security expert. Focus on injection, auth bypass, and secrets.

AGENTS.md

Create an AGENTS.md in your project root for project-specific instructions (max 10KB). Any AI coding agent can read this — hawk, Claude Code, Cursor, Codex:

# My Project
- Go project using chi router
- Tests use testify
- Run tests: go test ./...

Hawk also reads AGENTS.md for backward compatibility.

Permission System

Hawk asks before running dangerous tools (Bash, Write, Edit, NotebookEdit):

⚠ Run: go test ./...  [y/n]

Features:

  • Auto-mode: Learns from your decisions
  • Command classifier: Safe/unsafe/unknown classification
  • Bypass killswitch: Emergency disable for auto-mode
  • Shadowed rule detection: Warns when rules conflict
hawk -p "review this repo" --permission-mode acceptEdits
hawk -p "fix lint" --allowed-tools "Bash(go test:*) Edit Read"
hawk -p "plan only" --permission-mode plan

MCP (Model Context Protocol)

hawk --mcp "npx @modelcontextprotocol/server-filesystem ."
hawk --mcp "npx @modelcontextprotocol/server-github"

License

MIT — GrayCode AI

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package api provides an HTTP API server for hawk, consumable by SDKs.
Package api provides an HTTP API server for hawk, consumable by SDKs.
Package circuit provides a circuit breaker pattern for resilience.
Package circuit provides a circuit breaker pattern for resilience.
cmd
compat-test command
compat-test reads compatibility-matrix.json and runs basic compatibility checks across the listed components.
compat-test reads compatibility-matrix.json and runs basic compatibility checks across the listed components.
Package cmdhistory implements a structured command history store using SQLite.
Package cmdhistory implements a structured command history store using SQLite.
Package validator provides config validation utilities.
Package validator provides config validation utilities.
Package container provides Docker container lifecycle management for hawk's sandboxed execution environments.
Package container provides Docker container lifecycle management for hawk's sandboxed execution environments.
Package daemon provides a Telegram gateway for hawk.
Package daemon provides a Telegram gateway for hawk.
agent
Package agent is the Stage-1 namespace for sub-agent orchestration types.
Package agent is the Stage-1 namespace for sub-agent orchestration types.
branching
Package branching is the Stage-1 namespace for branching strategies, cascade, council, shadow, snowball.
Package branching is the Stage-1 namespace for branching strategies, cascade, council, shadow, snowball.
code
Package code is the Stage-1 namespace for code-aware features (context extraction, lenses, actions, explainer).
Package code is the Stage-1 namespace for code-aware features (context extraction, lenses, actions, explainer).
compact
Package compact is the Stage-1 namespace for the engine package's compaction-related types and functions.
Package compact is the Stage-1 namespace for the engine package's compaction-related types and functions.
control
Package control is the Stage-1 namespace for engine control-flow safety types — loop detection, stall detection, backtracking.
Package control is the Stage-1 namespace for engine control-flow safety types — loop detection, stall detection, backtracking.
cost
Package cost is the Stage-1 namespace for cost-tracking types and functions in package engine.
Package cost is the Stage-1 namespace for cost-tracking types and functions in package engine.
ctxmgr
Package ctxmgr is the Stage-1 namespace for context budget, decay, packing, providers, visualisation, and read-only context.
Package ctxmgr is the Stage-1 namespace for context budget, decay, packing, providers, visualisation, and read-only context.
diff
Package diff is the Stage-1 namespace for diff sandbox, staging, preview, summariser, test selector, and 3-way merge.
Package diff is the Stage-1 namespace for diff sandbox, staging, preview, summariser, test selector, and 3-way merge.
docs
Package docs is the Stage-1 namespace for documentation generation, external docs fetching, and doc updating.
Package docs is the Stage-1 namespace for documentation generation, external docs fetching, and doc updating.
errs
Package errs is the Stage-1 namespace for error context enrichment, grouping, learning, patterns, and recovery.
Package errs is the Stage-1 namespace for error context enrichment, grouping, learning, patterns, and recovery.
git
Package git is the Stage-1 namespace for git-related types and functions in package engine.
Package git is the Stage-1 namespace for git-related types and functions in package engine.
history
Package history is the Stage-1 namespace for command history, conversation summarisation, distillation, head/tail, annotations.
Package history is the Stage-1 namespace for command history, conversation summarisation, distillation, head/tail, annotations.
intelligence
Package intelligence is the Stage-1 namespace for intent classification, capabilities, language support, tool selection.
Package intelligence is the Stage-1 namespace for intent classification, capabilities, language support, tool selection.
io
Package io is the Stage-1 namespace for clipboard, AI watcher, file watcher, and cron scheduler types.
Package io is the Stage-1 namespace for clipboard, AI watcher, file watcher, and cron scheduler types.
lifecycle
Package lifecycle is the Stage-1 namespace for session lifecycle, limits, timeouts, and sleep-time operations.
Package lifecycle is the Stage-1 namespace for session lifecycle, limits, timeouts, and sleep-time operations.
memory
Package memory is the Stage-1 namespace for knowledge, experience, and memory consolidation types.
Package memory is the Stage-1 namespace for knowledge, experience, and memory consolidation types.
observability
Package observability is the Stage-1 namespace for profiling, debug recording, structured logging, feedback.
Package observability is the Stage-1 namespace for profiling, debug recording, structured logging, feedback.
planning
Package planning is the Stage-1 namespace for task planning, decomposition, goals, and suggested tasks.
Package planning is the Stage-1 namespace for task planning, decomposition, goals, and suggested tasks.
project
Package project is the Stage-1 namespace for project analysis, snapshots, impact analysis, dep updates, migrations, releases.
Package project is the Stage-1 namespace for project analysis, snapshots, impact analysis, dep updates, migrations, releases.
prompt
Package prompt is the Stage-1 namespace for prompt-construction and prompt-optimisation types in package engine.
Package prompt is the Stage-1 namespace for prompt-construction and prompt-optimisation types in package engine.
retry
Package retry is the Stage-1 namespace for retry-queue types in package engine.
Package retry is the Stage-1 namespace for retry-queue types in package engine.
review
Package review is the Stage-1 namespace for self-review / critique / quality scoring types in package engine.
Package review is the Stage-1 namespace for self-review / critique / quality scoring types in package engine.
safety
Package safety is the Stage-1 namespace for hallucination guard, output redaction, permissions, risk assessment.
Package safety is the Stage-1 namespace for hallucination guard, output redaction, permissions, risk assessment.
scaffold
Package scaffold is the Stage-1 namespace for scaffolding, recipes, patterns, skills, and few-shot types.
Package scaffold is the Stage-1 namespace for scaffolding, recipes, patterns, skills, and few-shot types.
search
Package search is the Stage-1 namespace for URL scraping, issue search, and research agent types.
Package search is the Stage-1 namespace for URL scraping, issue search, and research agent types.
session
Package session is the Stage-1 namespace for session-lifecycle types in package engine.
Package session is the Stage-1 namespace for session-lifecycle types in package engine.
streaming
Package streaming is the Stage-1 namespace for response caching, formatting, stream optimisation, thinking protocol, and steering.
Package streaming is the Stage-1 namespace for response caching, formatting, stream optimisation, thinking protocol, and steering.
token
Package token is the Stage-1 namespace for token-related types and functions in package engine.
Package token is the Stage-1 namespace for token-related types and functions in package engine.
validation
Package validation is the Stage-1 namespace for generated-code validation, schema validation, test loops, and lint loops.
Package validation is the Stage-1 namespace for generated-code validation, schema validation, test loops, and lint loops.
workflow
Package workflow is the Stage-1 namespace for workflow + workspace + trajectory types in package engine.
Package workflow is the Stage-1 namespace for workflow + workspace + trajectory types in package engine.
Package health provides health check and readiness probe support.
Package health provides health check and readiness probe support.
Package ide provides IDE integration hints and metadata.
Package ide provides IDE integration hints and metadata.
internal
Package localize implements hierarchical fault localization inspired by OpenAutoCoder/Agentless.
Package localize implements hierarchical fault localization inspired by OpenAutoCoder/Agentless.
Package logger provides structured logging with levels.
Package logger provides structured logging with levels.
Package mention implements @-prefixed file mentions in prompt input, enabling users to reference project files that get auto-included as context.
Package mention implements @-prefixed file mentions in prompt input, enabling users to reference project files that get auto-included as context.
Package metrics provides basic metrics collection (counters, timers, gauges).
Package metrics provides basic metrics collection (counters, timers, gauges).
Package planner implements structured planning that generates artifacts before coding begins.
Package planner implements structured planning that generates artifacts before coding begins.
Package profile provides runtime profiling helpers.
Package profile provides runtime profiling helpers.
Package prompt provides the system prompt for hawk.
Package prompt provides the system prompt for hawk.
Package ratelimit provides token bucket rate limiting.
Package ratelimit provides token bucket rate limiting.
Package recipe also provides declarative provider configuration.
Package recipe also provides declarative provider configuration.
Package repomap generates a lightweight code structure map of a repository by scanning files and extracting top-level symbols using regex-based parsers.
Package repomap generates a lightweight code structure map of a repository by scanning files and extracting top-level symbols using regex-based parsers.
Package retry provides configurable retry logic with exponential backoff.
Package retry provides configurable retry logic with exponential backoff.
Package model provides model routing and health checking.
Package model provides model routing and health checking.
Package rules provides import/export of AI coding rules between different tool formats (hawk, Cursor, Claude Code, Copilot, Gemini).
Package rules provides import/export of AI coding rules between different tool formats (hawk, Cursor, Claude Code, Copilot, Gemini).
Package sandbox provides sandbox mode for isolated command execution.
Package sandbox provides sandbox mode for isolated command execution.
sarif module
Package sessioncapture provides terminal context capture with delta-based tracking.
Package sessioncapture provides terminal context capture with delta-based tracking.
Package shellmode implements the ! prefix for direct shell command execution in the REPL input, bypassing the LLM entirely.
Package shellmode implements the ! prefix for direct shell command execution in the REPL input, bypassing the LLM entirely.
Package shutdown provides graceful shutdown handling for applications.
Package shutdown provides graceful shutdown handling for applications.
Package staleness detects rules/skills that are no longer actively used or that contradict observed user behavior.
Package staleness detects rules/skills that are no longer actively used or that contradict observed user behavior.
Package taste implements a learning system that observes user coding preferences and builds a style profile over time to improve agent output alignment.
Package taste implements a learning system that observes user coding preferences and builds a style profile over time to improve agent output alignment.
Package trace provides Langfuse tracing integration for LLM observability.
Package trace provides Langfuse tracing integration for LLM observability.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL