Skip to content

rdcstarr/docs-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docs-generator

Generate AI-optimized Markdown documentation from Laravel-ecosystem docs sites (Laravel, Flux UI, Livewire) for Claude Code, Cursor, and GitHub Copilot.

Latest Version on Packagist License

Why

When you work with AI coding assistants in Laravel projects, the model answers better when it has the official docs close at hand — sliced into small Markdown files you can load on demand. This package fetches the public docs, asks an LLM to rewrite each page as a clean, AI-friendly Markdown file, and writes it into the right folder for your IDE (.claude/, .cursor/rules/, or .github/instructions/).

Features

  • Three built-in sources: Laravel, Flux UI (with authentication for Flux Pro), and Livewire
  • Three IDE targets: Claude (with auto-sync of CLAUDE.md index), Cursor (.mdc with frontmatter), Copilot (.instructions.md)
  • Uses the native Laravel AI SDK (laravel/ai) — 10+ providers out of the box: DeepSeek, OpenAI, Anthropic, Gemini, Groq, xAI, Mistral, Ollama, Cohere, and more
  • Configurable per-project: enable only the sources you use
  • Smart retry with rate-limit backoff
  • Skip-existing with --force to regenerate
  • Filter with --only=routing,eloquent during development

Installation

composer require rdcstarr/docs-generator

Publish the Laravel AI SDK config and run its migrations (used internally by laravel/ai):

php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider"
php artisan migrate

Then publish this package's config:

php artisan vendor:publish --tag=docs-generator-config

Setup

Add the credentials for whichever AI provider and sources you use in .env. API keys are read by the Laravel AI SDK, so you can use any provider it supports:

# DeepSeek (default)
DEEPSEEK_API_KEY=sk-...

# OpenAI
OPENAI_API_KEY=sk-...

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Gemini
GEMINI_API_KEY=...

# Required only if you use the Flux UI source (for Flux Pro access)
FLUXUI_EMAIL=you@example.com
FLUXUI_PASSWORD=your-password

In config/docs-generator.php, keep only the sources you want to generate. For a plain Laravel project without Flux/Livewire:

'sources' => [
    'laravel' => [
        'driver'  => \Rdcstarr\DocsGenerator\Drivers\LaravelDriver::class,
        'version' => '13.x',
    ],
],

Usage

Generate docs for all enabled sources, for Claude (the default target):

php artisan docs:generate

Generate only one source:

php artisan docs:generate laravel
php artisan docs:generate flux
php artisan docs:generate livewire

Target Cursor or Copilot instead of Claude:

php artisan docs:generate --for=cursor
php artisan docs:generate laravel --for=copilot

Force regeneration of already-generated files:

php artisan docs:generate --force

Generate only specific pages (matches by slug, case-insensitive, substring):

php artisan docs:generate laravel --only=routing,eloquent

Use a different AI provider for this run (any key from config/docs-generator.php):

php artisan docs:generate --provider=openai
php artisan docs:generate --provider=anthropic
php artisan docs:generate --provider=gemini

Re-sync the CLAUDE.md index without generating any files:

php artisan docs:generate --sync-only
php artisan docs:generate laravel --sync-only

Output

Claude target (default)

.claude/
├── laravel/
│   ├── routing.md
│   ├── eloquent.md
│   └── ...
├── fluxui/
│   └── ...
└── livewire/
    └── ...
CLAUDE.md                ← auto-updated with per-source index sections

CLAUDE.md gets a ## Laravel / ## Flux UI / ## Livewire section listing every generated file with its H1 title, so the model can pick the right file on demand.

Cursor target

.cursor/rules/
├── laravel.routing.mdc       (with Cursor frontmatter)
├── fluxui.button.mdc
└── livewire.actions.mdc

Copilot target

.github/instructions/
├── laravel.routing.instructions.md
├── fluxui.button.instructions.md
└── livewire.actions.instructions.md

Extending

Add a new AI provider entry

Most providers you'd want are already available natively through the Laravel AI SDK (OpenAI, Anthropic, Gemini, Groq, xAI, Mistral, Ollama, Cohere, DeepSeek, …). To add another entry to config/docs-generator.php, point class at LaravelAiProvider and set the SDK provider key plus the model you want:

'providers' => [
    'groq' => [
        'class'    => \Rdcstarr\DocsGenerator\Providers\LaravelAiProvider::class,
        'provider' => 'groq',
        'model'    => env('GROQ_MODEL', 'llama-3.3-70b-versatile'),
        'timeout'  => env('GROQ_TIMEOUT', 60),
    ],
],

Then add GROQ_API_KEY=... to .env and run php artisan docs:generate --provider=groq.

Add a fully custom AI provider

If you need a service not supported by the Laravel AI SDK, implement Rdcstarr\DocsGenerator\Contracts\AIProvider:

namespace App\DocsGenerator;

use Rdcstarr\DocsGenerator\Contracts\AIProvider;

class MyCustomProvider implements AIProvider
{
    public function __construct(array $config) { /* ... */ }

    public function generate(string $prompt): ?string
    {
        // call your API, return Markdown
    }
}

Register it under providers and use it via --provider=mycustom.

Add a custom documentation source

Implement Rdcstarr\DocsGenerator\Contracts\DocsDriver — five methods:

namespace App\DocsGenerator;

use Rdcstarr\DocsGenerator\Contracts\DocsDriver;

class FilamentDriver implements DocsDriver
{
    public function __construct(array $config) { /* ... */ }

    public function name(): string          { return 'filament'; }
    public function indexSection(): string  { return '## Filament'; }
    public function discoverPages(): array  { /* fetch + parse sidebar */ }
    public function fetchPage(string $url): ?string { /* fetch + clean HTML */ }
    public function buildPrompt(string $url, string $html): string { /* prompt */ }
}

Register it under sources in the config. Helpers Rdcstarr\DocsGenerator\Support\HtmlExtractor and SidebarDiscovery are available to keep your driver small.

Add a custom IDE target

Implement Rdcstarr\DocsGenerator\Contracts\Target and register under targets.

Requirements

  • PHP 8.3+
  • Laravel 13+
  • laravel/ai (installed automatically as a dependency)

License

MIT © rdcstarr

About

Generate AI-optimized Markdown docs from Laravel-ecosystem sites for Claude, Cursor, and Copilot

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages