Skip to content

oliver-kriska/claude-elixir-phoenix / targets/codex/skills/phx-investigate

phx-investigate

Verified

Investigate Elixir/Phoenix bugs root-cause first. Reproduce failures, cite evidence; Codex subagents are optional.

FileKindSize
SKILL.mdskill md4.0 KB
references/debug-commands.mdmarkdown2.0 KB
references/error-patterns.mdmarkdown1.4 KB
references/investigation-template.mdmarkdown998 B

references/debug-commands.md

View on GitHub
# Quick Debug Commands & Common Fixes

## Quick Debug Commands

Common debug commands:

- Clean rebuild: `rm -rf _build deps && mix deps.get && mix compile`
- Check module exports: `mix run -e "IO.inspect MyModule.__info__(:functions)"`
- Interactive debugging: `iex -S mix phx.server` (then `recompile()`)
- Run single test with output: `mix test test/file_test.exs:42 --trace`

## Common Fixes

### String vs Atom Keys

```elixir
# External data (JSON, params) = strings
params["key"]

# Internal data = atoms
struct.field
map.key
```

### Missing Preload

```elixir
# Before
user = Repo.get(User, id)
user.posts  # BOOM

# After
user = Repo.get(User, id) |> Repo.preload(:posts)
```

### Nil Propagation

```elixir
# Before
user.profile.name  # Crashes if profile nil

# After
case user.profile do
  nil -> nil
  profile -> profile.name
end
# Or use get_in/2
```

## Telemetry-Based Debugging

When Tidewave is unavailable, use telemetry to diagnose
performance and behavior issues:

```elixir
# Attach a temporary handler to see all Ecto queries
:telemetry.attach(
  "debug-queries",
  [:my_app, :repo, :query],
  fn _event, measurements, metadata, _config ->
    IO.puts("Query: #{metadata.query}")
    IO.puts("  Time: #{measurements.total_time / 1_000_000}ms")
  end,
  nil
)
# Detach when done: :telemetry.detach("debug-queries")
```

### Common Telemetry Events to Attach

| Event | What It Shows |
|-------|---------------|
| `[:my_app, :repo, :query]` | All Ecto queries with timing |
| `[:phoenix, :endpoint, :stop]` | Request duration |
| `[:phoenix, :router_dispatch, :stop]` | Per-route timing |
| `[:oban, :job, :stop]` | Oban job execution time |
| `[:oban, :job, :exception]` | Oban job failures |

### LiveDashboard in Dev

Add to router for real-time metrics visualization:

```elixir
if Mix.env() in [:dev, :test] do
  import Phoenix.LiveDashboard.Router

  scope "/" do
    pipe_through :browser
    live_dashboard "/dashboard",
      metrics: MyAppWeb.Telemetry
  end
end
```
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall