prefer-yq

prefer-yq is a skill for Claude Code from ncaq/konoka. It costs 65 tokens per session (1,715 once invoked), scanned A, original, Apache-2.0.

A command-line usage guide for `yq`, a tool that reads and changes structured YAML, XML, TOML, and CSV files. It also explains how this version differs from another incompatible tool with the same name.

In plain words
What is it for?
Use it when reading or editing structured configuration files from the command line, especially when selecting fields by their path.
Why use it?
It avoids unsafe text substitutions that can change the wrong configuration field and reduces confusion about which `yq` syntax is installed.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the programming-tasuke plugin — 7 skills shipped together

Good fit Use it when reading or editing structured configuration files from the command line, especially when selecting fields by their path.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ncaq/konoka/prefer-yq
View source ↗ ncaq/konoka
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ncaq/konoka --skill prefer-yq
Clone the repo
git clone --depth 1 https://github.com/ncaq/konoka

Made for: Claude Code.

Or install programming-tasuke, the plugin that ships this one along with the rest of its 7 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prefer-yq

README.md
[![agentmods](https://agentmods.dev/badge/skills/ncaq/konoka/prefer-yq/github.svg)](https://agentmods.dev/skills/ncaq/konoka/prefer-yq)
Your own site
<a href="https://agentmods.dev/skills/ncaq/konoka/prefer-yq"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/prefer-yq/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for prefer-yq

Your own site · 80×15
<a href="https://agentmods.dev/skills/ncaq/konoka/prefer-yq"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/prefer-yq.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,715 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.01715
Opus 5.5 $0.00026 $0.00686
Sonnet 5.5 $0.00013 $0.00343
Haiku 4.5 $0.00006 $0.00171

Measured 1mo ago against content hash 487d430c34cd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

prefer-yq scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

リモートから取得したデータを`curl`からyqへ直接パイプするのは避けてください。
plugins/programming-tasuke/skills/prefer-yq/SKILL.md · 135 lines

How it starts

The opening of the file, as written. The whole thing — 135 lines — stays where its author put it; the contents beside it link to each section on GitHub.

YAMLなどの処理にはyqを優先する

YAMLやXMLやTOMLやCSVといった構造化データを読み取ったり変換したりする用事には、 yqを使ってください。 Pythonなどの汎用スクリプト言語や、 sedによる場当たり的なテキスト置換を持ち出さないでください。

JSONを扱う時はyqではなくjqを使ってください。 yqでもJSONは扱えますが、 形式ごとに道具を使い分けたほうが読み手に意図が伝わります。 programming-tasuke:prefer-jqスキルを参照してください。

理由

汎用スクリプト言語は何でも出来てしまいます。 コマンドの実行を承認する人間は毎回スクリプトの中身を読んで安全性を判断しなければならず、 Bash(python:*)のような包括的な許可を出すことも危険です。 yqの出来ることはデータの変換にほぼ限られていて副作用が少ないため、 包括的な許可を出しやすく、 承認の手間が発生しません。

sedによる置換はYAMLの構造を理解しないため、 同じ名前のキーが別の階層にもある場合などに、 意図しない箇所まで書き換えてしまいます。 yqはパスを指定して構造として扱うのでその危険がありません。

インデントやアンカーの扱いを自前で組み立てるより、 yqに任せた方が短く書けて読みやすいという利点もあります。

実装の区別

yqという名前のコマンドには互換性のない2つの実装があります。

  • mikefarah/yq: Go製の単体バイナリ。nixpkgsのyq-go。このスキルはこちらを前提とします。
  • kislyuk/yq: Python製のjqラッパー。nixpkgsのyq。フィルタの構文はjqと同一です。

構文が違うので、 書いたフィルタが構文エラーになった時は実装の違いを疑ってください。 yq --versionで判別できます。 mikefarah版はyq (https://github.com/mikefarah/yq/) version v4.53.2のように出力します。

使い方

読み取り。

yq '.services.web.image' compose.yaml

書き換え。 -iで入力ファイルを直接書き換えます。 コメントは保持されます。

yq -i '.version = "2"' compose.yaml

出力形式の変換は-oで指定します。

yq -o=json '.' compose.yaml

入力形式は既定ではautoで、 ファイルの拡張子から判別されます。 拡張子から判別できない入力を渡す時は-pで明示してください。 標準入力を渡す場合や、 .txtのように中身と一致しない拡張子のファイルを渡す場合が該当します。 判別できない入力は黙ってYAMLとして解釈されるため、 気付かないまま誤った結果を得ることがあります。 auto, yaml, kyaml, json, props, csv, tsv, xml, base64, uri, toml, hcl, lua, iniをサポートします。

yq -p=xml -o=yaml '.root.item' response.txt

出力形式も-oで明示してください。 出力形式の既定もautoですが、 こちらが見ているのは入力形式ではなく入力ファイルの拡張子で、 -pを付けても連動しません。 拡張子から判別できないままだと、 YAMLへ倒した旨の警告が出力されます。

リモートから取得したデータをcurlからyqへ直接パイプするのは避けてください。 一度ファイルへ保存して中身を確認してから処理してください。 想定と違う形式が返っていたり、 巨大なデータが返っていたりすることに気付けます。

シェルの値はフィルタへ文字列連結せずに、 環境変数を経由して渡します。 jqの--argに相当します。

version=2 yq -i '.version = strenv(version)' compose.yaml

複数のファイルやドキュメントを横断して処理する時はeval-allを使います。

yq eval-all '. as $item ireduce ({}; . * $item)' base.yaml override.yaml

jqとの違いで戸惑いやすい点

Read the full file on GitHub · 135 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 135 lines · 65 tokens per session scan A 487d430c34cd

Subscribe to this mod's changes

prefer-yq is a skill published in the GitHub repository ncaq/konoka (3 stars, last pushed yesterday), licensed Apache-2.0. It adds 65 tokens to every session and 1,715 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.