Skip to content
Back to skills

1540 Documentation E0b2ae27

ASecurity

```elixir defmodule MyApp.UserManager do @moduledoc """ Manages user lifecycle operations including creation, updates, and deletion.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
businessgodatabasedocumentation

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1540-documentation_e0b2ae27 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1540 Documentation E0b2ae27?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1540 Documentation E0b2ae27
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1540-documentation-e0b2ae27/badge)](https://www.skillsdirectory.com/skills/tools-only-1540-documentation-e0b2ae27)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Documentation

## Module Documentation

### @moduledoc

```elixir
defmodule MyApp.UserManager do
  @moduledoc """
  Manages user lifecycle operations including creation, updates, and deletion.

  This module provides the primary interface for user management and delegates
  to the appropriate subsystems for persistence and notification.

  ## Examples

      iex> UserManager.create(%{name: "Alice", email: "alice@example.com"})
      {:ok, %User{}}

  ## Configuration

  Requires `:user_manager` config with `:repo` key.
  """
end
```

### When to Use @moduledoc false

```elixir
# Valid uses of @moduledoc false:
# 1. Private implementation modules
defmodule MyApp.Internal.Helper do
  @moduledoc false
  # ...
end

# 2. Protocol implementations
defimpl Jason.Encoder, for: MyStruct do
  @moduledoc false
  # ...
end
```

## Function Documentation

### @doc with @spec

```elixir
@doc """
Fetches a user by their unique identifier.

Returns `{:ok, user}` if found, `{:error, :not_found}` otherwise.

## Examples

    iex> fetch_user(123)
    {:ok, %User{id: 123}}

    iex> fetch_user(-1)
    {:error, :not_found}
"""
@spec fetch_user(pos_integer()) :: {:ok, User.t()} | {:error, :not_found}
def fetch_user(id) when is_integer(id) and id > 0 do
  # ...
end
```

### @spec Patterns

```elixir
# Basic types
@spec add(integer(), integer()) :: integer()

# Union types
@spec parse(String.t()) :: {:ok, map()} | {:error, term()}

# Custom types
@type result :: {:ok, t()} | {:error, reason()}
@spec fetch(id()) :: result()

# Keyword options
@spec start_link(keyword()) :: GenServer.on_start()

# When clauses for type variables
@spec map(list(a), (a -> b)) :: list(b) when a: term(), b: term()
```

## Doctests

### When to Use

```elixir
# GOOD - pure function, predictable output
@doc """
Calculates the factorial of n.

## Examples

    iex> Math.factorial(0)
    1

    iex> Math.factorial(5)
    120
"""
def factorial(0), do: 1
def factorial(n), do: n * factorial(n - 1)
```

### When NOT to Use

```elixir
# BAD - side effects, unpredictable
@doc """
Creates a user in the database.

## Examples

    iex> create_user(%{name: "Test"})  # Don't doctest DB operations!
    {:ok, %User{}}
"""
```

## Review Questions

1. Do all public modules have @moduledoc?
2. Do all public functions have @doc and @spec?
3. Are doctests used for pure, deterministic functions?
4. Do @specs accurately reflect function signatures?

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.