Update dependencies
usage_rules 1.0.2 => 1.1.0 Fixes a bug that would cause skipping of included subrules.
This commit is contained in:
@@ -3,6 +3,55 @@
|
|||||||
[Project architecture](architecture.md)
|
[Project architecture](architecture.md)
|
||||||
|
|
||||||
<!-- usage-rules-start -->
|
<!-- usage-rules-start -->
|
||||||
|
<!-- usage_rules-start -->
|
||||||
|
## usage_rules usage
|
||||||
|
_A config-driven dev tool for Elixir projects to manage AGENTS.md files and agent skills from dependencies_
|
||||||
|
|
||||||
|
## Using Usage Rules
|
||||||
|
|
||||||
|
Many packages have usage rules, which you should *thoroughly* consult before taking any
|
||||||
|
action. These usage rules contain guidelines and rules *directly from the package authors*.
|
||||||
|
They are your best source of knowledge for making decisions.
|
||||||
|
|
||||||
|
## Modules & functions in the current app and dependencies
|
||||||
|
|
||||||
|
When looking for docs for modules & functions that are dependencies of the current project,
|
||||||
|
or for Elixir itself, use `mix usage_rules.docs`
|
||||||
|
|
||||||
|
```
|
||||||
|
# Search a whole module
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Searching Documentation
|
||||||
|
|
||||||
|
You should also consult the documentation of any tools you are using, early and often. The best
|
||||||
|
way to accomplish this is to use the `usage_rules.search_docs` mix task. Once you have
|
||||||
|
found what you are looking for, use the links in the search results to get more detail. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<!-- usage_rules-end -->
|
||||||
<!-- usage_rules:elixir-start -->
|
<!-- usage_rules:elixir-start -->
|
||||||
## usage_rules:elixir usage
|
## usage_rules:elixir usage
|
||||||
# Elixir Core Usage Rules
|
# Elixir Core Usage Rules
|
||||||
@@ -60,6 +109,55 @@
|
|||||||
- Use `dbg/1` to print values while debugging. This will display the formatted value and other relevant information in the console.
|
- Use `dbg/1` to print values while debugging. This will display the formatted value and other relevant information in the console.
|
||||||
|
|
||||||
<!-- usage_rules:elixir-end -->
|
<!-- usage_rules:elixir-end -->
|
||||||
|
<!-- usage_rules-start -->
|
||||||
|
## usage_rules usage
|
||||||
|
_A config-driven dev tool for Elixir projects to manage AGENTS.md files and agent skills from dependencies_
|
||||||
|
|
||||||
|
## Using Usage Rules
|
||||||
|
|
||||||
|
Many packages have usage rules, which you should *thoroughly* consult before taking any
|
||||||
|
action. These usage rules contain guidelines and rules *directly from the package authors*.
|
||||||
|
They are your best source of knowledge for making decisions.
|
||||||
|
|
||||||
|
## Modules & functions in the current app and dependencies
|
||||||
|
|
||||||
|
When looking for docs for modules & functions that are dependencies of the current project,
|
||||||
|
or for Elixir itself, use `mix usage_rules.docs`
|
||||||
|
|
||||||
|
```
|
||||||
|
# Search a whole module
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Searching Documentation
|
||||||
|
|
||||||
|
You should also consult the documentation of any tools you are using, early and often. The best
|
||||||
|
way to accomplish this is to use the `usage_rules.search_docs` mix task. Once you have
|
||||||
|
found what you are looking for, use the links in the search results to get more detail. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<!-- usage_rules-end -->
|
||||||
<!-- usage_rules:otp-start -->
|
<!-- usage_rules:otp-start -->
|
||||||
## usage_rules:otp usage
|
## usage_rules:otp usage
|
||||||
# OTP Usage Rules
|
# OTP Usage Rules
|
||||||
@@ -541,6 +639,139 @@ mix usage_rules.search_docs "Enum.zip" --query-by title
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<!-- usage_rules-end -->
|
||||||
|
<!-- usage_rules:elixir-start -->
|
||||||
|
## usage_rules:elixir usage
|
||||||
|
# Elixir Core Usage Rules
|
||||||
|
|
||||||
|
## Pattern Matching
|
||||||
|
- Use pattern matching over conditional logic when possible
|
||||||
|
- Prefer to match on function heads instead of using `if`/`else` or `case` in function bodies
|
||||||
|
- `%{}` matches ANY map, not just empty maps. Use `map_size(map) == 0` guard to check for truly empty maps
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
- Use `{:ok, result}` and `{:error, reason}` tuples for operations that can fail
|
||||||
|
- Avoid raising exceptions for control flow
|
||||||
|
- Use `with` for chaining operations that return `{:ok, _}` or `{:error, _}`
|
||||||
|
|
||||||
|
## Common Mistakes to Avoid
|
||||||
|
- Elixir has no `return` statement, nor early returns. The last expression in a block is always returned.
|
||||||
|
- Don't use `Enum` functions on large collections when `Stream` is more appropriate
|
||||||
|
- Avoid nested `case` statements - refactor to a single `case`, `with` or separate functions
|
||||||
|
- Don't use `String.to_atom/1` on user input (memory leak risk)
|
||||||
|
- Lists and enumerables cannot be indexed with brackets. Use pattern matching or `Enum` functions
|
||||||
|
- Prefer `Enum` functions like `Enum.reduce` over recursion
|
||||||
|
- When recursion is necessary, prefer to use pattern matching in function heads for base case detection
|
||||||
|
- Using the process dictionary is typically a sign of unidiomatic code
|
||||||
|
- Only use macros if explicitly requested
|
||||||
|
- There are many useful standard library functions, prefer to use them where possible
|
||||||
|
|
||||||
|
## Function Design
|
||||||
|
- Use guard clauses: `when is_binary(name) and byte_size(name) > 0`
|
||||||
|
- Prefer multiple function clauses over complex conditional logic
|
||||||
|
- Name functions descriptively: `calculate_total_price/2` not `calc/2`
|
||||||
|
- Predicate function names should not start with `is` and should end in a question mark.
|
||||||
|
- Names like `is_thing` should be reserved for guards
|
||||||
|
|
||||||
|
## Data Structures
|
||||||
|
- Use structs over maps when the shape is known: `defstruct [:name, :age]`
|
||||||
|
- Prefer keyword lists for options: `[timeout: 5000, retries: 3]`
|
||||||
|
- Use maps for dynamic key-value data
|
||||||
|
- Prefer to prepend to lists `[new | list]` not `list ++ [new]`
|
||||||
|
|
||||||
|
## Mix Tasks
|
||||||
|
|
||||||
|
- Use `mix help` to list available mix tasks
|
||||||
|
- Use `mix help task_name` to get docs for an individual task
|
||||||
|
- Read the docs and options fully before using tasks
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
- Run tests in a specific file with `mix test test/my_test.exs` and a specific test with the line number `mix test path/to/test.exs:123`
|
||||||
|
- Limit the number of failed tests with `mix test --max-failures n`
|
||||||
|
- Use `@tag` to tag specific tests, and `mix test --only tag` to run only those tests
|
||||||
|
- Use `assert_raise` for testing expected exceptions: `assert_raise ArgumentError, fn -> invalid_function() end`
|
||||||
|
- Use `mix help test` to for full documentation on running tests
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
- Use `dbg/1` to print values while debugging. This will display the formatted value and other relevant information in the console.
|
||||||
|
|
||||||
|
<!-- usage_rules:elixir-end -->
|
||||||
|
<!-- usage_rules:otp-start -->
|
||||||
|
## usage_rules:otp usage
|
||||||
|
# OTP Usage Rules
|
||||||
|
|
||||||
|
## GenServer Best Practices
|
||||||
|
- Keep state simple and serializable
|
||||||
|
- Handle all expected messages explicitly
|
||||||
|
- Use `handle_continue/2` for post-init work
|
||||||
|
- Implement proper cleanup in `terminate/2` when necessary
|
||||||
|
|
||||||
|
## Process Communication
|
||||||
|
- Use `GenServer.call/3` for synchronous requests expecting replies
|
||||||
|
- Use `GenServer.cast/2` for fire-and-forget messages.
|
||||||
|
- When in doubt, use `call` over `cast`, to ensure back-pressure
|
||||||
|
- Set appropriate timeouts for `call/3` operations
|
||||||
|
|
||||||
|
## Fault Tolerance
|
||||||
|
- Set up processes such that they can handle crashing and being restarted by supervisors
|
||||||
|
- Use `:max_restarts` and `:max_seconds` to prevent restart loops
|
||||||
|
|
||||||
|
## Task and Async
|
||||||
|
- Use `Task.Supervisor` for better fault tolerance
|
||||||
|
- Handle task failures with `Task.yield/2` or `Task.shutdown/2`
|
||||||
|
- Set appropriate task timeouts
|
||||||
|
- Use `Task.async_stream/3` for concurrent enumeration with back-pressure
|
||||||
|
|
||||||
|
<!-- usage_rules:otp-end -->
|
||||||
|
<!-- usage_rules-start -->
|
||||||
|
## usage_rules usage
|
||||||
|
_A config-driven dev tool for Elixir projects to manage AGENTS.md files and agent skills from dependencies_
|
||||||
|
|
||||||
|
## Using Usage Rules
|
||||||
|
|
||||||
|
Many packages have usage rules, which you should *thoroughly* consult before taking any
|
||||||
|
action. These usage rules contain guidelines and rules *directly from the package authors*.
|
||||||
|
They are your best source of knowledge for making decisions.
|
||||||
|
|
||||||
|
## Modules & functions in the current app and dependencies
|
||||||
|
|
||||||
|
When looking for docs for modules & functions that are dependencies of the current project,
|
||||||
|
or for Elixir itself, use `mix usage_rules.docs`
|
||||||
|
|
||||||
|
```
|
||||||
|
# Search a whole module
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Searching Documentation
|
||||||
|
|
||||||
|
You should also consult the documentation of any tools you are using, early and often. The best
|
||||||
|
way to accomplish this is to use the `usage_rules.search_docs` mix task. Once you have
|
||||||
|
found what you are looking for, use the links in the search results to get more detail. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<!-- usage_rules-end -->
|
<!-- usage_rules-end -->
|
||||||
<!-- usage_rules:elixir-start -->
|
<!-- usage_rules:elixir-start -->
|
||||||
## usage_rules:elixir usage
|
## usage_rules:elixir usage
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
"thousand_island": {:hex, :thousand_island, "1.4.3", "2158209580f633be38d43ec4e3ce0a01079592b9657afff9080d5d8ca149a3af", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6e4ce09b0fd761a58594d02814d40f77daff460c48a7354a15ab353bb998ea0b"},
|
"thousand_island": {:hex, :thousand_island, "1.4.3", "2158209580f633be38d43ec4e3ce0a01079592b9657afff9080d5d8ca149a3af", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6e4ce09b0fd761a58594d02814d40f77daff460c48a7354a15ab353bb998ea0b"},
|
||||||
"tidewave": {:hex, :tidewave, "0.5.5", "a125dfc87f99daf0e2280b3a9719b874c616ead5926cdf9cdfe4fcc19a020eff", [:mix], [{:circular_buffer, "~> 0.4 or ~> 1.0", [hex: :circular_buffer, repo: "hexpm", optional: false]}, {:igniter, "~> 0.6", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_live_reload, ">= 1.6.1", [hex: :phoenix_live_reload, repo: "hexpm", optional: true]}, {:plug, "~> 1.17", [hex: :plug, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}], "hexpm", "825ebb4fa20de005785efa21e5a88c04d81c3f57552638d12ff3def2f203dbf7"},
|
"tidewave": {:hex, :tidewave, "0.5.5", "a125dfc87f99daf0e2280b3a9719b874c616ead5926cdf9cdfe4fcc19a020eff", [:mix], [{:circular_buffer, "~> 0.4 or ~> 1.0", [hex: :circular_buffer, repo: "hexpm", optional: false]}, {:igniter, "~> 0.6", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_live_reload, ">= 1.6.1", [hex: :phoenix_live_reload, repo: "hexpm", optional: true]}, {:plug, "~> 1.17", [hex: :plug, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}], "hexpm", "825ebb4fa20de005785efa21e5a88c04d81c3f57552638d12ff3def2f203dbf7"},
|
||||||
"time_zone_info": {:hex, :time_zone_info, "0.7.10", "79fdfd16e70bb2e514ceff8bd81af4f0b5f46d45c8e5f6485de5ad29f8d4252a", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "abe6d744ff152788a36c2c2fce6cd007ae031c6a4c540f8d3d325f24a775aeba"},
|
"time_zone_info": {:hex, :time_zone_info, "0.7.10", "79fdfd16e70bb2e514ceff8bd81af4f0b5f46d45c8e5f6485de5ad29f8d4252a", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "abe6d744ff152788a36c2c2fce6cd007ae031c6a4c540f8d3d325f24a775aeba"},
|
||||||
"usage_rules": {:hex, :usage_rules, "1.0.2", "5980cd40e7efaeee8c777d0808b69ae33f166b86dcac12da9161acebe9b06473", [:mix], [{:igniter, ">= 0.6.6 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}], "hexpm", "71b9e59ddf23c693248e51507a46adbb20c71a39acc2ce8a6a07ea532646b021"},
|
"usage_rules": {:hex, :usage_rules, "1.1.0", "94b764a4d049846cf396bc16dcb21fd5bb11d060b91d7f53951ef790dc8b9ac6", [:mix], [{:igniter, ">= 0.6.6 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}], "hexpm", "d4a4ca02054f888474069ff2829672a6a480cb5b5b722fe8ce761450f18e0147"},
|
||||||
"vix": {:hex, :vix, "0.38.0", "77529ee4f6ced339c3d5f90a9eacf306f5b7109d3d1b5e3ef391a984ad404f75", [:make, :mix], [{:cc_precompiler, "~> 0.1.4 or ~> 0.2", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7.3 or ~> 0.8", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}], "hexpm", "dca58f654922fa678d5df8e028317483d9c0f8acb2e2714076a8468695687aa7"},
|
"vix": {:hex, :vix, "0.38.0", "77529ee4f6ced339c3d5f90a9eacf306f5b7109d3d1b5e3ef391a984ad404f75", [:make, :mix], [{:cc_precompiler, "~> 0.1.4 or ~> 0.2", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7.3 or ~> 0.8", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}], "hexpm", "dca58f654922fa678d5df8e028317483d9c0f8acb2e2714076a8468695687aa7"},
|
||||||
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
|
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
|
||||||
"websock_adapter": {:hex, :websock_adapter, "0.5.9", "43dc3ba6d89ef5dec5b1d0a39698436a1e856d000d84bf31a3149862b01a287f", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "5534d5c9adad3c18a0f58a9371220d75a803bf0b9a3d87e6fe072faaeed76a08"},
|
"websock_adapter": {:hex, :websock_adapter, "0.5.9", "43dc3ba6d89ef5dec5b1d0a39698436a1e856d000d84bf31a3149862b01a287f", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "5534d5c9adad3c18a0f58a9371220d75a803bf0b9a3d87e6fe072faaeed76a08"},
|
||||||
|
|||||||
Reference in New Issue
Block a user