# LLM Prompt Generation

Writes application prompts and generation calls with model selection and tracing.

- Repository: https://github.com/lobehub/lobehub (83676 stars)
- Category: AI and agents
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add lobehub/lobehub --skill llm-generation -g -a claude-code -y`
Codex: `npx skills add lobehub/lobehub --skill llm-generation -g -a codex -y`
Cursor: `npx skills add lobehub/lobehub --skill llm-generation -g -a cursor -y`
Gemini CLI: `npx skills add lobehub/lobehub --skill llm-generation -g -a gemini-cli -y`

## Description

Use for application prompts, generateObject/generateText, model selection and generation tracing. Excludes provider adapters and agent snapshots.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# LLM Generation

Implement business-facing LLM calls as explicit, independently observable workflows. Keep prompt identity, model policy, structured output, and tracing responsibilities separate.

## Locate the Existing Boundary

Before editing a call, inspect:

- `packages/prompts` for reusable application prompts;
- `apps/server/src/services/aiGeneration` for the server-side structured generation wrapper;
- `packages/const/src/llmGenerationTracing.ts` for scenario names;
- `packages/llm-generation-tracing` for tracing option and registry behavior;
- the owning service for model configuration and business-specific schemas.

Use `agent-tracing` for execution-snapshot diagnosis and `agent-runtime-hooks` for lifecycle hook behavior. Neither owns application LLM generation conventions.

## Prompt Ownership and Versioning

- Put a reusable generation contract in `packages/prompts/src/chains`: the message builder, JSON schema, schema name, and prompt version should be exported together. Do not leave substantial system prompts or model-facing input serialization embedded in a service.
- Keep execution concerns in the owning server service: model configuration, `AiGenerationService`, tracing entity IDs, Zod validation, persistence, and business error handling do not belong in the prompt chain.
- Keep each `*_PROMPT_VERSION` beside the prompt it versions and export both from the same module.
- Format versions as `v<major>` or `v<major>.<minor>`, for example `v1` or `v1.2`.
- Store only the version in `promptVersion`. Do not include a feature or scenario prefix such as `expertise-ingestion-v1`; `scenario` carries workflow identity.
- Bump the version whenever a prompt or output contract changes in a way that should create a separate evaluation or tracing cohort.

```ts
export const EXAMPLE_PROMPT_VERSION = 'v1';

export const EXAMPLE_SYSTEM_PROMPT = `...`;
```

## Scenario Semantics

The rest: https://github.com/lobehub/lobehub/blob/HEAD/.agents/skills/llm-generation/SKILL.md
