### Generated SKILL.md Example Source: https://context7.com/ash-project/usage_rules/llms.txt Example frontmatter for a generated SKILL.md file, including name, description, and managed-by metadata, along with sections for additional references, documentation searching, and available mix tasks. ```markdown --- name: ash-framework description: "Expert on the Ash Framework ecosystem." metadata: managed-by: usage-rules --- ## Additional References ### ash - [ash](references/ash/ash.md) - [postgres](references/ash/postgres.md) ## Searching Documentation ```sh mix usage_rules.search_docs "search term" -p ash -p ash_postgres ``` ## Available Mix Tasks - `mix ash.gen.resource` - Generate an Ash resource ``` -------------------------------- ### Pre-built SKILL.md Frontmatter Source: https://context7.com/ash-project/usage_rules/llms.txt Example frontmatter for a pre-built SKILL.md file located within a package's 'usage-rules/skills/' directory, including name, description, and an overview section. ```markdown --- name: my-skill description: "Use this skill when working with MyPackage." --- ## Overview Content describing how to use the package effectively... ``` -------------------------------- ### Install UsageRules with Igniter Source: https://github.com/ash-project/usage_rules/blob/main/README.md Use this command if you have igniter installed to add UsageRules to your project. ```sh mix igniter.install usage_rules ``` -------------------------------- ### Configure UsageRules in mix.exs Source: https://context7.com/ash-project/usage_rules/llms.txt This example shows a full-featured configuration for `usage_rules` in `mix.exs`. It specifies the target output file, lists the usage rules to include, and configures skill generation and composition. ```elixir def project do [ app: :my_app, version: "0.1.0", deps: deps(), usage_rules: usage_rules() ] end defp usage_rules do [ # Target file to write consolidated usage rules into file: "CLAUDE.md", # Inline specific packages' usage-rules.md # :elixir and :otp are built-in aliases shipped with usage_rules itself usage_rules: [ :elixir, # built-in Elixir rules :otp, # built-in OTP rules :ash, # inline deps/ash/usage-rules.md "phoenix:all", # inline all phoenix sub-rules {:req, link: :at}, # link: @deps/req/usage-rules.md {:ecto, link: :markdown}, # link: [ecto usage rules](deps/ecto/usage-rules.md) {~r/^ash_/, link: :markdown} # link all ash_* extensions ], skills: [ location: ".claude/skills", # output directory (default) # Auto-build one "use-" skill per dependency deps: [:ash, :req, ~r/^ash_/], # Pull in pre-built skills shipped by packages package_skills: [:ash, ~r/^ash_/], # Compose custom multi-package skills build: [ "ash-framework": [ description: "Use this skill when working with Ash Framework or any of its extensions.", usage_rules: [:ash, ~r/^ash_/] ], "phoenix-framework": [ description: "Use this skill when working with Phoenix. Consult for web layer work.", usage_rules: [:phoenix, ~r/^phoenix_/] ] ] ] ] end ``` -------------------------------- ### Full UsageRules Configuration Reference Source: https://github.com/ash-project/usage_rules/blob/main/README.md Detailed configuration options for UsageRules in mix.exs, covering file output, rule inclusion, and agent skill setup. ```elixir defp usage_rules do [ # The file to write usage rules into (required for usage_rules syncing) file: "CLAUDE.md", # include links in your CLAUDE.md for all packages with usage_rules usage_rules: [{~r/.*/, link: :markdown}], # Or list specific packages and sub-rules: # usage_rules: [ # :ash, # inlined (default) # ~r/^ash_/, # regex match (inlined) # "phoenix:ecto", # specific sub-rule (inlined) # {:req, link: :at}, # linked with @-style # {:ecto, link: :markdown}, # linked with markdown-style # {~r/^phoenix_/, link: :markdown}, # regex match (linked) # :elixir, # built-in Elixir rules # :otp, # built-in OTP rules # ], # Agent skills configuration skills: [ location: ".claude/skills", # where to output skills (default) # Auto-build a "use-" skill per dependency deps: [:ash, :req], # Supports regex for matching multiple deps: # deps: [~r/^ash_/], # Pull in pre-built skills shipped directly by packages package_skills: [:ash, ~r/^ash_/], # Compose custom skills from multiple packages build: [ "ash-framework": [ description: "Expert on the Ash Framework ecosystem.", usage_rules: [:ash, ~r/^ash_/] ] ] ] ] end ``` -------------------------------- ### Configure UsageRules in mix.exs Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure UsageRules by adding a :usage_rules key to your project's configuration in mix.exs. This example shows configuration for Claude. ```elixir def project do [ ... usage_rules: usage_rules() ] end defp usage_rules do # Example for those using claude. [ file: "CLAUDE.md", # rules to include directly in CLAUDE.md # :usage_rules itself provides rules for search_docs, docs, etc. # use a regex to match multiple deps, or atoms/strings for specific ones usage_rules: [:usage_rules, :ash, ~r/^ash_/], # If your CLAUDE.md is getting too big, link instead of inlining: usage_rules: [:ash, {~r/^ash_/, link: :markdown}], # or use skills skills: [ location: ".claude/skills", # build skills that combine multiple usage rules build: [ "ash-framework": [ # The description tells people how to use this skill. description: "Use this skill working with Ash Framework or any of its extensions. Always consult this when making any domain changes, features or fixes.", # Include all Ash dependencies usage_rules: [:ash, ~r/^ash_/] ], "phoenix-framework": [ description: "Use this skill working with Phoenix Framework. Consult this when working with the web layer, controllers, views, liveviews etc.", # Include all Phoenix dependencies usage_rules: [:phoenix, ~r/^phoenix_/] ] ] ] ] end ``` -------------------------------- ### Elixir Guard Clause Example Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Guard clauses can be used to add conditions to function heads, improving clarity and performance. ```elixir when is_binary(name) and byte_size(name) > 0 ``` -------------------------------- ### List All Dependencies with Usage Rules Source: https://context7.com/ash-project/usage_rules/llms.txt Command to list all project dependencies that ship usage rules and the sub-rule files they provide. ```sh # List all dependencies with usage rules mix usage_rules.list # Output: # Dependencies with usage rules: # :ash (deps/ash) # usage-rules.md: yes # sub-rules: postgres, phoenix # :req (deps/req) # usage-rules.md: yes # sub-rules: (none) # Filter to a specific package mix usage_rules.list ash # Output: # :ash (deps/ash) # usage-rules.md: yes # sub-rules: postgres, phoenix ``` -------------------------------- ### Elixir Mix Task Help Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use `mix help` to list available tasks and `mix help task_name` for specific task documentation. ```bash mix help ``` ```bash mix help task_name ``` -------------------------------- ### Sync All Dependencies Usage Rules Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure to discover and inline all dependencies' usage-rules.md files. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: :all ] end ``` -------------------------------- ### Package Layout for Usage Rules Source: https://context7.com/ash-project/usage_rules/llms.txt Illustrates the directory structure for a package named 'my_pkg' to include usage rules, such as a main rules file and sub-rule files within a 'usage-rules/' directory, including a 'skills/' subdirectory for pre-built skills. ```text # Layout for a package named "my_pkg" usage-rules.md # main rules (optional) usage-rules/ html.md # sub-rule: "my_pkg:html" database.md # sub-rule: "my_pkg:database" skills/ my-skill/ SKILL.md # pre-built skill users can pull in via package_skills: references/ some-ref.md # companion file copied alongside SKILL.md ``` -------------------------------- ### Show Callback Documentation Source: https://context7.com/ash-project/usage_rules/llms.txt Displays documentation for a specific Elixir callback, which is automatically detected. ```sh mix usage_rules.docs GenServer.handle_call/3 ``` -------------------------------- ### Show Dependency Module Documentation Source: https://context7.com/ash-project/usage_rules/llms.txt Displays documentation for a module within a project dependency. ```sh mix usage_rules.docs Ecto.Changeset ``` -------------------------------- ### Search All Hex.pm Packages Source: https://context7.com/ash-project/usage_rules/llms.txt Searches documentation across all packages on hex.pm, ignoring project-specific scoping. Useful for general queries. ```sh mix usage_rules.search_docs "rate limiting" --everywhere ``` -------------------------------- ### Search Project Dependencies Source: https://context7.com/ash-project/usage_rules/llms.txt Searches documentation for project dependencies, automatically scoped to your mix.lock versions. Use quotes for multi-word searches. ```sh mix usage_rules.search_docs "changeset validation" ``` -------------------------------- ### Sync Usage Rules Source: https://context7.com/ash-project/usage_rules/llms.txt Commands to synchronize usage rules and generate agent skills. Use `--dry-run` to preview changes or `--check` for CI to exit non-zero if files would change. ```sh mix usage_rules.sync ``` ```sh mix usage_rules.sync --dry-run ``` ```sh mix usage_rules.sync --check ``` -------------------------------- ### Include All Sub-rules Source: https://github.com/ash-project/usage_rules/blob/main/README.md Use "package:all" to include all sub-rules from a package. ```elixir usage_rules: [:phoenix, "phoenix:all"] ``` -------------------------------- ### Search Specific Packages Source: https://context7.com/ash-project/usage_rules/llms.txt Searches documentation within specific packages. Use the `-p` flag followed by the package name, optionally with a version. ```sh mix usage_rules.search_docs "insert_all" -p ecto -p ecto_sql ``` -------------------------------- ### Show Nested Module Documentation Source: https://context7.com/ash-project/usage_rules/llms.txt Displays documentation for a nested module within your project. ```sh mix usage_rules.docs MyApp.Accounts.User ``` -------------------------------- ### Show Module Documentation Source: https://context7.com/ash-project/usage_rules/llms.txt Displays local documentation for a given Elixir module in markdown format. Falls back to callback documentation if function docs are not found. ```sh mix usage_rules.docs Enum ``` -------------------------------- ### Migration from v0.2 Global Options Source: https://context7.com/ash-project/usage_rules/llms.txt Illustrates the v1.x per-dependency link options, which replace the v0.2 global link options. ```elixir # ---- v1.x per-dependency link options ---- usage_rules: [ {:ash, link: :at}, {:phoenix, link: :at}, "usage_rules:all" # inlined by default ] ``` -------------------------------- ### Search Documentation with mix usage_rules.search_docs Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules.md Employ `mix usage_rules.search_docs` to find documentation across all packages in your application or within specific packages. This task supports searching for functions, modules, and multi-word queries, with an option to filter results by title. ```shell # Search docs for all packages in the current application, including Elixir mix usage_rules.search_docs Enum.zip # Search docs for specific packages mix usage_rules.search_docs Req.get -p req # Search docs for multi-word queries mix usage_rules.search_docs "making requests" -p req # Search only in titles (useful for finding specific functions/modules) mix usage_rules.search_docs "Enum.zip" --query-by title ``` -------------------------------- ### Package Author: Pre-built Skills Structure Source: https://github.com/ash-project/usage_rules/blob/main/README.md Structure for shipping pre-built skills within a package. Skill files are placed in `usage-rules/skills/` and can include companion reference files. ```markdown usage-rules/skills/ my-skill/ SKILL.md # the skill definition references/ some-ref.md # optional reference files ``` -------------------------------- ### Match Dependencies by Regex Source: https://github.com/ash-project/usage_rules/blob/main/README.md Use a regular expression to match and inline usage rules for multiple dependencies. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: [:ash, ~r/^ash_/\] # If your AGENTS.md is getting too big, link instead of inlining: # usage_rules: [:ash, {~r/^ash_/, link: :markdown}] ] end ``` -------------------------------- ### Migration from v0.1 CLI Style Source: https://context7.com/ash-project/usage_rules/llms.txt Shows the v1.x configuration style for usage_rules, replacing the older v0.1 CLI arguments. ```elixir # ---- v1.x config style ---- def project do [ usage_rules: [ file: "AGENTS.md", usage_rules: :all ] ] end ``` -------------------------------- ### Package Author: Usage Rules File Structure Source: https://github.com/ash-project/usage_rules/blob/main/README.md Structure for `usage-rules.md` files, including general rules and optional sub-rule directories for specific functionalities like HTML or database interactions. ```markdown usage-rules.md # general rules usage-rules/ html.md # html specific rules database.md # database specific rules ``` -------------------------------- ### Sync Specific Packages Usage Rules Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure to include only specified packages' usage rules. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: [:ash, :phoenix, :ecto] ] end ``` -------------------------------- ### Compose Custom Skills from Multiple Packages Source: https://github.com/ash-project/usage_rules/blob/main/README.md Use the `build` option to compose a single skill from multiple packages. This is useful for creating a comprehensive skill that references rules from several related libraries. Regex is supported for package names. ```elixir skills: [ build: [ "ash-framework": [ description: "Expert on the Ash Framework ecosystem.", usage_rules: [:ash, :ash_postgres, :ash_phoenix, :ash_json_api] ] ] ] ``` ```elixir skills: [ build: [ "ash-framework": [ description: "Expert on Ash.", usage_rules: [:ash, ~r/^ash_/] ] ] ] ``` -------------------------------- ### Include Usage Rules Files in Hex Package Source: https://context7.com/ash-project/usage_rules/llms.txt Configure the 'package' definition in mix.exs to include 'usage-rules.md' and the 'usage-rules/' directory in the hex package distribution. ```elixir defp package do [ files: ~w(lib mix.exs README* LICENSE* CHANGELOG* usage-rules.md usage-rules) ] end ``` -------------------------------- ### Update Usage Rules Options for v1.0 Source: https://github.com/ash-project/usage_rules/blob/main/README.md v1.0 removes `link_to_folder`, `link_style`, and `inline` options. Content is now inlined by default. Use the per-dependency `link` option for linking. ```elixir # Before (v0.2) usage_rules: :all, link_to_folder: "deps", link_style: "at", inline: ["usage_rules:all"] # After (v1.0) usage_rules: [ {:ash, link: :at}, {:phoenix, link: :at}, "usage_rules:all" # inlined by default ] ``` -------------------------------- ### Search Module Documentation with mix usage_rules.docs Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules.md Use `mix usage_rules.docs` to search for documentation within modules. You can search for an entire module, a specific function, or a function with a specific arity. ```shell mix usage_rules.docs Enum # Search a specific function mix usage_rules.docs Enum.zip # Search a specific function & arity mix usage_rules.docs Enum.zip/1 ``` -------------------------------- ### Add UsageRules and Igniter to Dev Dependencies Source: https://context7.com/ash-project/usage_rules/llms.txt Include `usage_rules` and `igniter` in your `mix.exs` file under the `:dev` dependencies. This ensures they are only available during development. ```elixir defp deps do [ {:usage_rules, ">= 1.2", only: [:dev]}, {:igniter, ">= 0.6", only: [:dev]} ] end ``` -------------------------------- ### Link Dependencies Instead of Inlining Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure to link to package usage rules using :at or :markdown styles instead of inlining. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: [ :ash, # inlined {:phoenix, link: :at}, # @deps/phoenix/usage-rules.md {:ecto, link: :markdown}, # [ecto usage rules](deps/ecto/usage-rules.md) {"phoenix:html", link: :at} # @deps/phoenix/usage-rules/html.md ] ] end ``` -------------------------------- ### Umbrella Project Configuration Source: https://context7.com/ash-project/usage_rules/llms.txt Configures the usage_rules tool to support umbrella projects by collecting dependencies from all child apps. The `:usage_rules` key is placed in the root `mix.exs` file. ```elixir def project do [ apps_path: "apps", usage_rules: [ file: "AGENTS.md", # Collects deps from apps/app_a, apps/app_b, etc. usage_rules: :all ] ] end ``` -------------------------------- ### Define Usage Rules in Elixir Source: https://context7.com/ash-project/usage_rules/llms.txt Configure which package rules are included and how they appear in the output file using various formats like inline, linked, and mixed references. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: [ # --- Inline (content embedded directly) --- :ash, # main usage-rules.md only ~r/^ash_/, # all deps matching regex "phoenix:ecto", # specific sub-rule only "phoenix:all", # all sub-rules for phoenix :elixir, # built-in alias → usage_rules sub-rule "elixir" :otp, # built-in alias → usage_rules sub-rule "otp" # --- Linked (reference inserted, file not inlined) --- {:req, link: :at}, # @deps/req/usage-rules.md {:ecto, link: :markdown}, # [ecto usage rules](deps/ecto/usage-rules.md) {"phoenix:html", link: :at}, # @deps/phoenix/usage-rules/html.md {~r/^ash_/, link: :markdown}, # regex match, markdown links # --- Mixed: inline main, link sub-rules --- {:ash, sub_rules: []}, # inline main rules, no sub-rules {:ash, sub_rules: :all, main: false, link: :markdown}, # link all sub-rules only # --- Exclude specific sub-rules --- {:phoenix, except: ["html", "js"]} # skip listed sub-rules ] ] end ``` -------------------------------- ### Add UsageRules to mix.exs Source: https://github.com/ash-project/usage_rules/blob/main/README.md Manually add UsageRules and Igniter to your project's development dependencies in mix.exs. ```elixir def deps do [ {:usage_rules, "~> 1.1", only: [:dev]}, {:igniter, "~> 0.6", only: [:dev]} ] end ``` -------------------------------- ### Auto-build Skills from Dependencies Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure `deps` to automatically generate `use-` skills for each listed dependency. This creates reference links and documentation for each package's usage rules. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: :all, skills: [ deps: [:ash, :req] ] ] end ``` -------------------------------- ### Search HexDocs Documentation Source: https://github.com/ash-project/usage_rules/blob/main/README.md Use `mix usage_rules.search_docs` to search HexDocs with human-readable markdown output. Supports searching all dependencies, specific packages, specific versions, and across all packages on Hex. ```sh # Search all project dependencies mix usage_rules.search_docs "search term" ``` ```sh # Search specific packages mix usage_rules.search_docs "search term" -p ecto -p ash ``` ```sh # Search specific versions mix usage_rules.search_docs "search term" -p ecto@3.13.2 ``` ```sh # Search all packages on hex mix usage_rules.search_docs "search term" --everywhere ``` ```sh # JSON output mix usage_rules.search_docs "search term" --output json ``` ```sh # Search only in titles mix usage_rules.search_docs "search term" --query-by title ``` ```sh # Pagination mix usage_rules.search_docs "search term" --page 2 --per-page 20 ``` -------------------------------- ### Inline Main Rules, Link Sub-rules Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure to inline main usage rules while linking to sub-rules using `main: false`. ```elixir defp usage_rules do [ file: "AGENTS.md", usage_rules: [ {:ash, sub_rules: []}, # inline main rules only {:ash, sub_rules: :all, main: false, link: :markdown} # link sub-rules only ] ] end ``` -------------------------------- ### Show Specific Function Documentation Source: https://context7.com/ash-project/usage_rules/llms.txt Displays documentation for a specific Elixir function, including its arity. ```sh mix usage_rules.docs Enum.map/2 ``` -------------------------------- ### Migrate CLI Arguments to Project Config (v0.1 to v0.2) Source: https://github.com/ash-project/usage_rules/blob/main/README.md Replace CLI arguments with project configuration in `mix.exs`. This change simplifies command execution by centralizing settings. ```sh mix usage_rules.sync AGENTS.md --all --link-to-folder deps ``` ```elixir def project do [ usage_rules: [ file: "AGENTS.md", usage_rules: :all ] ] end ``` -------------------------------- ### Skills-Only Mode Configuration Source: https://github.com/ash-project/usage_rules/blob/main/README.md Configure skills without syncing usage rules to a file by omitting the `file` and `usage_rules` keys. This is useful when you only need the skills functionality. ```elixir defp usage_rules do [ skills: [ deps: [:ash, :phoenix] ] ] end ``` -------------------------------- ### Umbrella Project Sync Source: https://context7.com/ash-project/usage_rules/llms.txt Synchronizes usage rules for umbrella projects. This command automatically discovers dependencies from all child applications. ```sh mix usage_rules.sync ``` -------------------------------- ### Elixir List Prepending Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Prefer prepending to lists using the `[new | list]` syntax for efficiency over appending with `++`. ```elixir Prefer to prepend to lists `[new | list]` not `list ++ [new]` ``` -------------------------------- ### Pin Search to Specific Version Source: https://context7.com/ash-project/usage_rules/llms.txt Pins the search to a specific version of a package. This ensures results are relevant to that exact version. ```sh mix usage_rules.search_docs "live_view mount" -p phoenix_live_view@0.20.17 ``` -------------------------------- ### Configure Skills in Elixir Source: https://context7.com/ash-project/usage_rules/llms.txt Manage AI skills using SKILL.md files within a specified directory. This configuration supports auto-generating skills per dependency, copying package-shipped skills, and building aggregated skills. ```elixir defp usage_rules do [ # skills-only mode: no file/usage_rules keys required skills: [ location: ".claude/skills", # Auto-generate one skill per dependency (use-ash, use-req, …) # Skill contains reference links + available mix tasks + search command deps: [:ash, :req, ~r/^ash_/], # Copy skills shipped directly inside a package's usage-rules/skills/ directory package_skills: [:ash, ~r/^ash_/], # Build a single skill that aggregates several packages build: [ "ash-framework": [ description: "Expert on the Ash Framework ecosystem.", usage_rules: [:ash, :ash_postgres, :ash_phoenix, :ash_json_api, ~r/^ash_/] ] ] ] ] end ``` -------------------------------- ### Use Built-in Aliases Source: https://github.com/ash-project/usage_rules/blob/main/README.md Utilize built-in usage rule aliases for common Elixir and OTP packages. ```elixir usage_rules: [:elixir, :otp, :ash, :phoenix] ``` -------------------------------- ### Include Specific Sub-rules Source: https://github.com/ash-project/usage_rules/blob/main/README.md Reference specific sub-rules from packages using the "package:sub_rule" syntax. ```elixir usage_rules: [:phoenix, "phoenix:ecto", "phoenix:html"] ``` -------------------------------- ### JSON Output for Scripting Source: https://context7.com/ash-project/usage_rules/llms.txt Outputs search results in JSON format, which is useful for scripting or post-processing by agents. ```sh mix usage_rules.search_docs "Req.get" --output json ``` -------------------------------- ### Search Specific Fields Source: https://context7.com/ash-project/usage_rules/llms.txt Searches across specified fields such as 'doc', 'title', and 'type'. This allows for targeted searches within documentation content. ```sh mix usage_rules.search_docs "migration" --query-by "doc,title,type" ``` -------------------------------- ### Elixir Running Specific Tests Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Run tests in a specific file or a particular line within a file using `mix test`. ```bash mix test test/my_test.exs ``` ```bash mix test path/to/test.exs:123 ``` -------------------------------- ### Query Hexdocs Full-Text Search API Source: https://context7.com/ash-project/usage_rules/llms.txt Command to query the hexdocs full-text search API, returning human-readable markdown results suitable for terminals and AI agents. Defaults to searching only packages used by the current mix project. ```sh mix usage_rules.search_docs ``` -------------------------------- ### Search Only in Titles Source: https://context7.com/ash-project/usage_rules/llms.txt Restricts the search to only the titles of documentation entries, enabling precise function or module lookups. ```sh mix usage_rules.search_docs "Ecto.Query.from" --query-by title ``` -------------------------------- ### Elixir Tagging and Running Tests Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Tag tests using `@tag` and run only tagged tests with `mix test --only tag`. ```elixir Use `@tag` to tag specific tests, and `mix test --only tag` to run only those tests ``` -------------------------------- ### Elixir Debugging with `dbg/1` Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use the `dbg/1` function to print values and debugging information to the console during development. ```elixir Use `dbg/1` to print values while debugging. This will display the formatted value and other relevant information in the console. ``` -------------------------------- ### Elixir Testing Expected Exceptions Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use `assert_raise` to test for expected exceptions, providing the exception type and a function that should raise it. ```elixir assert_raise ArgumentError, fn -> invalid_function() end ``` -------------------------------- ### Elixir Error Handling with Tuples Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use `{:ok, result}` and `{:error, reason}` tuples for operations that can fail. Avoid raising exceptions for control flow. ```elixir Use `{:ok, result}` and `{:error, reason}` tuples for operations that can fail Avoid raising exceptions for control flow ``` -------------------------------- ### Elixir Map Pattern Matching Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use `map_size(map) == 0` guard to check for truly empty maps when pattern matching. ```elixir %{} matches ANY map, not just empty maps. Use `map_size(map) == 0` guard to check for truly empty maps ``` -------------------------------- ### Elixir `with` for Chained Operations Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Use the `with` construct for chaining operations that return `{:ok, _}` or `{:error, _}` tuples, simplifying error propagation. ```elixir Use `with` for chaining operations that return `{:ok, _}` or `{:error, _}` ``` -------------------------------- ### Paginate Search Results Source: https://context7.com/ash-project/usage_rules/llms.txt Retrieves paginated search results. Use `--page` to specify the page number and `--per-page` to set the number of items per page. ```sh mix usage_rules.search_docs "schema" --page 2 --per-page 20 ``` -------------------------------- ### Elixir Limiting Test Failures Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Control the number of test failures shown using the `--max-failures` option with `mix test`. ```bash mix test --max-failures n ``` -------------------------------- ### Elixir Struct Definition Source: https://github.com/ash-project/usage_rules/blob/main/usage-rules/elixir.md Define structs using `defstruct` to represent data with a known shape, preferring them over maps. ```elixir defstruct [:name, :age] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.