Claude
View SourceHelp make Claude Code write production-ready Elixir, every time.
Claude, not to be confused with the Claude (probably should have picked a better name π ), is an elixir library, batteries-included integration that ensures every line of code Claude writes is properly formatted, compiles without warnings, and follows your project's conventionsβautomatically.
Quick Start
# Install Claude
mix igniter.install claude
# That's it! Now Claude:
# β Formats every file after editing
# β Checks for compilation errors
# β Validates code before commits
The Problem
When Claude Code writes Elixir, you often need to:
- Run
mix formatmanually after every edit - Discover compilation errors only when you run the code
- Remember to update related test files
- Ensure consistent code style across your team
The Solution
Claude hooks directly into Claude Code's workflow:
# Before Claude: Unformatted code that might not compile
defmodule MyModule do
def hello( name ) do
"Hello, #{ nam }!" # Oops, typo!
end
end
# After Claude: Production-ready code, automatically
defmodule MyModule do
def hello(name) do
"Hello, #{name}!"
end
endFeatures
π― Smart Hooks
- Format on save - Every
.exand.exsfile is automatically formatted - Compile checks - Catch errors immediately, not in production
- Pre-commit validation - Block bad commits before they happen
- Related files - "You edited the schema, want to check the Phoenix Context?"
π§ Extensible
# .claude.exs - Add your own hooks
%{
hooks: [
MyApp.Hooks.SecurityScanner,
MyApp.Hooks.TestRunner
]
}π€ Sub-agents
Create specialized AI assistants for your project with built-in best practices:
%{
subagents: [
%{
name: "genserver-agent",
role: "Genserver agent",
instructions: "You are an writing and testing genservers...",
usage_rules: ["usage_rules:elixir", "usage_rules:otp"] # Automatically includes best practices!
}
]
}Built-in Meta Agent: Claude includes a Meta Agent by default that helps you create new sub-agents following best practices. Just ask: "Create a sub-agent for handling GraphQL queries" and the Meta Agent will:
- Generate a complete sub-agent configuration
- Choose appropriate tools and permissions
- Include relevant usage rules from your dependencies
- Add it to your
.claude.exsfile
Usage Rules Integration: The real power comes from usage rules - documentation from your dependencies that gets automatically injected into sub-agents, ensuring they follow library best practices.
π MCP Server Support
Integrate with Phoenix development tools via Tidewave:
%{
mcp_servers: [tidewave: [port: 4000]]
}π Best Practices
Usage rules will be added to your CLAUDE.md automatically so you can have the best chance of your agents following best practices.
Installation
Requirements
- Elixir ~> 1.18
- Claude Code (CLI)
- Mix with Igniter support
Install via Igniter
mix igniter.install claude
This will:
- Add
claudeto your dependencies - Generate
.claude.exsconfiguration - Install hooks in
.claude/settings.jsonand.claude/hooks - Create specialized sub-agents in
.claud/agents
Configuration
Claude uses .claude.exs for project-specific configuration:
# .claude.exs
%{
# Hooks to run (built-in + custom)
hooks: [
# Optional: Enable related files suggestions
Claude.Hooks.PostToolUse.RelatedFiles,
# Add your custom hooks
MyApp.Hooks.CredoChecker
],
# MCP servers (for Phoenix projects, only tidewave is supported, use claude manually to add other mcp servers)
mcp_servers: [
# Simple configuration
:tidewave,
# Or with options
{:tidewave, [port: 5000]}
],
# Specialized sub-agents
subagents: [
%{
name: "test_expert",
role: "ExUnit testing specialist",
instructions: "You excel at writing comprehensive test suites...",
usage_rules: ["usage_rules:elixir", "usage_rules:otp"]
}
]
}Built-in Sub-agents
Claude includes a Meta Agent by default to help you create new sub-agents.
Meta Agent
The Meta Agent is your sub-agent architect. It helps you create new, well-designed sub-agents by:
- Analyzing your requirements and suggesting optimal configuration
- Choosing appropriate tools and permissions
- Integrating usage rules from your dependencies
- Following Claude Code best practices for performance and context management
Usage: Just ask Claude to create a new sub-agent, and the Meta Agent will automatically help.
Creating Custom Hooks
Extend Claude with your own hooks:
defmodule MyApp.Hooks.CredoChecker do
use Claude.Hooks.Hook.Behaviour,
event: :post_tool_use,
matcher: [:edit, :write],
description: "Runs Credo on modified files"
@impl true
def run(json_input) do
# Your hook logic here
:ok
end
endHow It Works
This library leverages Claude Code's hook system to intercept file operations:
- Claude edits a file β PostToolUse hook triggered
- Hook runs Mix tasks β
mix format,mix compile --warnings-as-errors - Feedback provided β Claude sees any issues and can fix them
- Process repeats β Until the code is production-ready
This happens automatically, without interrupting Claude's workflow.
Documentation
Contributing
We welcome contributions!
# Run tests
mix test
# Format code
mix format
# Run quality checks
mix compile --warnings-as-errors
Support
- π Documentation
- π¬ Discussions
- π Issue Tracker
Roadmap
π Coming Soon
Custom Slash Commands
/create-subagent- Generate a new sub-agent with guided prompts/create-hook- Scaffold a new custom hook with boilerplate- Auto-generate commands in
.claude/commands/during installation
Scoped CLAUDE.md's
- Directory-specific instructions (e.g.,
*_web/CLAUDE.mdfor Phoenix)
More MCP Servers
- Database tools (PostgreSQL, MySQL, Redis)
- Testing and documentation servers
- Auto-configuration based on project dependencies
Dynamic Sub-agents
- Generate sub-agents for each dependency with context automatically
- Common workflow templates (LiveView, GraphQL, Testing)
Want to contribute? Open an issue on GitHub!
License
MIT - see LICENSE for details.
Made with β€οΈ by the Elixir community