Skip to content

xiaoquisme/my-coding-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Coding Agent

A minimal, interactive CLI coding agent powered by Anthropic's Claude API. It can read, write, edit, and glob files — and run bash commands — all within your project directory.

Prerequisites

  • Python 3.14+
  • An Anthropic API key (or a compatible proxy)

Setup

cd my-coding-agent
uv sync
cp .env.example .env  # then edit .env with your API key

Your .env file should contain:

ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_API_URL=https://api.anthropic.com
ANTHROPIC_MODEL=claude-sonnet-4-20250514
Variable Required Default
ANTHROPIC_API_KEY Yes
ANTHROPIC_API_URL No https://api.anthropic.com
ANTHROPIC_MODEL No claude-sonnet-4-20250514

Usage

uv run python -m src.entry
  • Type your question across multiple lines, press Enter twice (empty line) to send.
  • Type q, exit, or press Ctrl+C to quit.
  • Type /clear context to reset conversation history.

Available Tools

Tool Description
bash Execute a shell command (dangerous commands blocked)
read_file Read a file with optional start/limit
write_file Create or overwrite a file
edit_file Find-and-replace inside a file
glob Find files by pattern (supports **)

All file operations are sandboxed to the current working directory.

Features

  • Hook system — extensible lifecycle hooks (UserPromptSubmit, PreToolUse, PostToolUse, Stop) in src/hooks/hooks.py
  • Permission gate — dangerous bash commands and out-of-workspace writes are blocked via src/gate/permission_check.py
  • Thinking display — Claude's chain-of-thought reasoning is shown inline as 🧠(Thinking): ...
  • Context clearing — type /clear context to reset conversation history

Built-in Hooks

Hook Point Behavior
UserPromptSubmit Logs the working directory for context
PreToolUse Logs each tool invocation with arguments
PostToolUse Warns if a tool output exceeds 100,000 characters
Stop Prints a summary of total tool calls for the session

To add custom hooks, use register_hook(hook_name, callback) in hooks/hooks.py.

Project Structure

my-coding-agent/
├── pyproject.toml
├── uv.lock
├── .env.example
├── .env
└── src/
    ├── __init__.py
    ├── entry.py
    ├── config.py
    ├── tools.py
    ├── hooks/
    │   └── hooks.py
    └── gate/
        └── permission_check.py

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages