# aerostack ai / index

> Context-aware AI commands that use your project's knowledge graph. Generate code, answer questions, and explain your codebase from the terminal.

AI-powered commands that use your project's knowledge graph to provide context-aware assistance.

## aerostack index

Build the Project Knowledge Graph (PKG) for your project. This indexes your codebase's symbols, routes, schemas, and relationships so the AI agent understands your specific setup.

```bash
aerostack index
```

Run this before using `aerostack ai` or `aerostack auth doctor`.

---

## aerostack ai

Ask the AI agent a question with full project context.

```bash
aerostack ai [prompt] [flags]
```

| Flag | Description |
|------|-------------|
| `--debug` | Enable debug logging |

```bash
# Ask a question
aerostack ai "Why is my auth route returning 401?"

# Debug mode
aerostack ai "Trace the request flow for POST /api/users" --debug
```

The agent uses your PKG to understand your project structure, so answers are specific to your codebase — not generic documentation responses.

Run `aerostack index` first. Without it, the agent lacks project context.

---

## aerostack auth doctor

Analyze your authentication configuration and diagnose issues.

```bash
aerostack auth doctor
```

Checks:
- Auth route configuration
- OTP and magic link setup
- JWT secret and expiry settings
- Email provider configuration

---

## Typical workflow

```bash
# 1. Index your project (do this after major changes)
aerostack index

# 2. Ask the agent
aerostack ai "How do I add rate limiting to my auth routes?"

# 3. If auth issues arise
aerostack auth doctor
```
