config-skills
Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.
Best use case
config-skills is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.
Teams using config-skills should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/config-skills/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How config-skills Compares
| Feature / Agent | config-skills | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Config Skills for LlamaFarm
Specialized patterns and best practices for the LlamaFarm configuration module (`config/`).
## Module Overview
The config module provides YAML/TOML/JSON configuration loading with JSONSchema validation:
| File | Purpose |
|------|---------|
| `datamodel.py` | Generated Pydantic v2 models from JSONSchema |
| `schema.yaml` | Source JSONSchema with `$ref` references |
| `compile_schema.py` | Dereferences `$ref` to create `schema.deref.yaml` |
| `generate_types.py` | Generates Python types via `datamodel-codegen` |
| `validators.py` | Custom validators beyond JSONSchema capabilities |
| `helpers/loader.py` | Config loading, saving, and format detection |
| `helpers/generator.py` | Template-based config generation |
## Links to Shared Skills
This module follows Python conventions from the shared skills:
| Topic | Link | Key Relevance |
|-------|------|---------------|
| Patterns | [python-skills/patterns.md](../python-skills/patterns.md) | Pydantic v2, dataclasses |
| Typing | [python-skills/typing.md](../python-skills/typing.md) | Type hints, constrained types |
| Testing | [python-skills/testing.md](../python-skills/testing.md) | Pytest fixtures, temp files |
| Errors | [python-skills/error-handling.md](../python-skills/error-handling.md) | Custom exceptions |
| Security | [python-skills/security.md](../python-skills/security.md) | Path traversal prevention |
## Framework-Specific Checklists
| Checklist | Description |
|-----------|-------------|
| [pydantic.md](pydantic.md) | Pydantic v2 configuration patterns, nested models, constraints |
| [jsonschema.md](jsonschema.md) | JSONSchema generation, dereferencing, validation |
## Tech Stack
- **Python**: 3.11+
- **Pydantic**: v2 with `ConfigDict`, `Field`, constrained types
- **JSONSchema**: Draft-07 with `$ref` dereferencing via `jsonref`
- **YAML**: `ruamel.yaml` for comment-preserving read/write
- **Code Generation**: `datamodel-codegen` for schema-to-Pydantic
## Key Patterns
### Generated Pydantic Models
The `datamodel.py` file is auto-generated from JSONSchema:
```python
# Generated by datamodel-codegen from schema.deref.yaml
from pydantic import BaseModel, ConfigDict, Field, conint, constr
class Database(BaseModel):
model_config = ConfigDict(extra="forbid")
name: constr(pattern=r"^[a-z][a-z0-9_]*$", min_length=1, max_length=50)
type: Type
config: dict[str, Any] | None = Field(None, description="Database-specific configuration")
```
### Custom Validators for Cross-Field Constraints
JSONSchema draft-07 cannot express all constraints. Custom validators extend validation:
```python
def validate_llamafarm_config(config_dict: dict[str, Any]) -> None:
"""Validate constraints beyond JSONSchema (uniqueness, references)."""
# Check for duplicate prompt names
prompt_names = [p.get("name") for p in config_dict.get("prompts", [])]
duplicates = [name for name in prompt_names if prompt_names.count(name) > 1]
if duplicates:
raise ValueError(f"Duplicate prompt set names: {', '.join(set(duplicates))}")
```
### Comment-Preserving YAML with ruamel.yaml
Configuration files preserve user comments when modified:
```python
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap
def _get_ruamel_yaml() -> YAML:
yaml_instance = YAML()
yaml_instance.preserve_quotes = True
yaml_instance.indent(mapping=2, sequence=4, offset=2)
return yaml_instance
```
## Directory Structure
```
config/
├── pyproject.toml # UV-managed dependencies
├── schema.yaml # Source JSONSchema with $ref
├── schema.deref.yaml # Dereferenced schema (generated)
├── datamodel.py # Pydantic models (generated)
├── compile_schema.py # Schema compilation script
├── generate_types.py # Type generation script
├── validators.py # Custom validation beyond JSONSchema
├── validate_config.py # CLI validation wrapper
├── __init__.py # Public API exports
├── helpers/
│ ├── loader.py # Config loading/saving
│ └── generator.py # Template-based generation
├── templates/
│ └── default.yaml # Default config template
└── tests/
├── conftest.py # Shared fixtures
└── test_*.py # Test modules
```
## Workflow: Schema Changes
When modifying the configuration schema:
1. **Edit** `schema.yaml` (or referenced schemas like `../rag/schema.yaml`)
2. **Run** `nx run generate-types` to compile and generate types
3. **Update** `validators.py` if new cross-field constraints are needed
4. **Test** with `uv run pytest config/tests/`
## Common Commands
```bash
# Generate types from schema
nx run generate-types
# Validate a config file
uv run python config/validate_config.py path/to/llamafarm.yaml --verbose
# Run tests
uv run pytest config/tests/ -v
# Lint and format
ruff check config/ --fix
ruff format config/
```Related Skills
typescript-skills
Shared TypeScript best practices for Designer and Electron subsystems.
server-skills
Server-specific best practices for FastAPI, Celery, and Pydantic. Extends python-skills with framework-specific patterns.
runtime-skills
Universal Runtime best practices for PyTorch inference, Transformers models, and FastAPI serving. Covers device management, model loading, memory optimization, and performance tuning.
react-skills
React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.
rag-skills
RAG-specific best practices for LlamaIndex, ChromaDB, and Celery workers. Covers ingestion, retrieval, embeddings, and performance.
python-skills
Shared Python best practices for LlamaFarm. Covers patterns, async, typing, testing, error handling, and security.
go-skills
Shared Go best practices for LlamaFarm CLI. Covers idiomatic patterns, error handling, and testing.
generate-subsystem-skills
Generate specialized skills for each subsystem in the monorepo. Creates shared language skills and subsystem-specific checklists for high-quality AI code generation.
common-skills
Best practices for the Common utilities package in LlamaFarm. Covers HuggingFace Hub integration, GGUF model management, and shared utilities.
cli-skills
CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.
electron-skills
Electron patterns for LlamaFarm Desktop. Covers main/renderer processes, IPC, security, and packaging.
designer-skills
Designer subsystem patterns for LlamaFarm. Covers React 18, TanStack Query, TailwindCSS, and Radix UI.