---
name: bootstrap-docs
description: Analyze repository and generate documentation. Reads docType from docs.json config, or asks if not set.
---

## Instructions

When bootstrapping documentation from a repository:

### Step 1: Detect Project Structure

Determine where you are:

**If `docs.json` exists in current directory:**
- You're in a DevDoc docs folder
- Source code is likely in `../` (parent directory)

**If `package.json` and `src/` exist:**
- You're at repo root
- Create docs in `./docs/` subfolder

**If neither matches:**
- Ask user for the source code path

### Step 2: Check for docType Configuration

**Read `docs.json` and check for `docType` field:**

```json
{
  "name": "Project Name",
  "docType": "api",  // "internal" | "api" | "product"
  ...
}
```

**If `docType` is set:**
- Use that value automatically
- Tell user: "Using docType: {type} from docs.json"

**If `docType` is NOT set, ask the user:**

"What type of documentation are you creating?

1. **internal** - For your team: setup guides, architecture, contribution guidelines
2. **api** - For developers using your product: API reference, SDKs, integration guides
3. **product** - For end users: feature guides, tutorials, FAQs"

**IMPORTANT: After user answers, immediately update docs.json:**

Add the `docType` field to docs.json so it's saved for future use:

```json
{
  "name": "Project Name",
  "docType": "api",  // Save their choice here
  "navigation": { ... }
}
```

Tell user: "Saved docType: {type} to docs.json - you won't be asked again."

### Step 3: Analyze Repository

Scan the source code for:
- `README.md` - Project overview
- `package.json` / `Cargo.toml` / `pyproject.toml` - Dependencies, metadata
- `src/` or `lib/` - Source code structure
- `api/` or `routes/` - API endpoints
- `openapi.json` / `swagger.yaml` - API specs
- `schema.graphql` - GraphQL schemas

### Step 4: Generate Based on docType

---

## docType: "internal"

For internal team documentation, create:

```
docs/
├── docs.json
├── index.mdx              # Project overview
├── getting-started/
│   ├── setup.mdx          # Dev environment setup
│   ├── prerequisites.mdx  # Required tools/versions
│   └── first-contribution.mdx
├── architecture/
│   ├── overview.mdx       # System architecture
│   ├── folder-structure.mdx
│   └── decisions.mdx      # ADRs, design decisions
├── development/
│   ├── workflow.mdx       # Git workflow, PR process
│   ├── testing.mdx        # How to run/write tests
│   ├── debugging.mdx      # Common issues, debugging tips
│   └── deployment.mdx     # How to deploy
├── api/                   # Internal API docs (if applicable)
│   └── ...
└── contributing.mdx       # Contribution guidelines
```

**Content focus:**
- How to set up local development
- Codebase architecture and patterns
- Internal APIs and services
- Debugging and troubleshooting
- Team conventions and standards

---

## docType: "api"

For external developers using your API/SDK, create:

```
docs/
├── docs.json
├── index.mdx              # Product intro, value prop
├── quickstart.mdx         # 5-minute getting started
├── authentication.mdx     # Auth setup (API keys, OAuth)
├── guides/
│   ├── overview.mdx       # Concepts overview
│   └── {use-case}.mdx     # Common use case tutorials
├── api-reference/
│   ├── introduction.mdx   # API overview, base URL, versioning
│   ├── authentication.mdx # Auth details
│   ├── errors.mdx         # Error codes and handling
│   └── openapi.json       # Full API spec
├── sdks/                  # If SDKs exist
│   ├── javascript.mdx
│   ├── python.mdx
│   └── ...
├── webhooks.mdx           # If webhooks exist
└── changelog.mdx          # API changelog
```

**Content focus:**
- Quick time-to-first-API-call
- Authentication and authorization
- API reference with examples
- SDKs and client libraries
- Error handling and troubleshooting
- Rate limits and best practices

---

## docType: "product"

For end users of your product, create:

```
docs/
├── docs.json
├── index.mdx              # Product overview
├── getting-started/
│   ├── quickstart.mdx     # First steps
│   ├── account-setup.mdx  # Account creation, onboarding
│   └── key-concepts.mdx   # Core concepts explained
├── features/
│   ├── {feature-1}.mdx    # Feature guides
│   ├── {feature-2}.mdx
│   └── ...
├── tutorials/
│   ├── {workflow-1}.mdx   # Step-by-step tutorials
│   └── ...
├── integrations/          # If integrations exist
│   └── ...
├── troubleshooting/
│   ├── common-issues.mdx
│   └── faq.mdx
└── release-notes.mdx      # What's new
```

**Content focus:**
- Non-technical language (minimal code)
- Screenshots and visual guides
- Step-by-step tutorials
- Use case focused
- FAQs and troubleshooting
- Feature explanations

---

## docs.json Templates (with docType)

### Internal Docs
```json
{
  "name": "{Project Name}",
  "docType": "internal",
  "navigation": {
    "tabs": [
      {
        "tab": "Documentation",
        "groups": [
          { "group": "Getting Started", "pages": ["index", "getting-started/setup", "getting-started/prerequisites"] },
          { "group": "Architecture", "pages": ["architecture/overview", "architecture/folder-structure"] },
          { "group": "Development", "pages": ["development/workflow", "development/testing", "development/deployment"] },
          { "group": "Contributing", "pages": ["contributing"] }
        ]
      }
    ]
  }
}
```

### Customer API Docs
```json
{
  "name": "{Product Name}",
  "docType": "api",
  "navigation": {
    "tabs": [
      {
        "tab": "Guides",
        "groups": [
          { "group": "Getting Started", "pages": ["index", "quickstart", "authentication"] },
          { "group": "Guides", "pages": ["guides/overview"] }
        ]
      },
      {
        "tab": "API Reference",
        "type": "openapi",
        "spec": "api-reference/openapi.json"
      }
    ]
  }
}
```

### Product Docs
```json
{
  "name": "{Product Name}",
  "docType": "product",
  "navigation": {
    "tabs": [
      {
        "tab": "Documentation",
        "groups": [
          { "group": "Getting Started", "pages": ["index", "getting-started/quickstart", "getting-started/key-concepts"] },
          { "group": "Features", "pages": ["features/..."] },
          { "group": "Tutorials", "pages": ["tutorials/..."] },
          { "group": "Help", "pages": ["troubleshooting/common-issues", "troubleshooting/faq"] }
        ]
      }
    ]
  }
}
```

## Quality Guidelines

- Extract real code examples, don't fabricate
- Match tone to audience (technical vs non-technical)
- Add TODO markers for sections needing human review
- Include relevant screenshots for product docs
- Test all code examples work
