Skip to content
Back to skills

Op Secret Template

ASecurity

Generate `op://` secret references for every field on a 1Password item. Output is ready to paste into a `.env` template.

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
toolsbashapi

Works with

  • cli
  • api

Security analysis

A100/100

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

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill op-secret-template --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Op Secret Template?

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

Security grade badge for Op Secret Template
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-op-secret-template/badge)](https://www.skillsdirectory.com/skills/aibot88-op-secret-template)

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: op-secret-template
description: Generate `op://` secret references for every field on a 1Password item. Output is ready to paste into a `.env` template.
argument-hint: "<item-name-or-id> [--vault <vault>]"
allowed-tools: Bash(op item get:*), Bash(op vault list:*)
---

# /op-secret-template

Given an item identifier, print every field on the item as a `KEY=op://...` line, suitable for a `.env` template used with `op run --env-file=.env -- ...`.

## Inputs

`$ARGUMENTS` — first arg is the item name or ID. Optionally `--vault <vault>` to scope the lookup.

## Steps

1. Fetch the item as JSON:
   ```bash
   op item get $ARGUMENTS --format=json
   ```

2. From the JSON, extract:
   - `vault.name` (call this `VAULT`)
   - `title` (call this `ITEM`)
   - For each entry in `fields[]`:
     - `label` (or `id` if no label)
     - `section.label` if `section` is present
     - `purpose` (`PASSWORD`, `USERNAME`, `NOTES`, etc.) if no label
     - `type` (`STRING`, `CONCEALED`, `URL`, `EMAIL`, `OTP`, `DATE`, `MONTH_YEAR`, `PHONE`)

3. Emit `KEY=op://VAULT/ITEM[/SECTION]/FIELD_LABEL` lines:
   - Skip fields with no value AND no label (CLI metadata).
   - Use the human-readable label for the secret reference.
   - Convert each label to a SCREAMING_SNAKE env var name on the left side.
   - For OTP fields, append `?attribute=otp` so it returns the current code.
   - For SSH private-key fields, append `?ssh-format=openssh`.

4. Wrap output in a fenced block with a header explaining usage:
   ```
   # Generated for item "ITEM" in vault "VAULT"
   # Use with: op run --env-file=.env -- <command>
   USERNAME=op://VAULT/ITEM/username
   PASSWORD=op://VAULT/ITEM/password
   API_KEY=op://VAULT/ITEM/Credentials/api_key
   TOTP=op://VAULT/ITEM/totp?attribute=otp
   ```

5. Note any field type that needs special handling (file attachments → `op read --out-file ...` not env, document attachments not supported).

## Edge cases

- **Multiple sections with same field name** → include the section name in the reference so the URI is unambiguous.
- **Whitespace in vault/item/field names** → wrap the whole reference value in single quotes in the output: `KEY='op://Acme Prod/My Item/api key'`.
- **Special characters that secret refs don't allow** → use the field's `id` instead of `label`, and note "(using ID instead of name due to special characters)".
- **Item is a Document or has file attachments** → emit a comment line explaining `op read --out-file` is needed instead of env loading.

## On failure

- Item not found → suggest `/op-find <query>` to locate it.
- Multiple matches (interactive only error) → tell the user to disambiguate by ID or `--vault`.

Files in this skill

  • SKILL.md2.6 KB
  • source.json647 B

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.