Guidance for agents working in this repository.
RubyLLM Code is a small coding agent for the terminal, built on RubyLLM 2.0. Its
one distinctive feature is /collab <model>: two models work the same task,
explore the workspace in parallel, argue until they agree, and only then does the
coder touch the files.
bundle install
./bin/rubyllm # run it
bundle exec rspec # tests, no network needed
bundle exec rubocop # lint
bundle exec rake # bothRubyLLM 2.0 is unreleased, so the Gemfile tracks its trunk.
lib/ruby_llm/code/cli.rb— flags, then either one question or the REPLlib/ruby_llm/code/session.rb— one sitting: turns, streaming, approvalslib/ruby_llm/code/collab.rb— the two-model workflowlib/ruby_llm/code/coder.rb,peer.rb— the twoRubyLLM::Agentsubclasseslib/ruby_llm/code/tools/—read list glob grepandwrite edit shelllib/ruby_llm/code/prompts/— every word the agents are told, as ERBlib/ruby_llm/code/ui.rb— Lipgloss frames, Glamour markdown, one write mutex
- Lean on RubyLLM. The agentic loop (
ask_later,complete,step), tool approval (requires_approval,approve!,deny!), the usage ledger (chat.tokens,chat.cost), prompt templates, andRubyLLM.workfloware all already there. Do not reimplement them here. - Prompts are files. Behaviour changes belong in
prompts/*.txt.erb, not in Ruby heredocs. A project's ownapp/promptsoverrides them. - Tools stay small. One job each,
{ error: "..." }for anything the model should read and correct,raise ToolErrorfor a refusal. Anything that changes the workspace declaresrequires_approvaland apreview. - Every path goes through
Workspace#resolve, which refuses to leave the workspace. - All output goes through
UI. Nothing else prints; a spinner runs in its own thread and the mutex inUI#writeis what keeps lines intact. - Plain Ruby, small methods, no ceremony. Comments explain why, not what.
Specs never hit the network. Stub RubyLLM::Code::Peer.new to script a
collaboration, and stub the coder's loop verbs to script a turn. spec_helper.rb
gives every example a throwaway sandbox workspace and a ui writing to a
screen you can read back.