# Send Phoenix API Generator to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "phoenix-api-gen",
    "name": "Phoenix API Generator",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/gchapim/phoenix-api-gen",
    "canonicalUrl": "https://clawhub.ai/gchapim/phoenix-api-gen",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/phoenix-api-gen",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=phoenix-api-gen",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "references/test-patterns.md",
      "references/phoenix-conventions.md",
      "references/ecto-patterns.md",
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "phoenix-api-gen",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T01:55:47.500Z",
      "expiresAt": "2026-05-14T01:55:47.500Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=phoenix-api-gen",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=phoenix-api-gen",
        "contentDisposition": "attachment; filename=\"phoenix-api-gen-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "phoenix-api-gen"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/phoenix-api-gen"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/phoenix-api-gen",
    "downloadUrl": "https://openagent3.xyz/downloads/phoenix-api-gen",
    "agentUrl": "https://openagent3.xyz/skills/phoenix-api-gen/agent",
    "manifestUrl": "https://openagent3.xyz/skills/phoenix-api-gen/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/phoenix-api-gen/agent.md"
  }
}
```
## Documentation

### From OpenAPI YAML

Parse the OpenAPI spec — extract paths, schemas, request/response bodies.
Map each schema to an Ecto schema + migration.
Map each path to a controller action; group by resource context.
Generate auth plugs from securitySchemes.
Generate ExUnit tests covering happy path + validation errors.

### From Natural Language

Extract resources, fields, types, and relationships from the description.
Infer context boundaries (group related resources).
Generate schemas, migrations, controllers, views, router, and tests.
Ask the user to confirm before writing files.

### File Generation Order

Migrations (timestamps prefix: YYYYMMDDHHMMSS)
Ecto schemas + changesets
Context modules (CRUD functions)
Controllers + FallbackController
JSON renderers (Phoenix 1.7+ *JSON modules, or *View for older)
Router scope + pipelines
Auth plugs
Tests + factories

### Phoenix Conventions

See references/phoenix-conventions.md for project structure, naming, context patterns.

Key rules:

One context per bounded domain (e.g., Accounts, Billing, Notifications).
Context is the public API — controllers never call Repo directly.
Schemas live under contexts: MyApp.Accounts.User.
Controllers delegate to contexts; return {:ok, resource} or {:error, changeset}.
Use FallbackController with action_fallback/1 to handle error tuples.

### Ecto Patterns

See references/ecto-patterns.md for schema, changeset, migration details.

Key rules:

Always use timestamps(type: :utc_datetime_usec).
Binary IDs: @primary_key {:id, :binary_id, autogenerate: true} + @foreign_key_type :binary_id.
Separate create_changeset/2 and update_changeset/2 when create/update fields differ.
Validate required fields, formats, and constraints in changesets — not in controllers.

### Multi-Tenancy

Add tenant_id :binary_id to every tenant-scoped table. Pattern:

# In context
def list_resources(tenant_id) do
  Resource
  |> where(tenant_id: ^tenant_id)
  |> Repo.all()
end

# In plug — extract tenant from conn and assign
defmodule MyAppWeb.Plugs.SetTenant do
  import Plug.Conn
  def init(opts), do: opts
  def call(conn, _opts) do
    tenant_id = get_req_header(conn, "x-tenant-id") |> List.first()
    assign(conn, :tenant_id, tenant_id)
  end
end

Always add a composite index on [:tenant_id, <resource_id or lookup field>].

### API Key

defmodule MyAppWeb.Plugs.ApiKeyAuth do
  import Plug.Conn
  def init(opts), do: opts
  def call(conn, _opts) do
    with [key] <- get_req_header(conn, "x-api-key"),
         {:ok, account} <- Accounts.authenticate_api_key(key) do
      assign(conn, :current_account, account)
    else
      _ -> conn |> send_resp(401, "Unauthorized") |> halt()
    end
  end
end

### Bearer Token

defmodule MyAppWeb.Plugs.BearerAuth do
  import Plug.Conn
  def init(opts), do: opts
  def call(conn, _opts) do
    with ["Bearer " <> token] <- get_req_header(conn, "authorization"),
         {:ok, claims} <- MyApp.Token.verify(token) do
      assign(conn, :current_user, claims)
    else
      _ -> conn |> send_resp(401, "Unauthorized") |> halt()
    end
  end
end

### Router Structure

scope "/api/v1", MyAppWeb do
  pipe_through [:api, :authenticated]

  resources "/users", UserController, except: [:new, :edit]
  resources "/teams", TeamController, except: [:new, :edit] do
    resources "/members", MemberController, only: [:index, :create, :delete]
  end
end

### Test Generation

See references/test-patterns.md for ExUnit, Mox, factory patterns.

Key rules:

Use async: true on all tests that don't share state.
Use Ecto.Adapters.SQL.Sandbox for DB isolation.
Factory module using ex_machina or hand-rolled build/1, insert/1.
Test contexts and controllers separately.
For controllers: test status codes, response body shape, and error cases.
Mock external services with Mox — define behaviours, set expectations in test.

### Controller Test Template

defmodule MyAppWeb.UserControllerTest do
  use MyAppWeb.ConnCase, async: true

  import MyApp.Factory

  setup %{conn: conn} do
    user = insert(:user)
    conn = put_req_header(conn, "authorization", "Bearer #{token_for(user)}")
    {:ok, conn: conn, user: user}
  end

  describe "index" do
    test "lists users", %{conn: conn} do
      conn = get(conn, ~p"/api/v1/users")
      assert %{"data" => users} = json_response(conn, 200)
      assert is_list(users)
    end
  end

  describe "create" do
    test "returns 201 with valid params", %{conn: conn} do
      params = params_for(:user)
      conn = post(conn, ~p"/api/v1/users", user: params)
      assert %{"data" => %{"id" => _}} = json_response(conn, 201)
    end

    test "returns 422 with invalid params", %{conn: conn} do
      conn = post(conn, ~p"/api/v1/users", user: %{})
      assert json_response(conn, 422)["errors"] != %{}
    end
  end
end

### JSON Renderer (Phoenix 1.7+)

defmodule MyAppWeb.UserJSON do
  def index(%{users: users}), do: %{data: for(u <- users, do: data(u))}
  def show(%{user: user}), do: %{data: data(user)}

  defp data(user) do
    %{
      id: user.id,
      email: user.email,
      inserted_at: user.inserted_at
    }
  end
end

### Checklist Before Writing

Migrations use timestamps(type: :utc_datetime_usec)
 Binary IDs configured if project uses UUIDs
 Tenant scoping applied where needed
 Auth plug wired in router pipeline
 FallbackController handles {:error, changeset} and {:error, :not_found}
 Tests cover 200, 201, 404, 422 status codes
 Factory defined for each schema
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: gchapim
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-07T01:55:47.500Z
- Expires at: 2026-05-14T01:55:47.500Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/phoenix-api-gen)
- [Send to Agent page](https://openagent3.xyz/skills/phoenix-api-gen/agent)
- [JSON manifest](https://openagent3.xyz/skills/phoenix-api-gen/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/phoenix-api-gen/agent.md)
- [Download page](https://openagent3.xyz/downloads/phoenix-api-gen)