Community程式設計與開發github.com

Jamie-BitFlight/dasel-reference

用於查詢、修改或轉換 JSON、YAML、TOML、XML、CSV、HCL 或 INI 格式資料,搭配 dasel v3。完整的選擇器、函式、條件式、變數、展開運算子、型別轉換及格式特定模式參考。

dasel-reference 是什麼?

這項技能提供 dasel v3 的完整語法參考,dasel 是一個單一二進位 CLI 工具,用於統一查詢、修改和轉換多種結構化資料格式(JSON、YAML、TOML、XML、CSV、HCL、INI),可取代 jq、yq 和 xmllint。本技能涵蓋基本的 stdin 使用方式、格式處理(必須明確指定輸入/輸出格式)、關鍵旗標(如 --in、--out、--root、--var、--compact、--rw-flag),以及核心選擇器(點記法、陣列索引、遞迴下降、物件建構、展開運算子)。它整理了 19 個內建函式(包括 filter、map、each、search、sortBy、has、sum、merge、keys、typeOf、toString 等),並說明 v3 中的修改語法(使用 --root 進行賦值、移除 put/delete 子命令)。此外,也提供條件式、變數賦值、格式轉換範例,以及 v3 與 v2 的重大變更清單(如移除 -f/--file 旗標、查詢語法重新設計、改為使用 Kong 框架)。此技能支援 Claude Code、Cursor、Codex 等 AI 代理平台,非常適合開發者在腳本或 CI/CD 流程中處理跨格式結構化資料。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Jamie-BitFlight/claude_skills/tree/main/plugins/dasel/skills/dasel-reference

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

dasel v3 語法參考

單一二進位 CLI 工具,用於查詢、修改和轉換結構化資料。以統一查詢語法取代 jq + yq + xmllint,支援所有格式。

撰寫時的穩定版本(日期:2026-02-23):v3.2.3

支援格式

json, yaml, toml, xml, csv, hcl, ini

基本用法

# 從標準輸入查詢(需指定格式)
echo '{"foo": "bar"}' | dasel -i json 'foo'

# 從標準輸入讀取檔案進行查詢
cat config.yaml | dasel -i yaml 'database.host'

# 修改並輸出完整文件
echo '{"port": 3000}' | dasel -i json --root 'server.port = 8080'

# 轉換格式
cat data.json | dasel -i json -o yaml

格式處理

dasel v3 不會自動從副檔名偵測格式。沒有 -f/--file 旗標。輸入一律從標準輸入讀取。必須使用 -i 和/或 -o 明確指定格式。如果只給定一個旗標,另一個會預設為相同格式。如果兩者都未給定,則兩者都預設為 json(可經由 ~/dasel.yaml 中的 default_format 金鑰進行設定)。

來源:internal/cli/query.go:10-11, internal/cli/run.go:37-43, internal/cli/config.go:19-21

主要旗標

-i, --in <format>         輸入解析器(json, yaml, toml, xml, csv, hcl, ini)
-o, --out <format>        輸出解析器(預設為輸入格式)
--root                    修改後輸出完整文件
--var <name>=<value>      將變數傳入查詢(可重複)
--compact                 緊湊輸出(不美化排版)
--rw-flag <name>=<value>  讀寫旗標(例如 --rw-flag csv-delimiter=;)
--read-flag <name>=<val>  讀取旗標(例如 --read-flag xml-mode=structured)
--write-flag <name>=<val> 寫入旗標(例如 --write-flag csv-delimiter=;)
-c, --config <path>       設定檔路徑(預設:~/dasel.yaml)

核心選擇器速查表

選擇器語法範例
點記法foo.bar.bazcat f.json | dasel -i json 'foo.bar'
陣列索引[0], [2]cat f.json | dasel -i json 'items[0]'
陣列切片[0:3]cat f.json | dasel -i json 'items[0:2]'
遞迴下降.., ..namecat f.json | dasel -i json '..name'
遞迴所有值..*cat f.json | dasel -i json '..*'
物件建構{ key1, key2 }cat f.json | dasel -i json '{ name, age }'
展開運算子obj...cat f.json | dasel -i json '{ defaults..., overrides... }'

主要函式速查表

DefaultFuncCollection 中有 19 個內建函式(來源:execution/func.go:12-33),加上 sortBy 複合表達式。

函式用途範例
filter(pred)過濾陣列users.filter(active == true)
map(expr)轉換陣列users.map(name)
each(expr)修改每個元素each($this = $this * 2)
search(pred)遞迴搜尋search(has("id"))
sortBy(expr)排序陣列sortBy($this, desc)
has(key)檢查金鑰是否存在has("name")
get(key)取得指定金鑰/索引的值get("name")
contains(val)檢查切片是否包含值contains(42)
len(expr)長度len($this)
join(sep)合併為字串join(",")
sum(expr)數值陣列求和sum($this)
add(args...)數字相加add(1, 2, 3)
max(args...)最大值max(1, 5, 3)
min(args...)最小值min(1, 5, 3)
merge(args...)合併映射merge(defaults, overrides)
keys(expr)取得映射的金鑰keys($this)
reverse(expr)反轉陣列reverse($this)
typeOf(expr)取得型別字串typeOf($this)
toString(expr)轉型為字串toString($this)
toInt(expr)轉型為整數toInt($this)
toFloat(expr)轉型為浮點數toFloat($this)
base64e(str)Base64 編碼base64e("hello")
base64d(str)Base64 解碼base64d("aGVsbG8=")
parse(fmt, data)執行時期解析資料parse("json", rawStr)
readFile(path)讀取檔案內容readFile("config.json")
ignore()從分支中排除ignore()

修改語法

v3 移除了 put 和 delete 子命令。請使用 --root 進行賦值:

# 設定值
echo '{"count": 1}' | dasel -i json --root 'count = 42'

# 布林賦值
echo '{"enabled": false}' | dasel -i json --root 'enabled = true'

# 附加到陣列
echo '[1,2,3]' | dasel -i json --root '[$this..., 4]'

# 移除金鑰(重新建構,排除該金鑰)
echo '{"keep": "yes", "drop": "no"}' | dasel -i json --root '{ keep }'

格式轉換

# JSON 轉 YAML
cat data.json | dasel -i json -o yaml

# YAML 轉 TOML
cat config.yaml | dasel -i yaml -o toml

# TOML 轉 JSON
cat config.toml | dasel -i toml -o json

特殊變數

  • $root — 參考根文件
  • $this — 參考目前節點(在 each、map、filter、search 內部使用)

變數賦值

# 使用分號進行多重陳述式
cat data.json | dasel -i json '$active = users.filter(active == true); $active.map(name)'

條件式

echo '{"count": 7}' | dasel -i json 'if(count > 5) { "many" } else { "few" }'

v3 重大變更(與 v2 比較)

  • 移除了 put 和 delete 子命令;請使用 --root 進行內聯賦值
  • 移除了 -f/--file 旗標;輸入一律透過管線從標準輸入讀取
  • 查詢/選擇器語法已完全重新設計;v2 語法與 v3 不相容
  • CLI 框架從 Cobra 改為 Kong
  • Go 模組路徑改為 github.com/tomwright/dasel/v3

詳細參考

  • 選擇器與語法 — 點記法、陣列、遞迴下降、物件建構、變數、條件式、比較運算子
  • 函式參考 — 完整函式簽名、描述及範例
  • 格式特定模式 — JSON、YAML、TOML、XML、CSV、HCL、INI 模式及轉換注意事項

來源

  1. dasel README: https://raw.githubusercontent.com/TomWright/dasel/master/README.md(擷取日期:2026-02-19)
  2. dasel 文件: https://daseldocs.tomwright.me(擷取日期:2026-02-19)
  3. 查詢語法: https://daseldocs.tomwright.me/syntax/query-syntax.md(擷取日期:2026-02-19)
  4. 函式索引: https://daseldocs.tomwright.me/functions(擷取日期:2026-02-19)
  5. CHANGELOG: https://raw.githubusercontent.com/TomWright/dasel/master/CHANGELOG.md(擷取日期:2026-02-19)
  6. 發行版本: https://github.com/TomWright/dasel/releases(擷取日期:2026-02-19)
  7. 原始碼分析: execution/func.go, internal/cli/query.go, internal/cli/run.go, internal/cli/config.go, execution/execute_binary.go, execution/execute_unary.go(分析日期:2026-02-19)
  8. 事實查核: FACT_CHECK_REPORT.md(2026-02-23)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Jamie-BitFlight/agentskill-kaizen-meta-docs

Agentskill kaizen plugin documentation index. Load when needing to read about cross-platform notes, improvement plans, or DuckDB integration.

Jamie-BitFlight/bash-51-features

Bash 5.1 release features and improvements with practical examples. Use when working with Bash 5.1 features, epoch time variables, redirection enhancements, or when user asks about Bash 5.1 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-52-features

Bash 5.2 release features and improvements with practical examples. Use when working with Bash 5.2 features, variable handling enhancements, readline improvements, or when user asks about Bash 5.2 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-53-features

Bash 5.3 release features and improvements with practical examples. Use when working with Bash 5.3 features, new command substitution, GLOBSORT, loadable builtins, or when user asks about Bash 5.3 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-development

This skill should be used when the user asks to "write a bash script", "create a shell script", "implement bash function", "parse arguments in bash", "handle errors in bash", or mentions bash development, shell scripting, script templates, or modern bash patterns.

Jamie-BitFlight/bash-lint

This skill should be used when the user asks to "lint bash script", "run shellcheck", "format shell script", "use shfmt", "fix shellcheck errors", or mentions shell script linting, formatting, code quality, or pre-commit hooks for bash.

Jamie-BitFlight/bash-logging

This skill should be used when the user asks to "add logging to bash script", "colorize output", "implement log levels", "CI/CD sections", "terminal colors in bash", or mentions logging functions, emoji output, collapsible CI sections, or shlocksmith.

Jamie-BitFlight/bash-portability

This skill should be used when the user asks about "POSIX compatibility", "portable shell scripts", "cross-shell compatibility", "bashisms", "shebang selection", or mentions writing scripts that work on different shells (bash, sh, dash, zsh) or different systems.

Jamie-BitFlight/bash-testing

This skill should be used when the user asks to "test bash script", "write shell tests", "use shunit2", "use shellspec", "create test suite for bash", or mentions unit testing, test frameworks, mocking, or test-driven development for shell scripts.

Jamie-BitFlight/brainstorming-skill

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or when users request help with ideation, marketing, and strategic planning. Explores user intent, requirements, and design before implementation using research-validated prompt patterns.

Jamie-BitFlight/clang-format

Configure clang-format code formatting. Use when: user mentions clang-format or .clang-format, analyzing code style/patterns, creating/modifying formatting config, troubleshooting formatting, brace styles/indentation/spacing/alignment/pointer alignment, or codifying conventions.

Jamie-BitFlight/commitlint

When setting up commit message validation for a project. When project has commitlint.config.js or .commitlintrc files. When configuring CI/CD to enforce commit format. When extracting commit rules for LLM prompt generation. When debugging commit message rejection errors.

Jamie-BitFlight/conventional-commits

When writing a git commit message. When task completes and changes need committing. When project uses semantic-release, commitizen, git-cliff. When choosing between feat/fix/chore/docs types. When indicating breaking changes. When generating changelogs from commit history.

Jamie-BitFlight/data-exploration

Use when exploring unknown structured data files with dasel v3 — discover schema, list keys, find nested values, sample arrays, identify data types across JSON, YAML, TOML, XML, CSV, HCL, INI formats

Jamie-BitFlight/data-transformation

Use when modifying, converting, or transforming structured data with dasel v3 — in-place mutations, format conversion, batch operations, array manipulation, object construction, and merge patterns across JSON, YAML, TOML, XML, CSV, HCL, INI

Jamie-BitFlight/delegate

Decompose substantive work into phases, dispatch each phase to a sub-agent, and adjudicate what comes back. Use whenever a request asks for implementation, investigation, a fix, a review, or any change to files — including small ones — and whenever you are about to read source or run a diagnostic yourself instead of handing it off. Also use when a report from a sub-agent needs judging, when a phase needs re-dispatching, or when a user names one instance of a pattern. Does not apply when your own prompt begins "Your ROLE_TYPE is sub-agent." — then follow references/sub-agent-contract.md instead.

Jamie-BitFlight/enterprise-hibernate-hbm

Dasel v3 query patterns for Hibernate .hbm.xml mapping files — entity-table binding, Java property-to-column extraction, one-to-many set/list/bag relationship tracing, many-to-one foreign key discovery, batch scanning across 60+ HBM files. Use when querying Hibernate ORM class mappings, extracting schema metadata from Java persistence layer, or auditing entity-column relationships in enterprise legacy codebases.

Jamie-BitFlight/enterprise-installanywhere

Dasel v3 query patterns for InstallAnywhere .iap_xml installer definitions — use when querying action sequences, discovering variables, resolving platform conditions, navigating panels, or comparing installer variants. Files are 2.5+ MB, 65,000+ lines — too large for context reads, requires structural dasel queries.

Jamie-BitFlight/enterprise-maven-pom

Dasel v3 selector patterns for Maven POM XML files — use when querying dependency versions, filtering by groupId or scope, extracting module hierarchy from parent POMs, or detecting version conflicts across enterprise multi-module Java projects. Load this skill when working with pom.xml files using dasel.

Jamie-BitFlight/enterprise-spring-xml

Dasel v3 selectors for Spring bean factory XML — use when querying any Spring ApplicationContext XML for bean discovery, dependency wiring, JMS destination mapping, property injection extraction, or cross-bean reference tracing. Load this skill before writing dasel selectors against Spring bean XML files (applicationContext.xml, *_beans.xml, spring-*.xml).

相關技能