Skip to content
Back to skills

Prompt Engineering

ASecurity

"Build CLIP zero-shot class prompts, tokenizer-safe templates, and

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 8, 2026
ai-agentspythongobash

Works with

  • cli

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill prompt-engineering --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prompt Engineering?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prompt Engineering
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-prompt-engineering/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-prompt-engineering)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: prompt-engineering
description: "Build CLIP zero-shot class prompts, tokenizer-safe templates, and
  normalized text classifier weights."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Prompt Engineering

Use this sub-skill when an agent needs to turn class labels into CLIP text prompts, tokenize them safely, build zero-shot classifier weights, or diagnose prompt/template failures.

## Route

- Start with `references/prompting-workflows.md` for class taxonomies, template design, prompt ensembling, normalized text features, and top-k zero-shot scoring.
- Use `references/tokenization.md` before generating large prompt sets or when `clip.tokenize` raises context-length errors.
- Use `references/troubleshooting.md` for unsafe category design, malformed templates, device mismatches, unnormalized features, and multilingual/English limitations.
- Use `scripts/build_zeroshot_classifier.py` when you need a reusable helper for expanding templates, dry-run tokenization, or building normalized classifier weights from a loaded CLIP model.

## Boundaries

- Model selection, `clip.load`, image preprocessing, and image-text inference setup belong in `../model-loading-inference/`.
- Linear probes, cached image feature evaluation, and dataset-scale benchmark loops belong in `../feature-evaluation/`.
- Dataset downloads mentioned in source docs are reference-only; do not make prompt workflows depend on downloading raw datasets by default.

## Minimal Safe Flow

1. Define a fixed English class taxonomy with non-overlapping labels and avoid sensitive or deployment-risk categories unless the user explicitly asks for a research-only audit.
2. Choose templates containing exactly one `{}` placeholder, such as `a photo of a {}.` or domain-specific variants like `a photo of a {}, a type of bird.`
3. Dry-run tokenize the expanded prompts with `clip.tokenize(..., context_length=77, truncate=False)` before running model inference.
4. Encode prompt batches with a loaded CLIP model, normalize every prompt embedding, average templates per class, normalize the averaged class vector, then stack weights as `[text_feature_dim, num_classes]`.
5. For image classification, normalize image features and compute `100.0 * image_features @ zeroshot_weights`; treat softmax/top-k scores as relative to the candidate class list, not calibrated real-world confidence.

## Helper Script

Dry-run prompt tokenization without loading or downloading model checkpoints:

```bash
python sub-skills/prompt-engineering/scripts/build_zeroshot_classifier.py \
  --class-name cat --class-name "electric ray" \
  --template "a photo of a {}." \
  --dry-run-tokenize
```

Build classifier weights only when a model load is explicitly requested or a caller imports `build_zeroshot_classifier(model, class_names, templates)` with an already loaded model. See `references/prompting-workflows.md` for the importable contract.

Files in this skill

  • SKILL.md2.9 KB
  • references/prompting-workflows.md6 KB
  • references/tokenization.md4.3 KB
  • references/troubleshooting.md4.4 KB
  • scripts/build_zeroshot_classifier.py12.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.