autobot-test
Skill47 starsChanged 8 months agoMITView on GitHub
Testing guidelines for Autobot with AAA pattern and Crystal spec best practices
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- docs/llms.txtllms.txt
- autobot-providerSkill
- autobot-releaseSkill
- autobot-toolSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 104
Always test error paths:
- Very specific: line 132
Avoid not_nil! in tests. Use safe nil handling instead:
- Distinctive: line 172
Test security constraints explicitly:
- Distinctive: line 188
Keep tests fast (< 1s per test ideally)
- Very specific: line 189
Use before_each/after_each for setup/teardown
- Distinctive: line 190
Avoid real network calls (mock HTTP)
- Distinctive: line 191
Avoid real file system operations when possible
- Distinctive: line 205
Use this skill when:
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing Standards
AAA Pattern
Structure all tests with Arrange-Act-Assert and require the spec helper:
require "../spec_helper"
describe "MyFeature" do
it "does something expected" do
# Arrange
tool = Autobot::Tools::MyTool.new
params = {"key" => JSON::Any.new("value")}
# Act
result = tool.execute(params)
# Assert
result.success?.should be_true
result.content.should contain("expected")
end
endTest File Organization
Mirror source structure:
spec/
├── autobot/
│ ├── providers/
│ │ ├── http_provider_spec.cr
│ │ └── registry_spec.cr
│ ├── tools/
│ │ ├── web_spec.cr
│ │ └── exec_spec.cr
│ └── config/
│ └── schema_spec.cr
├── spec_helper.cr
└── security_spec.crRunning Tests
# Run all tests
crystal spec
# Run specific file
crystal spec spec/autobot/tools/web_spec.cr
# Run specific test by line number
crystal spec spec/autobot/tools/web_spec.cr:42
# Run with verbose output
crystal spec -v
# Run with color (default)
crystal spec --colorMocking External Services
HTTP Provider Mocking:
class MockHttpProvider < Autobot::Providers::HttpProvider
property responses = [] of HTTP::Client::Response
property call_count = 0
def post(path : String, body : Hash) : HTTP::Client::Response
@call_count += 1
responses.shift? || HTTP::Client::Response.new(500, body: "{}").tap { |r| r.consume_body_io }
end
endTool Execution Mocking:
# Use dependency injection or monkey-patch for tests
class TestableExecTool < Autobot::Tools::ExecTool
property captured_commands = [] of String
def execute_system_command(cmd)
@captured_commands << cmd
{output: "mock output", exit_code: 0}
end
endTesting Error Conditions
Always test error paths:
it "handles missing parameters" do
tool = Autobot::Tools::MyTool.new
result = tool.execute({} of String => JSON::Any)
result.error?.should be_true
result.content.should contain("missing")
end
it "handles rate limiting" do
limiter = Autobot::Tools::RateLimiter.new(
per_tool_limits: {"exec" => Autobot::Tools::RateLimiter::Limit.new(
max_calls: 1,
window_seconds: 60
)}
)
limiter.record_call("exec", "session")
error = limiter.check_limit("exec", "session")
error.should_not be_nil
error.should contain("max 1 calls")
endAvoiding not_nil!
Avoid not_nil! in tests. Use safe nil handling instead:
# Bad
result.content.not_nil!.should contain("text")
# Good
if content = result.content
content.should contain("text")
else
fail("Expected content to not be nil")
endShared Examples
For common test patterns:
macro test_provider_interface
describe "provider interface" do
it "returns a name" do
provider.name.should be_a(String)
provider.name.should_not be_empty
end
it "returns a display name" do
provider.display_name.should be_a(String)
end
end
end
# Usage
describe Autobot::Providers::MyProvider do
provider = Autobot::Providers::MyProvider.new(api_key: "test")
test_provider_interface
endSecurity Testing
Test security constraints explicitly:
describe "SSRF protection" do
it "blocks private IPs" do
tool = Autobot::Tools::WebFetchTool.new
%w[http://127.0.0.1/secret http://10.0.0.1/].each do |url|
result = tool.execute({"url" => JSON::Any.new(url)})
result.access_denied?.should be_true
end
end
endTest Performance
- Keep tests fast (< 1s per test ideally)
- Use
before_each/after_eachfor setup/teardown - Avoid real network calls (mock HTTP)
- Avoid real file system operations when possible
Coverage
Test these scenarios:
- Happy path (normal operation)
- Invalid inputs
- Missing required parameters
- Error conditions (network, auth, etc.)
- Edge cases (empty strings, max values, etc.)
- Security constraints (private IPs, path traversal, etc.)
When to Use
Use this skill when:
- Writing new tests
- Debugging test failures
- Refactoring test code
- Setting up test infrastructure
- Reviewing test coverage
Related Skills: autobot-tool, autobot-provider
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

