Core Integration Patterns
Always use extensions: [AshJido] in your Ash resource definition
Define the jido section after your actions section for clarity
Use the DSL to selectively expose actions as Jido tools
Action Exposure Strategies
Individual Action Configuration
jido do
action :create
action :read , name: "list_users" , description: "List all users"
action :update , tags: [ "user-management" , "data-modification" ]
end
jido do
all_actions
# or with filtering
all_actions except: [ :internal_action , :admin_only ]
all_actions only: [ :create , :read , :update ]
end
Auto-generated names follow: {resource}_{action} format
Examples: user_create, post_update, comment_delete
Use name: option for custom action names
Use module_name: for custom module naming
Keep names descriptive and AI-friendly
Default modules: MyApp.User.Jido.Create
Custom modules: specify with module_name: option
Domain Configuration (REQUIRED)
Domain is REQUIRED - always provide domain: in action context
Use %{domain: MyApp.Domain} pattern
Actions will raise ArgumentError if domain is not provided
Include actor: for authorization
Include tenant: for multi-tenancy
Example: %{domain: MyDomain, actor: current_user, tenant: "org_123"}
:create actions → data_creation category
:read actions → data_retrieval category
:update actions → data_modification category
:destroy actions → data_deletion category
:action type → custom_operation category
Use descriptive names for better AI discovery
Add relevant tags for categorization
String keys auto-converted to atoms when appropriate
Use standard Ash argument patterns
Include validation through NimbleOptions schemas
Default: output_map?: true converts Ash structs to plain maps
Set output_map?: false to preserve Ash structs
Read actions return a list of records
Create/Update actions return the record
Ash errors automatically wrapped as Jido.Error
Field-level validation errors preserved
Authorization errors mapped to appropriate Jido types
Ash.Error.Forbidden → :authorization_error
Ash.Error.Invalid → :validation_error
Ash.Error.Framework → :system_error
Ash.Error.Unknown → :execution_error
Always use Ash policies for authorization
Don't expose sensitive actions without proper filtering
Use except: to exclude admin or internal actions
Consider limit: and offset: for large datasets
Add descriptive tags for better AI discovery
Use clear, descriptive action names
Include comprehensive descriptions
Tag actions by domain: ["user-management", "content", "analytics"]
Leverage auto-generated module documentation
Actions inherit descriptions from Ash definitions
Custom descriptions override defaults
jido do
action :create , name: "register_user"
action :read , name: "list_users" , tags: [ "user-management" , "public" ]
action :update , name: "update_profile"
action :destroy , name: "delete_account" , tags: [ "user-management" , "destructive" ]
end
jido do
all_actions except: [ :internal_update ]
# Auto-generates: create_post, list_posts, update_post, delete_post
end
jido do
action :activate , name: "activate_user" , tags: [ "user-management" , "state-change" ]
action :calculate_metrics , tags: [ "analytics" , "reporting" ]
end
Domain Not Provided Error
Domain is required in context - provide %{domain: MyApp.Domain}
Ensure the resource is registered in the domain you're providing
Verify action exists in resource definition
Check spelling and exact action name
Ensure action is public (not private)
Check Ash type → NimbleOptions mapping
Verify custom types are properly handled
Use string keys for JSON/API inputs
Module Compilation Issues
Ensure Jido dependency is available
Check for circular dependencies
Verify proper extension loading order