This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the A2A (Agent2Agent) Ruby gem - an implementation of the Agent2Agent protocol enabling communication and interoperability between opaque agentic applications. The gem provides typed data structures, serialization/deserialization, and validation according to the A2A specification.
bundle exec rake spec- Run RSpec testsbundle exec rake coverage- Run tests with coverage report (opens browser)bundle exec rake qa- Run full quality assurance suite (tests, linting, docs, security audit)bundle exec rspec spec/path/to/specific_spec.rb- Run a single test filebundle exec rspec spec/path/to/specific_spec.rb:42- Run specific test by line number
bundle exec rake rubocop- Run RuboCop lintingbundle exec rake rubocop:autocorrect- Auto-fix safe RuboCop offensesbundle exec rake rubocop:autocorrect_all- Auto-fix all RuboCop offenses (including unsafe)
bundle exec rake yard- Generate YARD documentationbundle exec rake yard:junk- Check for documentation issuesbundle exec rake verify_measurements- Ensure 100% documentation coverage (yardstick)
bundle exec typeprof lib/a2a.rb- Generate RBS type signaturesbundle exec steep check- Run Steep type checking
bundle exec rake bundle:audit:check- Check for security vulnerabilitiesbundle exec rake bundle:audit:update- Update security vulnerability database
bundle exec rake build- Build gembundle exec rake install- Install gem locallybin/console- Open interactive console with gem loaded
The gem is organized around the A2A protocol specification with the following key components:
-
Type System (
lib/a2a/types/): Complete typed implementation of A2A protocol data structures- Agent discovery objects (AgentCard, AgentSkill, AgentCapabilities)
- Message and task objects (Message, Task, TaskStatus, Artifact)
- Security schemes and authentication structures
- JSON-RPC request/response objects
- Implements the type system defined in
.agent-docs/types.ts(TypeScript reference definitions) - Type mapping between TypeScript types/interfaces and Ruby classes documented in
.agent-docs/types_mapping.md
-
Extensions System (
lib/a2a/extensions/):AdditionalProperties: Allows flexible schema with additional properties beyond defined attributesJSONDeserialization: Handles case transformation (snake_case ↔ camelCase) during instantiation
- Case Transformation: The gem handles automatic conversion between Ruby's snake_case conventions and the protocol's camelCase requirements during serialization/deserialization.
- Typed Data Structures: All protocol objects are implemented as Ruby classes with proper validation and type checking support via RBS signatures.
- JSON-RPC Integration: Built on the
jsonrpc-middlewaregem for proper JSON-RPC 2.0 protocol compliance. - Factory Pattern: Test factories are provided for all major objects to support testing.
lib/a2a.rb- Main entry point with Zeitwerk loader configurationlib/a2a/types/- All protocol data structure implementations (collapsed namespace)lib/a2a/extensions/- Mixin modules for additional functionalityspec/- RSpec test suite with comprehensive coveragesig/a2a.rbs- RBS type signatures for type checking
- Follow RuboCop configuration in
.rubocop.yml - Target Ruby 3.4 compatibility
- Use single quotes for strings, double quotes in interpolation
- Max line length: 120 characters
- Frozen string literals required
- Use RSpec for all tests
- FactoryBot factories for test data
- Match JSON matchers for JSON comparison
- Aim for comprehensive test coverage
- Tests are organized to mirror the lib structure
- 100% documentation coverage enforced by yardstick
- RuboCop compliance required
- Security audit checks via bundler-audit
- Type checking available via Steep
- Overcommit hooks enforce RuboCop and trailing whitespace checks on pre-commit
- Follow conventional commit message format based on existing history