This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Friday is a Unix-philosophy AI Agent for the terminal. Text in, text out. Pipe-friendly.
Core features:
- Pipeline-first design — stdin/stdout for Unix pipe composition
- Multiple input modes — Arguments, stdin, or combine both with
-mflag - Local data — Everything stored in
~/.friday/ - Session management — Persistent conversations with history
- Multi-provider support — OpenAI, Anthropic, Ollama, Google Gemini
This repository contains two Go modules:
- Root module (
/) — CLI application, config, workspace, memory, skills, sandbox, MCP - Core module (
/core) — Agent interfaces, providers, session management, tools, planning
The core package is a separate module with its own go.mod. See core/CLAUDE.md for details.
make build # Build for darwin/arm64, darwin/amd64, linux/arm64, linux/amd64
make test # Run all unit tests (go test ./... and go test ./core/...)To run a single test:
go test -v -run TestName ./path/to/package- Binaries need to be placed in the bin directory; it is strongly recommended to use make for building.
- When executing commands, keep them simple and easy to audit. For example, if you need to execute
cmd1 && cmd2, please use the tool twice, executingcmd1andcmd2respectively.
Cobra CLI application with commands:
root.go- Root command with config loading and session manager initializationchat.go- Send messages via arguments or stdin pipeinit.go- Initialize workspace with default markdown filessession.go- Session management (list, new, use, show, archive, delete)heartbeat.go- Send periodic tasks defined in HEARTBEAT.md
The agents/ package defines the Agent interface (core/agents/interface.go:9-11):
type Agent interface {
Chat(ctx context.Context, req *api.Request) *api.Response
}react.go- ReAct-style agent with thought/action/observation loop (max 50 iterations)tools.go- Tool execution and JSON Schema handlingresearch/- Research agent with subagent delegationsummarize/- Specialized agent for response synthesis and conversation compaction
Session manages conversation state and tool execution context:
session.go- Core session with message history, token tracking, and workdir filesystemhooks.go- Hook system:BeforeAgent,BeforeModel,AfterModellifecycle hookscompact.go- Conversation compaction/shortening utilities
Sessions support forking for sub-agent execution (core/session/session.go:57-75).
Orchestrates expert sub-agents:
hook.go- RegistersBeforeAgentandBeforeModelhooks to inject subagent toolstool.go- Main agent toolrun_taskdelegates to registered expert agents
lats/- LATS reasoning tree with candidate generation, parallel execution, and evaluationtodo.go- TODO-based planning with hook integration
interface.go- Client interface withCompletion,CompletionNonStreaming,StructuredPredictopenai/client.go- OpenAI-compatible API client with streaming supportopenai/compatible.go- OpenAI-compatible providers (Ollama, Gemini)openai/embedding.go- Vector embedding generationanthropics/client.go- Anthropic Claude API client
tool.go- Tool definition with JSON Schema, handlers, and property buildersutils.go- Tool utility functions
requests.go- Request/Response types for agent chatstream.go- Streaming response utilitiescontext.go- HTTP context utilities
session.go- Message types with roles (system/user/assistant/agent/tool)event.go- Session hook type constants (BeforeAgent,BeforeModel,AfterModel)
interface.go- State interface for KV storage with app/user scopesinmemory.go- In-memory state implementation (default)
interface.go- Logger interfacedefault.go- Default implementationroot.go- Root logger setup
Workspace loads markdown files for agent context:
loader.go- Loads workspace files and memory logstypes.go- FileSpec, FileRole, and LoadedContent typesdefaults.go- Default content templates for initialization
Workspace files (loaded into system prompt):
SOUL.md- Persona and toneENVIRONMENT.md- Machine and execution environmentAGENTS.md- Behavior guidelinesIDENTITY.md- Agent name and styleTOOLS.md- Tool usage guidanceHEARTBEAT.md- Periodic checklistMEMORY.md- Long-term memory
Daily memory log system:
memory.go- Memory system for daily logsforgetting.go- Memory retention and cleanup
manager.go- Session manager for current session trackingstore.go- Session store interfacefile/store.go- File-based session persistence
config.go- Config loading (JSON or YAML), path resolution, env expansiontypes.go- Config structs (ModelConfig, MemoryConfig, SessionConfig, LogConfig)
Default paths:
~/.friday/
├── config.json # Configuration (or friday.yaml)
├── sessions/ # Conversation history
├── memory/ # Daily memory logs
├── log/ # Application logs
└── workspace/ # Agent context files
LLM clients implement Client interface with:
Completion(ctx, Request) Response- Streaming chat completionCompletionNonStreaming(ctx, Request) (string, error)StructuredPredict(ctx, Request, model any) error- Structured output
The setup package provides agent initialization:
NewAgent- Creates AgentContext with all componentsAgentContext- Holds Client, Workspace, Session, Agent, MemoryChatmethod - Sends message to agentPrintResponse- Streams response to stdout- Options:
WithSessionID,WithIsolate,WithTemporary,WithVerbose
Setup flow:
- Create provider client from config
- Initialize workspace directory
- Get or create session (from session manager)
- Register compact hook for conversation summarization
- Load workspace content (system prompts + memory history)
- Create agent with system prompt and tools
- Ensure memory log exists for today
Skills are markdown-based extensions with YAML frontmatter:
skill.go— Skill struct with Frontmatter (name, description, allowed_tools)loader.go— Loads SKILL.md files from directoriesregistry.go— Skill registration and discoveryhook.go— Injects skill instructions into session context
OS-level sandboxing for secure command execution:
sandbox.go— Sandbox interface (WrapCommand, IsAvailable, Name)seatbelt.go— macOS sandbox using Seatbelt frameworkbwrap.go— Linux sandbox using bubblewrapexecutor.go— Command execution with sandbox integrationpermission.go— Permission definitions (filesystem, network)
Model Context Protocol integration:
server.go— Connects to MCP SSE endpoints and converts MCP tools to internal Tool format
CLI for managing skills: list, install, update installed skills.
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
Touch only what you must. Clean up only your own mess.
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.