mix usage_rules.sync (usage_rules v1.2.5)

Copy Markdown View Source

Sync AGENTS.md and agent skills from project config

Reads the :usage_rules key from your project config in mix.exs and generates an AGENTS.md file with usage rules from your dependencies, optionally generating agent skills as well.

Configuration

Add to your mix.exs project config:

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
    # 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: [:usage_rules, :ash, {~r/^ash_/, link: :markdown}],
    # or use skills
    skills: [
      location: ".claude/skills",
      # Pull in pre-built skills shipped directly by packages
      package_skills: [:ash, ~r/^ash_/],
      # 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

Then run:

mix usage_rules.sync

The config is the source of truth — packages present in the file but absent from config are automatically removed on each sync.