Community编程与开发github.com

Jamie-BitFlight/dasel-reference

用于查询、修改或转换 JSON、YAML、TOML、XML、CSV、HCL 或 INI 格式数据的 dasel v3 完整参考。包含选择器、函数、条件、变量、展开运算符、类型转换以及各格式特有模式。

dasel-reference 是什么?

该技能提供了 dasel v3 的全面语法参考,dasel 是一款单一二进制 CLI 工具,能够替代 jq、yq 和 xmllint,通过统一的查询语法处理多种结构化数据格式。它支持 JSON、YAML、TOML、XML、CSV、HCL 和 INI 格式,并且所有操作均通过标准输入(stdin)完成,显式指定输入输出格式。技能文档详细涵盖了核心选择器(如点号、数组索引、递归下降、对象构造和展开运算符)、19 个内置函数(如 filter、map、search、sortBy、类型转换和 Base64 编解码)、修改语法(使用赋值替换 v2 的 put/delete)、条件语句、特殊变量($root、$this)以及格式转换。此外还包含 v3 与 v2 的重大变更说明,内部引用了 dasel 官方文档和源代码进行分析,确保准确性。适用于 Cursor、Claude Code 以及任何支持 Markdown 知识库的 AI 编码代理。

兼容平台~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. 变更日志: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).

相关技能