extracting-jcr-queries
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "extracting-jcr-queries":https://skillpi.com/zh/skills/deepskill-9caa2981bc913a4e5513fb7bb90b6db8daf16b16590dfa08758bc3a5567a3acb。安装前核对上游来源和版本:https://github.com/adobe/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
在审计代码库以查找其发出的所有 JCR 查询时使用,包括 XPath、SQL2、AEM QueryBuilder 谓词,以及通过包装器/辅助类/DAO 以编程方式组装的查询。适用于 Oak 索引审计、迁移、性能调查,或回答“此应用程序运行哪些查询”之类的问题。
介绍来源: third_party · adobe · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 软件、账号及付费要求
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: extracting-jcr-queries
description: Use when auditing a codebase to find every JCR query it issues — XPath, SQL2, or AEM QueryBuilder predicates, including ones assembled programmatically through wrapper/helper/DAO code — before an Oak index audit, migration, performance investigation, or when asked "what queries does this app run".
license: Apache-2.0
compatibility: Any AEM/Oak codebase (Java, JSP/HTL, or config-driven) issuing JCR or AEM QueryBuilder queries.Extracting JCR Queries
Overview
Most real queries in AEM/Oak codebases are not string literals — they're
assembled at runtime (StringBuilder concatenation, predicate maps built
from named constants, fluent builders) and executed through a small set of
APIs: javax.jcr.query.QueryManager / Query or com.day.cq.search.QueryBuilder
/ PredicateGroup. Grepping for the query text misses these entirely — a
query built as sb.append("SELECT * FROM [").append(nodeType)... produces
zero hits on any literal-shape pattern despite being a live query.
Two complementary techniques. Use both; neither alone is a parser — treat matches as a candidate inventory, review by hand.
Tooling requirement
Every command below is written for ripgrep (rg). Check it's actually there before running anything:
command -v rg >/dev/null && echo "rg found" || echo "rg missing — use the fallback command under each pattern"
If rg is missing, grep -P is not a safe substitute. GNU grep supports -P, but macOS's stock
BSD grep does not — grep -P "..." fails with grep: invalid option -- P on an unmodified Mac, the
same failure mode as a missing rg. Don't assume grep -P as a drop-in fallback; use the portable
grep -E command given under each pattern below instead (verified against BSD grep). One pattern (the
multi-line predicate-map form in Technique 2) has no line-based fallback at all — see its note. Prefer
installing rg when you can (brew install ripgrep / apt install ripgrep) — faster, recurses by
default, and the only way to run that one pattern.
When to use
- Building an inventory of queries before checking Oak index coverage
- "What queries does this app/bundle issue?"
- Hunting for a query missing a matching index (traversal warnings, slow query logs)
- Auditing a bundle/package before migration or refactor
Technique 1: API-surface tracing (primary)
Anchor on the API, not the query text. Every JCR/QueryBuilder query passes through one of a handful of call shapes, no matter how the query itself was built.
Step 1 — find direct API entry points:
rg -n -P "getQueryManager\(\)|\.createQuery\(|PredicateGroup\.create\("
rg -n -P "^\s*import\s+(javax\.jcr\.query|org\.apache\.jackrabbit\.oak\.query|com\.day\.cq\.search)"
No rg? Portable fallback (verified against BSD grep):
grep -rnE "getQueryManager\(\)|\.createQuery\(|PredicateGroup\.create\(" .
grep -rnE "^[[:space:]]*import[[:space:]]+(javax\.jcr\.query|org\.apache\.jackrabbit\.oak\.query|com\.day\.cq\.search)" .
These match the JCR API (QueryManager, Query) and the AEM QueryBuilder
API (QueryBuilder, PredicateGroup) regardless of how the query
content itself is constructed.
Step 2 — classify each hit as a trigger or a wrapper:
Is this call site invoked directly from a request/job entry point, or is it
inside a helper/service/DAO that other code calls into with generic
parameters (nodeType, path, a predicate map)? Class names like *Service,
*Helper, *Dao, *Repository, *QueryUtil and methods called from more
than one place are signals of a wrapper.
Step 3 — pan out: trace every caller of the wrapper:
rg -n "WrapperClassName\b"
rg -n "\.wrapperMethodName\("
No rg? Portable fallback (drops the \b word boundary — GNU extension, not POSIX; accept the small
risk of matching a longer identifier that merely contains the name as a substring):
grep -rnE "WrapperClassName" .
grep -rnE "\.wrapperMethodName\(" .
A wrapper can itself be wrapped by another layer — repeat until you reach either a genuine external entry point (servlet, scheduled job, event listener) with no further in-repo caller, or you've enumerated every call site. Each distinct caller is a distinct trigger path and belongs in the inventory as its own row, even if they all route through the same construction site.
Step 4 — record what's fixed vs. dynamic at each caller: Note which parameters (path, node type, predicate values) are hardcoded literals at that call site vs. passed through unconstrained from further up the chain. An unconstrained node type/path means the query's real shape varies by caller — that matters for index coverage.
Technique 2: literal-shape regex (supplementary)
For query text that never touches a Java API call in this repo — hardcoded
in JSP/JS/HTL, config files, or query-string URLs — anchor on the shape of
the query text itself instead. Pure rg/grep, use double-quoted shell
strings (patterns contain literal "/'). Each pattern below has a portable
grep -E fallback (verified against BSD grep) except the last one, which
genuinely needs rg -U's multi-line matching — see its note.
SQL2 — SELECT ... FROM [nodetype]:
rg -n -i -P "\bselect\b.{0,200}?\bfrom\b\s*\[[\w:.]+\]"
No rg? (drops the lazy .{0,200}? and \b/\w PCRE shorthands — may over-match a line with more
than one select/from pair, review hits by hand):
grep -rniE "select.{0,200}from[[:space:]]*\[[A-Za-z0-9_:.]+\]" .
XPath — /jcr:root/..., //name[predicate], or //element(*, NodeType)[predicate]:
rg -n -P "(?:/jcr:root(?:/[^\s\"'\[\]]+)*|//(?:[\w:*]+|element\([^()]*\))(?:/(?:[\w:*]+|element\([^()]*\)))*)\[[^\[\]]*\]"
No rg? (non-capturing groups become plain groups — harmless, only matters if you'd used -o):
grep -rnE "(/jcr:root(/[^][:space:]\"'\[\]]+)*|//([A-Za-z0-9_:*]+|element\([^()]*\))(/([A-Za-z0-9_:*]+|element\([^()]*\)))*)\[[^][]*\]" .
The double-slash and the bracketed-predicate requirement are both deliberate: they're what stops a bare
single-/ path fragment (e.g. /docs/readme[1]) or a // line comment followed by unrelated array[0]
code from matching — use //, not //?, or that false-positive comes right back. The element(*, NodeType) branch is
required, not optional — the plain //[\w:*]+ name-token alternative alone cannot match through the
parens/comma inside element(*, dam:Asset), so a query already using an explicit nodetype restriction
(the fix the paired tuning-oak-query-indexes skill recommends for its nodetype-scoping gotcha) is
otherwise invisible to this technique — live-confirmed miss before this branch was added.
QueryBuilder, query-string form — path=...&type=... (&-joined, e.g. a URL) or space-joined (e.g. a
stored dam:query/Smart Collection predicate string, which also uses numeric-prefixed nested keys like
1_group.0_property=... or 5_relativedaterange.property=...):
rg -n -P "(?:^|[?&\"'\s])(?:\d+_)?(?:path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(?:\.(?:\d+_)?[A-Za-z]\w*)*=[^\s&\"']*(?:[&\s](?:\d+_)?(?:path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(?:\.(?:\d+_)?[A-Za-z]\w*)*=[^\s&\"']*)+"
No rg? (\d → [0-9], \s → [[:space:]], non-capturing groups → plain groups):
grep -rnE "(^|[?&\"'[:space:]])([0-9]+_)?(path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(\.([0-9]+_)?[A-Za-z][A-Za-z0-9_]*)*=[^[:space:]&\"']*([&[:space:]]([0-9]+_)?(path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(\.([0-9]+_)?[A-Za-z][A-Za-z0-9_]*)*=[^[:space:]&\"']*)+" .
Live-confirmed against a real stored predicate string in this repo
(bundles/core/src/test/java/.../CollectionServletTest.java, 1_group.0_property=...4_group.property=...
space-separated) — the previous version of this pattern (bare property/group\.\d+_group keys, &-only
separator) missed it entirely; a Smart-Collection-style query is exactly the case the paired
tuning-oak-query-indexes skill's Section B flags as needing manual field identification, so silently
missing it here means it never even reaches that step.
QueryBuilder, map/predicate form with literal keys — map.put("path", ...); map.put("type", ...)
or {"path": ..., "type": ...}:
rg -n -U -P "\"(?:\d+_)?(?:path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(?:\.(?:\d+_)?[A-Za-z]\w*)*\"[\s\S]{0,150}?\"(?:\d+_)?(?:path|type|property|fulltext|group|nodename|orderby|relativedaterange|daterange|boolproperty|tagid|similar)(?:\.(?:\d+_)?[A-Za-z]\w*)*\""
Same key list as the query-string pattern above (and the same fix applies here: this used to require bare
property(\.\d+)?/group\.\d+_group keys only, which misses numeric-prefixed nested keys like
"1_group.0_property" if a predicate map is ever built with literal quoted keys in that shape instead of
named constants).
No portable fallback for this one — it needs rg -U's cross-line [\s\S]{0,150}? matching; a
line-based grep -E cannot express "two keys within 150 chars, possibly across lines" at all. Without
rg, degrade to a two-step manual correlation instead: grep -rn '"path"', grep -rn '"type"' (repeat
per key), then open each hit and read the surrounding -B3 -A8 by hand to see whether the keys belong to
the same predicate map. Slower and noisier, but doesn't silently miss the construction sites.
Scope this one by file type before running it repo-wide — path/type are common JSON/config keys
with no JCR meaning at all, and combined with -U's cross-line matching this pattern is the noisiest of
the four; run unscoped and expect heavy noise from package-lock.json, generic *.json, and *.js.
Restrict to the languages that actually build QueryBuilder predicate maps and exclude generated/vendored
files, e.g. rg ... -g '*.java' -g '*.jsp' -g '*.js' -g '!**/target/**' -g '!**/node_modules/**' -g '!package-lock.json' (adjust the excludes to your stack's lockfiles/build output). Even scoped, expect
enough noise that you still need the -B3 -A8-and-read-by-hand step above — don't skip the scoping flags
and conclude the pattern is useless because an unscoped run is noisy; the real signal (a predicate map
built from numeric-prefixed literal keys, in a file with no createQuery(/PredicateGroup.create( call
for Technique 1 to anchor on) is still in there.
This flags a hit on the first two keys in a block. Pull -B3 -A8 context
and read the whole predicate map by hand — don't trust the snippet alone.
This pattern only catches literal key strings at the call site — if keys
come from named constants (params.put(PATH_KEY, ...)), it will not match;
Technique 1 is what catches that case, via the PredicateGroup.create(
anchor.
Workflow
- Run Technique 1 first — it's the one that survives dynamic query construction. Build the wrapper/caller inventory before falling back to text search.
- Run Technique 2 as a supplementary pass, especially over non-Java files (JSP, JS, HTL, config) where there's no Java API call to anchor on.
- For each hit from either technique, open the surrounding code to confirm it's really a query (not a comment, test fixture, or dead code) and note what it queries against.
- Merge into one inventory: file:line of the construction site, query type, path/nodetype/properties touched, and every caller/trigger path that reaches it (from Technique 1 step 3). That's the input to an index-coverage check.
Common mistakes
- Relying only on the literal-shape regex and concluding "no queries found" when it comes back empty — an empty Technique-2 result says nothing about whether the codebase calls the query APIs programmatically. Always run Technique 1.
- Finding a wrapper's query-construction site and stopping there without tracing its callers (Technique 1 step 3) — the same wrapper is often invoked from many unrelated features, each a distinct trigger worth its own inventory row.
- Trusting the map-style regex's single snippet as the complete predicate set — it only proves two literal keys are nearby, not which keys or how many.
- Forgetting
-ion the SQL2 pattern (select/SELECTboth appear in the wild). - Running only the XPath/SQL2 patterns and skipping QueryBuilder — in AEM code QueryBuilder is often the majority of queries, not raw JCR queries.
- Assuming
grep -Pis a safe substitute whenrgisn't installed — GNU grep supports it, but macOS's stock BSD grep doesn't (grep: invalid option -- P), so it fails the same wayrgdoes when missing. Check withcommand -v rgfirst and use the portablegrep -Efallback given under each pattern.
版本历史
-
plugin/stardust/v0.43.4
GitHub ↗
原版更新说明
## [0.43.4](https://github.com/adobe/skills/compare/plugin/stardust/v0.43.3...plugin/stardust/v0.43.4) (2026-11-21)
-
rollout-v1.3.1
GitHub ↗
原版更新说明
## [1.3.1](https://github.com/adobe/skills/compare/rollout-v1.3.0...rollout-v1.3.1) (2026-11-21)
-
plugin/aem-edge-delivery-services/v1.3.5
GitHub ↗
原版更新说明
## [1.3.5](https://github.com/adobe/skills/compare/plugin/aem-edge-delivery-services/v1.3.4...plugin/aem-edge-delivery-services/v1.3.5) (2026-11-20) ### Bug Fixes * **deps:** update dependency playwright to v1.65.1 ([#777](https://github.com/adobe/skills/issues/777)) ([c6c5233](https://github.com/adobe/skills/commit/c6c5233558a28bb8fde8ede408c35ac47c81cf8e)) * **deps:** update dependency pnpm to v12.21.0 ([#778](https://github.com/adobe/skills/issues/778)) ([a9e7de9](https://github.com/adobe/skills/commit/a9e7de976a969259a1d30ef8d24a4ef699d6d49e))
-
migrate-header-v1.0.4
GitHub ↗
原版更新说明
## [1.0.4](https://github.com/adobe/skills/compare/migrate-header-v1.0.3...migrate-header-v1.0.4) (2026-11-20) ### Bug Fixes * **deps:** update dependency pnpm to v12.21.0 ([#778](https://github.com/adobe/skills/issues/778)) ([a9e7de9](https://github.com/adobe/skills/commit/a9e7de976a969259a1d30ef8d24a4ef699d6d49e))
-
personalize-v1.0.1
GitHub ↗
原版更新说明
## [1.0.1](https://github.com/adobe/skills/compare/personalize-v1.0.0...personalize-v1.0.1) (2026-11-20) ### Bug Fixes * **deps:** update dependency playwright to v1.65.1 ([#777](https://github.com/adobe/skills/issues/777)) ([c6c5233](https://github.com/adobe/skills/commit/c6c5233558a28bb8fde8ede408c35ac47c81cf8e))
此处仅展示最近 5 个版本。 在原站查看完整版本历史 ↗
当前收录版本
0.0.1
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 针对 AEM/Oak 代码库中 JCR 查询审计的实际需求,提供端到端解决方案
- 覆盖动态查询构建和静态文本两种场景,实用性强
亮点
- 触发条件清晰明确,涵盖 Oak 索引审计、迁移、性能调查等核心场景
- 边界定义良好,不易与其他 Skill 混淆
待提升项
-
description写错位置 原报告严重程度:轻微
主描述内容在 frontmatter 和 skill_body 中重复出现,frontmatter 应为唯一权威来源
改进建议:将详细描述移至 frontmatter 的 description 字段,skill_body 中通过引用或摘要方式呈现
-
缺少 When to Use 章节 原报告严重程度:轻微
skill_body 中未设置独立的 'When to Use' 章节,尽管描述中已涵盖相关内容
改进建议:在 skill_body 开头添加显式的 'When to Use' 章节以提升可读性
亮点
- Technique 1 和 Technique 2 分阶段设计合理,步骤清晰
- 包含常见错误提醒和工作流指导,结构完整
亮点
- 提供 ripgrep 和 grep 双重工具支持,并明确 macOS BSD grep 的兼容性问题
- 对每种模式均给出 fallback 方案,异常处理周全
- 强调手动复核必要性,避免误判
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 34 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
翻译待完成,请参阅来源文档。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。