# `Agentic.AgentFS.Materializer`

Behaviour for materializing skills and memories into the agent's filesystem.

Host applications implement this behaviour and pass the module via
`ctx.metadata[:agent_fs_materializer]`.

## Usage

    defmodule MyApp.AgentFS.Materializer do
      @behaviour Agentic.AgentFS.Materializer

      @impl true
      def materialize_skills(opts) do
        # Return list of %{name: ..., content: ...}
      end

      @impl true
      def materialize_memories(opts) do
        # Return string of formatted memory content
      end

      @impl true
      def sync_back_skills(skills_data, opts) do
        # Persist agent-created skills
      end

      @impl true
      def sync_back_memories(memory_content, opts) do
        # Persist agent-created memories
      end
    end

# `opts`

```elixir
@type opts() :: keyword()
```

# `skill_data`

```elixir
@type skill_data() :: %{name: String.t(), content: String.t()}
```

# `skills_data`

```elixir
@type skills_data() :: [skill_data()]
```

# `materialize_memories`

```elixir
@callback materialize_memories(opts()) :: String.t()
```

Materialize memories for the agent filesystem.

Returns a string that will be written to `<memory_path>/MEMORY.md`.

# `materialize_skills`

```elixir
@callback materialize_skills(opts()) :: skills_data()
```

Materialize skills for the agent filesystem.

Returns a list of `%{name: ..., content: ...}` maps. Each skill will be
written as `<skill_path>/<name>/SKILL.md` in the overlay.

# `sync_back_memories`

```elixir
@callback sync_back_memories(String.t(), opts()) :: :ok
```

Sync back memories modified by the agent.

`memory_content` is the full text of the memory file after the session.

# `sync_back_skills`

```elixir
@callback sync_back_skills(skills_data(), opts()) :: :ok
```

Sync back skills created by the agent.

`skills_data` is a list of `%{name: ..., content: ..., is_new: bool}` maps
for skills that were modified or created during the session.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
