# My Document


This is a very long explanation of a concept that could be much more concise. It includes redundant information and verbose descriptions that make it harder for LLMs to extract the key points efficiently.


## Key Points


- Point 1: Important information
- Point 2: More important information
```

## Implementation

[Section titled “Implementation”](#implementation)

The script demonstrates several key GenAIScript features:

### File Filtering with Accept

[Section titled “File Filtering with Accept”](#file-filtering-with-accept)

```typescript
script({
    title: "LLM-optimized content generator",
    accept: ".md,.mdx",  // Process only markdown files
    // ...
})
```

### Individual File Processing

[Section titled “Individual File Processing”](#individual-file-processing)

```typescript
// Process each file individually using runPrompt
for (const file of markdownFiles) {
    const optimizedContent = await runPrompt(
        (_) => {
            _.def("FILE_CONTENT", content)
            _.$`Generate LLM-optimized content for this file...`
        },
        {
            label: `llmstxt-optimization-${file.filename}`,
            responseType: "text"
        }
    )


    // Update file with optimized content
    writeText(file.filename, updated)
}
```

### Intelligent Content Caching

[Section titled “Intelligent Content Caching”](#intelligent-content-caching)

```typescript
// Check if file needs updating based on content hash
const currentHash = MD5(content.trim())
const existingHash = frontmatter?.llmstxtHash


if (!existingHash || existingHash !== currentHash) {
    // Process file
} else {
    console.log(`File ${f.filename} skipped (content unchanged)`)
}
```

## Schema Extension

[Section titled “Schema Extension”](#schema-extension)

For Astro Starlight projects, extend the schema to include the `llmstxt` field:

docs/src/content.config.ts

```typescript
export const collections = {
  docs: defineCollection({
    loader: docsLoader(),
    schema: docsSchema({
      extend: (context) => {
        const blog = blogSchema(context);
        return blog.extend({
          llmstxt: z.string().optional(),
          llmstxtHash: z.string().optional(),
        });
      },
    }),
  }),
};
```

## Features

[Section titled “Features”](#features)

* **Content Optimization**: Reduces content length by 30-50% while preserving essential information
* **Technical Accuracy**: Maintains technical accuracy and key terminology
* **Code Preservation**: Includes important code examples in simplified form
* **Structured Output**: Uses clear, structured format for better LLM comprehension
* **Hash-based Caching**: Avoids regenerating content when source hasn’t changed
* **Batch Processing**: Can process multiple files efficiently
* **Individual Processing**: Each file gets its own runPrompt for better error handling

## Configuration

[Section titled “Configuration”](#configuration)

The script uses these optimized settings:

* **Model**: `large` (configurable)
* **Temperature**: `0.3` (low temperature for consistent output)
* **System**: `["system", "system.files"]` (file processing capabilities)
* **Response Type**: `text` (for clean text output)

## Output Quality

[Section titled “Output Quality”](#output-quality)

The optimized content:

* Extracts core concepts and information
* Uses clear, direct language
* Simplifies complex explanations
* Focuses on actionable information
* Maintains important context
* Reduces redundancy
* Preserves technical terminology