npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

llmstxt-gen

v0.1.0-beta.1

Published

Generate LLMS.txt for your website

Readme

LLMSTXT-GEN

Generate LLMS.txt for your website - A universal library for creating AI-friendly site documentation.

🚀 Features

  • Framework Agnostic: Works with Astro, Next.js, and static sites
  • Multiple Entry Points: Core library, framework integrations, and CLI
  • TypeScript Support: Full type safety and IntelliSense
  • Flexible Configuration: Customizable content extraction and formatting
  • CLI Tool: Generate LLMS.txt from command line
  • Dynamic & Static: Support for both build-time and runtime generation

📦 Installation

npm install llmstxt-gen

🔧 Quick Start

CLI Usage

# Initialize configuration
npx llms init

# Generate LLMS.txt
npx llms generate --site https://your-site.com

# Generate with custom config
npx llms generate --config llms.config.js

Astro Integration

// astro.config.mjs
import { defineConfig } from 'astro/config';
import llms from 'llmstxt-gen/astro';

export default defineConfig({
  site: 'https://your-site.com',
  integrations: [
    llms({
      pages: ['src/pages/**/*.md', 'src/pages/**/*.astro'],
      exclude: ['src/pages/admin/**/*'],
      customFields: {
        title: (page) => page.frontmatter?.title,
        description: (page) => page.frontmatter?.description,
      },
    }),
  ],
});

Next.js Integration

Using Webpack Plugin

// next.config.js
const { withLLMS } = require('llmstxt-gen/nextjs');

module.exports = withLLMS({
  // Your Next.js config
  llms: {
    site: 'https://your-site.com',
    pages: ['pages/**/*.md', 'content/**/*.md'],
  },
});

API Route (Pages Router)

// pages/api/llms.txt.js
import { nextjsUtils } from 'llmstxt-gen/nextjs';

export default nextjsUtils.createApiRoute({
  site: 'https://your-site.com',
  pages: ['pages/**/*.md', 'content/**/*.md'],
});

Route Handler (App Router)

// app/llms.txt/route.js
import { nextjsUtils } from 'llmstxt-gen/nextjs';

export const GET = nextjsUtils.createRouteHandler({
  site: 'https://your-site.com',
  pages: ['app/**/*.md', 'content/**/*.md'],
});

Core Library Usage

import { LLMS } from 'llmstxt-gen';

const llms = new LLMS({
  site: 'https://your-site.com',
  pages: ['**/*.md', '**/*.html'],
  exclude: ['node_modules/**/*'],
  customFields: {
    title: (page) => page.frontmatter?.title || page.metadata?.title,
    description: (page) => page.frontmatter?.description,
    content: (page) => page.content,
  },
});

// Generate LLMS.txt content
const output = await llms.generate();
console.log(llms.formatAsString(output));

// Generate and save to file
const filePath = await llms.generateAndSave();
console.log(`Generated: ${filePath}`);

⚙️ Configuration

Configuration File (llms.config.js)

module.exports = {
  site: 'https://your-site.com',
  pages: [
    'src/pages/**/*.md',
    'src/pages/**/*.astro',
    'content/**/*.md',
  ],
  exclude: [
    'src/pages/admin/**/*',
    'src/pages/api/**/*',
    'node_modules/**/*',
  ],
  customFields: {
    title: (page) => page.frontmatter?.title || page.metadata?.title,
    description: (page) => page.frontmatter?.description,
    content: (page) => page.content,
    author: (page) => page.frontmatter?.author,
  },
  output: 'static', // 'static' or 'dynamic'
  outputPath: 'public/llms.txt',
  siteName: 'Your Site Name',
  maxContentLength: 2000,
  includeMetadata: true,
};

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | site | string | required | Base URL of your site | | pages | string[] | auto-detected | Glob patterns for pages to include | | exclude | string[] | [] | Glob patterns for pages to exclude | | customFields | object | {} | Custom field extractors | | output | 'static' \| 'dynamic' | 'static' | Generation mode | | outputPath | string | 'llms.txt' | Output file path | | siteName | string | extracted from site | Site name for LLMS.txt header | | maxContentLength | number | 2000 | Maximum content length per page | | includeMetadata | boolean | true | Include page metadata |

🎯 CLI Commands

llms generate

Generate LLMS.txt file.

npx llms generate [options]

Options:

  • -c, --config <path> - Configuration file path (default: llms.config.js)
  • -o, --output <path> - Output file path (default: llms.txt)
  • -s, --site <url> - Site URL
  • -d, --dir <path> - Base directory to scan (default: current directory)
  • --dry-run - Print output without writing file

llms init

Create a configuration file.

npx llms init [options]

Options:

  • -f, --framework <framework> - Target framework (astro|nextjs|static)

llms validate

Validate configuration file.

npx llms validate [options]

Options:

  • -c, --config <path> - Configuration file path

📄 LLMS.txt Format

The generated LLMS.txt follows this structure:

# LLMS.txt for Your Site

Site: https://your-site.com
Generated: 2023-01-01T00:00:00.000Z

## Pages

### Page Title
URL: https://your-site.com/page
Description: Page description
Content: Extracted page content...

---

### Another Page
URL: https://your-site.com/another
Description: Another page description
Content: More extracted content...

🔌 Framework-Specific Features

Astro

  • Automatic integration with Astro's build process
  • Support for .astro, .md, and .mdx files
  • Frontmatter extraction
  • Build-time generation

Next.js

  • Support for both Pages Router and App Router
  • Dynamic API routes for runtime generation
  • Webpack plugin for build-time generation
  • MDX and Markdown support
  • Automatic framework detection

Static Sites

  • Universal file format support
  • Flexible glob patterns
  • CLI-based generation
  • Custom content extractors

🧪 Testing

# Run tests
npm test

# Watch mode
npm run test:watch

# Coverage
npm test -- --coverage

🛠️ Development

# Clone the repository
git clone https://github.com/yourusername/llms.git
cd llms

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Lint code
npm run lint

📚 Examples

Check the /examples directory for complete implementation examples:

🤝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

📄 License

MIT License - see LICENSE file for details.

🔗 Links

💡 What is LLMS.txt?

LLMS.txt is a proposed standard for helping AI systems understand website content structure. It provides a structured way to present your site's content to large language models, making it easier for AI to understand and work with your content.

Learn more about the LLMS.txt standard at llmstxt.org.