Generate static MD tip files for the drupal-tip skill using various LLM providers.
cd ~/.claude/skills/drupal-tip
python3 -m venv .venv
source .venv/bin/activate
pip install openai anthropicCopy the example environment file and add your keys:
cp .env.example .envEdit .env with your API keys (use TIPGEN_ prefix):
TIPGEN_ANTHROPIC_API_KEY=sk-ant-...
TIPGEN_OPENAI_API_KEY=sk-...
TIPGEN_OPENROUTER_API_KEY=sk-or-...Get a tip from the pre-generated database instantly — no API call needed:
.venv/bin/python tip_generator.py --random-tip
.venv/bin/python tip_generator.py --random-tip --tip-category core-service
.venv/bin/python tip_generator.py --list-existing.venv/bin/python tip_generator.py --list-categoriesUsing Anthropic:
.venv/bin/python tip_generator.py -c 35 -n 5 -p anthropicUsing OpenAI (batch mode - 50% cheaper):
.venv/bin/python tip_generator.py -c 35 -n 5 -p openaiUsing OpenRouter:
.venv/bin/python tip_generator.py -c 35 -n 5 -p openrouter| Argument | Description |
|---|---|
-c, --category |
Category number(s) or all |
-n, --count |
Number of tips per category (default: 5) |
-p, --provider |
LLM provider: anthropic, openai, openrouter |
-m, --model |
Override default model |
--no-wait |
Don't wait for batch completion |
--dry-run |
Show what would be done without calling API |
--list-categories |
List all available categories |
--random-tip |
Get a random existing tip (fast, no API) |
--list-existing |
List categories with existing tips |
--tip-category |
Filter random tip by category name |
--validate |
Enable validation mode |
--validate-file |
Validate a specific tip file |
--validate-category |
Validate all tips in a category |
--validate-all |
Validate all tips across all categories |
# Generate 3 tips for category 35 (core-service)
.venv/bin/python tip_generator.py -c 35 -n 3 -p openrouter
# Generate 5 tips for multiple categories
.venv/bin/python tip_generator.py -c 35,36,37 -n 5 -p openrouter
# Generate 1 tip for ALL categories
.venv/bin/python tip_generator.py -c all -n 1 -p openrouter
# Use a specific model
.venv/bin/python tip_generator.py -c 35 -n 5 -p openrouter -m anthropic/claude-opus-4| Provider | Batch Support | Discount | Notes |
|---|---|---|---|
| Anthropic | Yes | 50% | Uses message-batches-2024-09-24 beta |
| OpenAI | Yes | 50% | Results within 24h |
| OpenRouter | - | Batch API not supported |
If you ran batch mode with --no-wait:
.venv/bin/python tip_generator.py --check-batch BATCH_ID -p anthropic
.venv/bin/python tip_generator.py --check-batch BATCH_ID -p openai --save-resultsTips are saved to tips/{category-name}/{uuid}.md with 8-character random IDs:
tips/
├── core-service/
│ ├── a1b2c3d4.md
│ └── e5f6g7h8.md
└── rare-drush-command/
└── 9i0j1k2l.md
Each file has frontmatter:
---
category: core-service
title: [Generated title]
---
[Tip content]Categories and the prompt template are defined in config.json:
{
"prompt_template": "Generate a Drupal tip for category #{cat_id}: {cat_desc}...",
"code_language": "php",
"categories": {
"1": {"name": "proposed-new-module", "desc": "Proposed new module"},
"35": {"name": "core-service", "desc": "Lesser-known core service"}
}
}To add or modify categories, edit config.json directly - no code changes needed.
# Dry run to verify configuration
.venv/bin/python tip_generator.py -c 35 -n 1 -p openrouter --dry-runValidate generated tips for formatting issues, truncation, and quality:
# Validate a single file
.venv/bin/python tip_generator.py --validate --validate-file tips/core-service/a1b2c3d4.md
# Validate all tips in a category
.venv/bin/python tip_generator.py --validate --validate-category core-service
# Validate ALL tips across all categories
.venv/bin/python tip_generator.py --validate --validate-all- Formatting: Frontmatter structure, code block balance, line counts
- Completeness: Truncation patterns (trailing
...,[TODO], incomplete code blocks) - Quality: Generic openings, placeholder text, excessive code ratio
- Fake Content: Non-existent Drupal APIs, hallucinated functions, wrong service names
A simple web UI to browse tips:
pip install flask
python tip_viewer.py # http://localhost:5000
python tip_viewer.py --port 8080 # Custom port
python tip_viewer.py --host 0.0.0.0 # Public access
python tip_viewer.py --debug # Debug modeFeatures:
- Filter tips by category
- Get random tip with one click
- View all tips or browse by category