mcpField
L
llms-txt-generator

llms-txt-generator

github.com/testacode开发43 次安装
代码仓库

关于 llms-txt-generator

帮助开发人员为软件项目生成符合 llms.txt 标准的结构化文档。它根据项目类型和现有资料规划按领域拆分的文件,并选择脚本、静态文档或混合方式生成。

主要功能

  1. 01分析项目类型与文档资料
  2. 02规划领域文档文件结构
  3. 03选择脚本或静态文档生成方式
  4. 04生成主索引、版本信息和领域文件
  5. 05提供文档组织与格式建议

适用场景

  1. 01为前端组件库整理 AI 可读文档
  2. 02为 CLI 或 API 项目生成分领域文档
  3. 03将现有文档和结构化资料编成索引

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/testacode/llm-toolkit --skill llms-txt-generator

安装后在 Claude Code 中输入/llms-txt-generator确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
api-example.md
cli-example.md
complete-output-example.md
frontend-example.md
generator-script-pattern.md
library-example.md

详细介绍

LLM 文档生成器

遵循 llms.txt 标准生成结构化、便于 AI 阅读的文档,并按领域组织细分文件。

输出结构

llm-docs/
├── llm.txt                    # Main index (~1-2 KB)
├── llm.version.txt            # Metadata and sync info (~0.3 KB)
└── llm.{domain}.txt           # Domain-specific files (~3-50 KB each)

工作流

阶段 1:选择语言

询问用户希望文档输出使用哪种语言(英语、西班牙语或双语)。

阶段 2:分析项目

识别项目类型和数据来源:

指标项目类型
components/、设计令牌、SCSS前端/UI 库
cmd/、CLI 标志、子命令CLI 工具
/api/、OpenAPI、路由REST/GraphQL API
src/、导出、package.json通用库

检测结构化数据来源:

  • JSON 元数据文件(组件文档、OpenAPI 规范)
  • JSDoc/GoDoc 注释
  • TypeScript 定义
  • 配置文件(package.json、go.mod)
  • 现有文档(README、docs/)
阶段 3:规划领域

根据项目类型,规划要创建的 llm.{domain}.txt 文件:

  • 前端/UI:参见 references/frontend-example.md
  • CLI 工具:参见 references/cli-example.md
  • API:参见 references/api-example.md
  • 库:参见 references/library-example.md
阶段 4:决定实现方式
条件方式
存在结构化数据(JSON、JSDoc、OpenAPI)创建生成器脚本
需要手动编写文档编写静态 Markdown 文件
混合来源混合方式:用脚本处理结构化内容,其余手动编写

生成器脚本的结构请参见 references/generator-script-pattern.md。

阶段 5:生成文件
llm.version.txt(始终首先生成)
# {Project} LLM Documentation

- **Version**: {semantic version}
- **Last Updated**: {YYYY-MM-DD}
- **Documentation Version**: 1.0.0
- **Files**: {count} domain files
- **Total Size**: ~{X} KB
llm.txt(主索引)
# {Project} - LLM Documentation

## Project Metadata
- **Name**: {project name}
- **Type**: {frontend|cli|api|library}
- **Language**: {primary language}
- **Purpose**: {one-line description}

## Quick Reference
- **Key Modules**: {list main areas}
- **Patterns**: {architectural patterns used}
- **Dependencies**: {key dependencies}

## Documentation Structure

### {Domain 1}
#### llm.{domain1}.txt
- **Focus**: {what this file covers}
- **Use when**: {scenarios to read this file}

## Reading Guide

1. Start with `llm.version.txt` for metadata
2. Read `llm.{primary-domain}.txt` for core concepts
3. Reference other files as needed
llm.{domain}.txt(领域文件)

每个领域文件都遵循以下结构:

# {Domain} - {Project}

## Overview
{2-3 sentences explaining this domain}

## {Section 1}

| Name | Type | Description |
|------|------|-------------|
| ... | ... | ... |

## Related Files
- `llm.{related}.txt` - {why related}

最佳实践

  1. 文件大小:每个文件控制在 50 KB 以内,以优化大模型上下文使用效果
  2. 交叉引用:在文件之间建立链接,并明确说明“何时阅读”
  3. 表格:使用 Markdown 表格列出属性、令牌和参数
  4. 代码示例:包含实用且可直接复制粘贴的示例
  5. 层级结构:统一使用标题层级(H1 为标题,H2 为章节,H3 为小节)

完整示例请参见 references/complete-output-example.md。

评论

支持 Markdown