{"data":{"slug":"github-lobehub-lobehub-agents-skills-llm-generation-5dec9fafbf05","title":"LLM Generation for Business Workflows","summary":"Implement business-facing LLM calls as explicit, independently observable workflows with prompt versioning, scenario semantics, and structured output validation. Deliverables include versioned prompts, scenario-specific tracing, and validated JSON schemas.","url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-llm-generation-5dec9fafbf05","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-lobehub-lobehub-agents-skills-llm-generation-5dec9fafbf05","markdown_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-llm-generation-5dec9fafbf05.md","download_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-llm-generation-5dec9fafbf05\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before adding a call, check `TRACING_SCENARIOS` and ensure the scenario aligns with the user-visible workflow and lifecycle stage. Pass `schemaName` for structured generation and relevant entity IDs when available. Use `packages\/prompts` for reusable prompts and `apps\/server\/src\/services\/aiGeneration` for server-side structured generation.","instructions":"---\nname: llm-generation\ndescription: 'Use for application prompts, generateObject\/generateText, model selection and generation tracing. Excludes provider adapters and agent snapshots.'\n---\n\n# LLM Generation\n\nImplement business-facing LLM calls as explicit, independently observable workflows. Keep prompt identity, model policy, structured output, and tracing responsibilities separate.\n\n## Locate the Existing Boundary\n\nBefore editing a call, inspect:\n\n- `packages\/prompts` for reusable application prompts;\n- `apps\/server\/src\/services\/aiGeneration` for the server-side structured generation wrapper;\n- `packages\/const\/src\/llmGenerationTracing.ts` for scenario names;\n- `packages\/llm-generation-tracing` for tracing option and registry behavior;\n- the owning service for model configuration and business-specific schemas.\n\nUse `agent-tracing` for execution-snapshot diagnosis and `agent-runtime-hooks` for lifecycle hook behavior. Neither owns application LLM generation conventions.\n\n## Prompt Ownership and Versioning\n\n- 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.\n- 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.\n- Keep each `*_PROMPT_VERSION` beside the prompt it versions and export both from the same module.\n- Format versions as `v<major>` or `v<major>.<minor>`, for example `v1` or `v1.2`.\n- Store only the version in `promptVersion`. Do not include a feature or scenario prefix such as `expertise-ingestion-v1`; `scenario` carries workflow identity.\n- Bump the version whenever a prompt or output contract changes in a way that should create a separate evaluation or tracing cohort.\n\n```ts\nexport const EXAMPLE_PROMPT_VERSION = 'v1';\n\nexport const EXAMPLE_SYSTEM_PROMPT = `...`;\n```\n\n## Scenario Semantics\n\nTreat `scenario` as the stable product workflow and lifecycle-stage partition, not as a label for a prompt, schema, model, or helper.\n\n- Check `TRACING_SCENARIOS` before adding a call.\n- Reuse a scenario only for the same user-visible workflow and lifecycle stage.\n- Add a scenario when the business action differs, even if another call shares its prompt or JSON schema. Editable goal-criteria drafting and run-time verification planning are different scenarios.\n- Never borrow a nearby scenario as a placeholder. Doing so contaminates latency, cost, success-rate, and quality data.\n- Pass `schemaName` for structured generation and relevant entity IDs when available.\n\n## Model Policy\n\n- Resolve the model and provider through the owning service's configuration policy. Do not silently inherit an unrelated chat model.\n- When a workflow requires a stable service model, give it an explicit default and expose the corresponding service-model configuration instead of hardcoding the model only at the call site.\n- Keep model choice separate from prompt version. Changing a configured model does not rename the prompt or scenario.\n- Prefer the shared server generation service when it fits the call so runtime initialization, routing, and tracing remain consistent.\n\n## Structured Generation\n\n- Give each JSON schema a stable, workflow-appropriate name.\n- Keep prompt instructions and schema requirements aligned; required fields in one must be supplied by the other.\n- Validate generated content at the service boundary and preserve the owning service's fallback\/error behavior.\n- Do not reuse a schema name to justify reusing an unrelated tracing scenario.\n\n## Verification\n\nFor every new or corrected generation workflow:\n\n1. Assert the emitted `scenario`, `promptVersion`, and `schemaName` where applicable.\n2. Test the prompt's important behavioral constraints without snapshotting the entire prose.\n3. Test structured-output validation and relevant failure behavior.\n4. Search for stale inline prompts, old version strings, and incorrectly reused scenarios.\n5. Run `bun run check <changed-files...>` and `bun run check --type` for cross-package changes.\n\nUse the `testing` skill for test mechanics and the `typescript` skill for TypeScript changes.\n","use_cases":["Generate customer support responses with versioned prompts and structured output validation.","Create marketing copy with scenario-based tracing and model policy enforcement.","Validate structured output for sales lead generation with prompt versioning."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lobehub\/lobehub\/blob\/54382b5c8e81544da454fa6d7b50f461a562c1ee\/.agents\/skills\/llm-generation\/SKILL.md","source_commit":"54382b5c8e81544da454fa6d7b50f461a562c1ee","license":null,"version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T11:17:59.000000Z","updated_at":"2026-11-22T11:17:05.000000Z","seo_title":"LLM Generation for Business Workflows","seo_description":"Implement business-facing LLM calls with structured output, prompt versioning, and scenario semantics for reliable and traceable workflows.","seo_keywords":["LLM generation workflow","structured output validation","prompt versioning","scenario tracing","business LLM integration"]}}