Skip to content
Productivity
Skill

/llm

Guidelines for implementing LLM (Language Model) functionality in the application

From plugin
inbox-zero
13k26 skills2 agents

Claude Code

$ npx -y skills add elie222/inbox-zero --skill llm --agent claude-code

SKILL.md

llm.SKILL.md
name: llm
description: Guidelines for implementing LLM (Language Model) functionality in the application

LLM Implementation Guidelines

Directory Structure

LLM-related code is organized in specific directories:

  • `apps/web/utils/ai/` - Main LLM implementations
  • `apps/web/utils/llms/` - Core LLM utilities and configurations
  • `apps/web/__tests__/` - LLM-specific tests

Key Files

  • `utils/llms/index.ts` - Core LLM functionality
  • `utils/llms/model.ts` - Model definitions and configurations
  • `utils/llms/use-cases.ts` - Product use-case to model-role routing
  • `utils/usage.ts` - Usage tracking and monitoring

Model Routing

For product features with a static model choice, use `getModelForUseCase(emailAccount.user, LlmUseCase.FeatureName)` from `utils/llms/use-cases.ts`. Keep direct `getModel(user, modelType)` calls for generic helpers where the model role is intentionally passed from upstream. When adding or changing a use case, update `utils/llms/use-cases.test.ts`.

Implementation Pattern

Follow this standard structure for LLM-related functions:

import { z } from "zod";
import { createScopedLogger } from "@/utils/logger";
import { chatCompletionObject } from "@/utils/llms";
import type { EmailAccountWithAI } from "@/utils/llms/types";
import { createGenerateObject } from "@/utils/llms";
import { getModelForUseCase, LlmUseCase } from "@/utils/llms/use-cases";

export async function featureFunction(options: {
  inputData: InputType;
  emailAccount: EmailAccountWithAI;
}) {
  const { inputData, user } = options;

  if (!inputData || [other validation conditions]) {
    logger.warn("Invalid input for feature function");
    return null;
  }

  const system = `[Detailed system prompt that defines the LLM's role and task]`;

  const prompt = `[User prompt with context and specific instructions]

<data>
...
</data>

${emailAccount.about ? `<user_info>${emailAccount.about}</user_info>` : ""}`;

  const modelOptions = getModelForUseCase(
    emailAccount.user,
    LlmUseCase.FeatureName,
  );

  const generateObject = createGenerateObject({
    userEmail: emailAccount.email,
    label: "Feature Name",
    modelOptions,
  });


  const result = await generateObject({
    ...modelOptions,
    system,
    prompt,
    schema: z.object({
      field1: z.string(),
      field2: z.number(),
      nested: z.object({
        subfield: z.string(),
      }),
      array_field: z.array(z.string()),
    }),
  });

  return result.object;
}

Best Practices

1. **System and User Prompts**:

  • Keep system prompts and user prompts separate
  • System prompt should define the LLM's role and task specifications
  • User prompt should contain the actual data and context

2. **Schema Validation**:

  • Always define a Zod schema for response validation
  • Make schemas as specific as possible to guide the LLM output

3. **Logging**:

  • Use descriptive scoped loggers for each feature
  • Log inputs and outputs with appropriate log levels
  • Include relevant context in log messages

4. **Error Handling**:

  • Implement early returns for invalid inputs
  • Use proper error types and logging
  • Implement fallbacks for AI failures
  • Add retry logic for transient failures using `withRetry`

5. **Input Formatting**:

  • Use XML-like tags to structure data in prompts
  • Remove excessive whitespace and truncate long inputs
  • Format data consistently across similar functions

6. **Type Safety**:

  • Use TypeScript types for all parameters and return values
  • Define clear interfaces for complex input/output structures

7. **Code Organization**:

  • Keep related AI functions in the same file or directory
  • Extract common patterns into utility functions
  • Document complex AI logic with clear comments

8. **AI-First Behavior**:

  • Prefer generic prompt instructions, structured outputs, and model choice over brittle lexical heuristics that imitate model reasoning
  • Only add deterministic filters when the product truly needs a hard rule outside the model
  • Do not add prompt examples that closely mirror eval fixtures just to make a test pass

9. **Draft Attribution Versioning**:

  • When changing draft-generation prompt inputs, retrieval context, model routing behavior, or post-processing, bump `apps/web/utils/ai/reply/draft-attribution.ts` `DRAFT_PIPELINE_VERSION`
  • Do not bump it for behavior-preserving refactors that keep the same prompt, context, model role, and output processing
  • Treat that version as analytics attribution for reply-draft quality comparisons

10. **Drafts Answer as the User**:

  • The user knows their own business, so a gap in the model's context must never surface as the user not knowing: no hedges, "not sure", "I'll check and get back", or handing the request to someone on Cc. State the most likely answer and lower the confidence instead
  • Say a matter is open only when the thread itself shows it (the user said they would check, or it waits on someone else)
  • Draft eval criteria should fail non-answers and only fail invented specifics such as amounts, dates, or terms. Check changes with `__tests__/eval/draft-reply-voice.test.ts`

Testing

See [llm-test.mdc](mdc:.cursor/rules/llm-test.mdc)

Read more
@elie222
Ships withinbox-zero

The world's best AI personal assistant for email. Open source app to help you reach inbox zero fast.

13k26 skills2 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
13.1k
Star history of elie222/inbox-zero on GitHub, a chart by star-history.com

Other skills on inbox-zero.

agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…

@elie222@elie222Install Skill
code-simplifier

code-simplifier

Simplify and refine recently modified code for clarity, consistency, and maintainability while preserving exact behavior. Use…

@elie222@elie222Install Skill
create-pr

create-pr

Review the working tree, commit it safely, and open a GitHub pull request. Use when the user asks to create, open, raise, or…

@elie222@elie222Install Skill
e2e

e2e

Run and debug E2E flow tests. Use when triggering E2E tests, checking test status, debugging failures with Axiom logs, or setting…

@elie222@elie222Install Skill

More skills from other plugins.

i-have-adhd

i-have-adhd

Shape output for a reader with ADHD: lead with the next action, number multi-step work, restate state across turns, suppress…

@ayghri@ayghriInstall Skill
ab-test-analysis

ab-test-analysis

Analyze A/B test results with statistical significance, sample size validation, confidence intervals, and ship/extend/stop…

pm-skills13d28k
@phuryn@phurynInstall Skill
distilly

distilly

Set up the owner profile so a personal agent knows who it works for (first-run setup, \"get to know me\"), or distill colleague,…

Questions about llm.

Which coding agents can use llm?
llm installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.