Llm logo

Llm

CommunityPopular
elie222
llm

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

Overview

Publisherelie222
Repositoryinbox-zero
Skill namellm
Stars
12.5K
Forks
1.6K
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by elie222 on GitHub. Read the source before you install it.

Installation

Install the Llm AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/elie222/inbox-zero/tree/main/.claude/skills/llm
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/elie222/inbox-zero.git /tmp/inbox-zero
mkdir -p .claude/skills
cp -r /tmp/inbox-zero/.claude/skills/llm .claude/skills/llm
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Llm in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Llm on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Llm is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

typescript
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

Testing

See llm-test.mdc

Frequently asked questions

What does the Llm AI skill do?

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

Why use Llm on TypingMind?

Because you install it once and use it with any model. Llm is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Llm in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/elie222/inbox-zero/tree/main/.claude/skills/llm. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Llm?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Llm?

As many as you like. As long as a model supports skills, you can use Llm with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Llm AI skill free?

It is published on GitHub by elie222. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇