llm-apps-creator
This skill should be used when users want to build LLM-powered applications using LangChain. It provides patterns for initializing any LLM provider (OpenAI, Anthropic, Google, xAI), building agent loops with tools, and implementing structured output. Use this skill when users ask to create chatbots, AI agents, or applications that need LLM integration with tool calling or structured responses.
What this skill does
# LLM Apps Creator
## Overview
This skill provides essential patterns for building LLM-powered applications using LangChain. It covers three core concepts:
1. **Universal LLM Initialization** - Initialize any LLM provider with a single function
2. **Agent Loop Pattern** - The simple but powerful pattern used by top AI agents
3. **Structured Output** - Get predictable, validated responses from LLMs
## Core Philosophy
> "The main agent is just a loop. The session memory is just a list of messages. It is enough to build the most powerful agent in the world."
Forget complex frameworks like ReAct/Reflection agents. The same simple agent-loop pattern is used in one of the most powerful agents: Claude Code.
## Quick Start
### Initialize Any LLM
Use `init_chat_model` to initialize any LLM provider with automatic detection:
```python
from langchain.chat_models import init_chat_model
from dotenv import load_dotenv
load_dotenv()
# Auto-detects provider from model name
llm = init_chat_model("gpt-4.1") # OpenAI (needs OPENAI_API_KEY)
llm = init_chat_model("claude-sonnet-4-5-20250929") # Anthropic (needs ANTHROPIC_API_KEY)
llm = init_chat_model("grok-code-fast-1") # xAI (needs XAI_API_KEY)
# Explicit provider specification
llm = init_chat_model("gemini-2.5-flash", model_provider="google_genai") # Google
llm = init_chat_model("my-model", model_provider="openai") # Custom
```
### Create Tools with DETAILED Docstrings
> **CRITICAL**: The docstring IS the prompt that tells the LLM how to use the tool. Poor docstrings = poor tool usage = broken agent.
```python
from langchain_core.tools import tool
# BAD - minimal docstring, LLM won't know how to use properly
@tool
def read_file(file_path: str) -> str:
"""Read a file.""" # DON'T DO THIS!
...
# GOOD - detailed docstring with usage guidelines
@tool("Read") # Named tool for clarity
def read_file(file_path: str) -> str:
"""Reads a file from the local filesystem and returns its contents.
## Usage Guidelines
- **file_path must be ABSOLUTE** (e.g., /Users/name/project/file.py), NOT relative
- Returns file contents with line numbers in `cat -n` format
- If file doesn't exist, returns an error message (this is OK, don't panic)
## When to Use
- Reading source code to understand implementation
- Checking configuration files
- ALWAYS read a file BEFORE trying to edit or write to it
## Performance Tips
- You can call this tool multiple times in parallel for different files
Args:
file_path: The ABSOLUTE path to the file (e.g., /Users/name/project/src/main.py)
Returns:
File contents with line numbers, or error message if file not found
"""
try:
with open(file_path, 'r') as f:
lines = f.readlines()
# Format with line numbers like cat -n
result = []
for i, line in enumerate(lines, 1):
result.append(f"{i:6d}\t{line.rstrip()}")
return "\n".join(result)
except FileNotFoundError:
return f"Error: File not found: {file_path}"
except Exception as e:
return f"Error reading file: {e}"
```
### More Tool Examples
```python
@tool("Write")
def write_file(file_path: str, content: str) -> str:
"""Writes content to a file, creating it if it doesn't exist or OVERWRITING if it does.
## Usage Guidelines
- **file_path must be ABSOLUTE**, NOT relative
- This will OVERWRITE the entire file - use Edit tool for partial modifications
- **CRITICAL**: ALWAYS use Read tool first to check existing content!
## When to Use
- Creating NEW files that don't exist yet
- Completely replacing file contents
## When NOT to Use
- Modifying existing files (use Edit tool instead)
- If you haven't read the file first
Args:
file_path: The ABSOLUTE path to write to
content: The complete content to write to the file
Returns:
Success message with file path, or error message
"""
import os
try:
dir_path = os.path.dirname(file_path)
if dir_path:
os.makedirs(dir_path, exist_ok=True)
with open(file_path, 'w') as f:
f.write(content)
return f"Successfully wrote {len(content)} characters to {file_path}"
except Exception as e:
return f"Error writing file: {e}"
@tool("Bash")
def run_command(command: str, working_dir: str = None) -> str:
"""Executes a bash/shell command and returns the output (stdout + stderr).
## Usage Guidelines
- Use for running scripts, builds, tests, git commands, etc.
- Commands timeout after 30 seconds
- Use absolute paths in commands to avoid directory confusion
## When to Use
- Running build tools (npm, pip, cargo, make, etc.)
- Git operations (git status, git diff, git commit, etc.)
- Running tests (pytest, jest, cargo test, etc.)
## When NOT to Use
- Reading files (use Read tool instead of cat/head/tail)
- Searching files (use dedicated search tools instead of grep/find)
Args:
command: The shell command to execute
working_dir: Optional working directory (absolute path)
Returns:
Command output (stdout + stderr combined), or error/timeout message
"""
import subprocess
import os
try:
cwd = working_dir if working_dir else os.getcwd()
result = subprocess.run(
command, shell=True, capture_output=True,
text=True, timeout=30, cwd=cwd
)
output = result.stdout
if result.stderr:
output += f"\nSTDERR:\n{result.stderr}"
if result.returncode != 0:
output += f"\n[Exit code: {result.returncode}]"
return output if output.strip() else "(Command completed with no output)"
except subprocess.TimeoutExpired:
return "Error: Command timed out after 30 seconds"
except Exception as e:
return f"Error executing command: {e}"
```
### Initialize Agent with Tools
```python
from langchain.chat_models import init_chat_model
# Initialize LLM with tools
llm = init_chat_model("gpt-4.1")
llm_with_tools = llm.bind_tools([read_file, write_file, run_command])
```
### Get Structured Output
```python
from pydantic import BaseModel, Field
from langchain.agents import create_agent
class ContactInfo(BaseModel):
"""Contact information for a person."""
name: str = Field(description="The name of the person")
email: str = Field(description="The email address")
phone: str = Field(description="The phone number")
agent = create_agent(
model="gpt-4.1",
response_format=ContactInfo # Auto-selects best strategy
)
result = agent.invoke({
"messages": [{"role": "user", "content": "Extract: John Doe, [email protected], 555-1234"}]
})
print(result["structured_response"])
# ContactInfo(name='John Doe', email='[email protected]', phone='555-1234')
```
## The Agent Loop Pattern
The core pattern is deceptively simple:
```
1. User sends a message
2. LLM responds (possibly with tool calls)
3. If tool calls exist, execute them and feed results back
4. Repeat until LLM responds without tool calls
```
### Complete Agent Implementation
```python
from typing import List, Dict, Any, Optional
from langchain_core.messages import SystemMessage, HumanMessage, ToolMessage
from langchain_core.tools import BaseTool
from langchain.chat_models import init_chat_model
class SimpleAgent:
"""A minimal agent that uses tools to accomplish tasks."""
def __init__(
self,
system_prompt: str,
tools: List[BaseTool],
model_name: str = "gpt-4.1",
model_provider: Optional[str] = None,
):
# Store tools in a map for quick lookup
self.tools_map: Dict[str, BaseTool] = {tool.name: tool for tool in tools}
# Create LLM with tools bound
llm = init_chat_model(model_name, model_provider=model_provider)
self.llm_wRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.