glob-minimatch-patterns
暂无简介
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 13
- Forks
- 2
03 SKILL.md 正文
/glob-minimatch-patterns
When to Use
- Filter skill/rule/script file lists by glob pattern (core/**/*.sh)
- Implement
.gitignore-style file exclusion in agent tools - Build allowlists/denylists for which files agents can read or write
- Validate file paths before passing to sandboxed commands
Do NOT use for
- Directory traversal — use [[filesystem-isolation-chroot]] for path containment
- User-supplied regex patterns (use [[regex-escape-redos-guard]] first)
Basic matching
import { minimatch } from 'minimatch'
// Single match
minimatch('core/scripts/tool-proxy.sh', 'core/**/*.sh') // true
minimatch('core/rules/foo.md', 'core/**/*.sh') // false
// Options
minimatch('README.MD', '**/*.md', { nocase: true }) // true
minimatch('.hidden', '**', { dot: true }) // true (dot:true matches dotfiles)
Batch file filtering
import { minimatch } from 'minimatch'
import { readdirSync } from 'fs'
import { join } from 'path'
function filterFiles(
dir: string,
patterns: string[],
negations: string[] = []
): string[] {
const allFiles = readdirSync(dir, { recursive: true, withFileTypes: false }) as string[]
return allFiles.filter(f => {
const rel = f.replace(/\\/g, '/') // normalize Windows paths
const included = patterns.some(p => minimatch(rel, p, { dot: false }))
const excluded = negations.some(p => minimatch(rel, p, { dot: false }))
return included && !excluded
})
}
// Example: all skill files, excluding drafts
const skills = filterFiles(
'/workspaces/yana-ai/core/skills',
['*/SKILL.md'],
['**/draft-*', '**/*.bak']
)
Build file access allowlist for sandbox
const READABLE_PATTERNS = [
'core/skills/**/*.md',
'core/rules/**/*.md',
'README.md',
'MANIFEST.json',
]
const WRITABLE_PATTERNS = [
'releases/**',
'core/memory/**',
]
function checkAccess(path: string, mode: 'read' | 'write'): boolean {
const patterns = mode === 'read' ? READABLE_PATTERNS : WRITABLE_PATTERNS
return patterns.some(p => minimatch(path, p, { matchBase: false }))
}
Brace expansion
import { minimatch, braceExpand } from 'minimatch'
// Expand patterns before matching
const patterns = braceExpand('core/{skills,rules,scripts}/**/*.{md,sh}')
// → ['core/skills/**/*.md', 'core/skills/**/*.sh', 'core/rules/**/*.md', ...]
Anti-Fake-Pass Checklist
❌ matchBase:true — 'foo.sh' matches 'deeply/nested/foo.sh' unexpectedly
❌ dot:false (default) — patterns miss dotfiles (.claude/, .gitignore)
❌ Path not normalized (\\→/) on Windows — all matches fail
❌ User-supplied glob not validated — **/../../../etc/passwd traversal
❌ Glob on absolute paths — minimatch expects relative paths from a root
❌ No negation — cannot express "all .md except drafts" without both arrays
04 同仓库更多 Skills
openai--sentry--sentry
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.
ito-basket-compare
Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.
implementing-network-traffic-baselining
Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling
detecting-evasion-techniques-in-endpoint-logs
Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.
implementing-microsegmentation-with-guardicore
Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.
ramdisk-tmpfs-patterns
暂无简介