|
| 1 | +# Agent Instructions |
| 2 | + |
| 3 | +## Development Environment |
| 4 | +This project uses [devenv](https://devenv.sh/) for reproducible development environments with Nix. |
| 5 | + |
| 6 | +## Commands |
| 7 | +- `devenv shell` - Enter the development shell |
| 8 | +- `devenv test` - Run tests (currently runs git version check) |
| 9 | +- `go build` - Build Go project |
| 10 | +- `go run main.go` - Run the chat application |
| 11 | +- `go test ./...` - Run all Go tests |
| 12 | +- `go test <package>` - Run tests for specific package |
| 13 | +- `go mod tidy` - Download dependencies |
| 14 | +- `hello` - Custom script that greets from the development environment |
| 15 | + |
| 16 | +### Application Commands |
| 17 | +- `go run chat.go` - Simple chat interface with Claude |
| 18 | +- `go run read.go` - Chat with file reading capabilities |
| 19 | +- `go run list_files.go` - Chat with file listing and reading capabilities |
| 20 | +- `go run bash_tool.go` - Chat with file operations and bash command execution |
| 21 | +- `go run edit_tool.go` - Chat with full file operations (read, list, edit, bash) |
| 22 | + |
| 23 | +### Verbose Logging |
| 24 | +All Go applications support a `--verbose` flag for detailed execution logging: |
| 25 | +- `go run chat.go --verbose` - Enable verbose logging for debugging |
| 26 | +- `go run read.go --verbose` - See detailed tool execution and API calls |
| 27 | +- `go run edit_tool.go --verbose` - Debug file operations and tool usage |
| 28 | + |
| 29 | +## Architecture |
| 30 | +- **Environment**: Nix-based development environment using devenv |
| 31 | +- **Shell**: Includes Git, Go toolchain, and custom greeting script |
| 32 | +- **Structure**: Chat application with terminal interface to Claude via Anthropic API |
| 33 | + |
| 34 | +## Code Style Guidelines |
| 35 | +- Follow Nix conventions for devenv.nix configuration |
| 36 | +- Use standard Git workflows |
| 37 | +- Development environment configuration should be reproducible |
| 38 | + |
| 39 | +## Troubleshooting |
| 40 | + |
| 41 | +### Verbose Logging |
| 42 | +When debugging issues with the chat applications, use the `--verbose` flag to get detailed execution logs: |
| 43 | + |
| 44 | +```bash |
| 45 | +go run edit_tool.go --verbose |
| 46 | +``` |
| 47 | + |
| 48 | +**What verbose logging shows:** |
| 49 | +- API calls to Claude (model, timing, success/failure) |
| 50 | +- Tool execution details (which tools are called, input parameters, results) |
| 51 | +- File operations (reading, writing, listing files with sizes/counts) |
| 52 | +- Bash command execution (commands run, output, errors) |
| 53 | +- Conversation flow (message processing, content blocks) |
| 54 | +- Error details with stack traces |
| 55 | + |
| 56 | +**Log output locations:** |
| 57 | +- **Verbose mode**: Detailed logs go to stderr with timestamps and file locations |
| 58 | +- **Normal mode**: Only essential output goes to stdout |
| 59 | + |
| 60 | +**Common troubleshooting scenarios:** |
| 61 | +- **API failures**: Check verbose logs for authentication errors or rate limits |
| 62 | +- **Tool failures**: See exactly which tool failed and why (file not found, permission errors) |
| 63 | +- **Unexpected responses**: View full conversation flow and Claude's reasoning |
| 64 | +- **Performance issues**: See API call timing and response sizes |
| 65 | + |
| 66 | +### Environment Issues |
| 67 | +- Ensure `ANTHROPIC_API_KEY` environment variable is set |
| 68 | +- Run `devenv shell` to ensure proper development environment |
| 69 | +- Use `go mod tidy` to ensure dependencies are installed |
| 70 | + |
| 71 | +## Notes |
| 72 | +- Requires ANTHROPIC_API_KEY environment variable to be set |
| 73 | +- Chat application provides a simple terminal interface to Claude |
| 74 | +- Use ctrl-c to quit the chat session |
0 commit comments