gitignore-pattern-matching
暂无简介
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 13
- Forks
- 2
03 SKILL.md 正文
/gitignore-pattern-matching
When to Use
- Agent needs to skip files matching
.gitignorepatterns (avoid reading secrets/node_modules) - Building an access-control gate: which files an agent is allowed to read
- Parsing
.claudeignoreor custom ignore files for sandbox boundaries - Filtering output of file listings before passing to LLM context
Do NOT use for
- Security-critical access control alone (filesystem permissions are ground truth)
- Glob matching without gitignore semantics (use [[glob-minimatch-patterns]])
Basic ignore check
import ignore from 'ignore'
import { readFileSync, readdirSync } from 'fs'
// Load .gitignore rules
const ig = ignore()
ig.add(readFileSync('/workspaces/yana-ai/.gitignore', 'utf8'))
// Add custom agent rules
ig.add([
'releases/logs/',
'*.env',
'**/.env*',
'node_modules/',
'**/__pycache__/',
])
// Check single path (must be relative, no leading /)
ig.ignores('releases/logs/tool-proxy.log') // true
ig.ignores('core/rules/foo.md') // false
Filter file list
function listAgentReadableFiles(projectRoot: string): string[] {
const ig = ignore()
// Load repo .gitignore
try {
ig.add(readFileSync(`${projectRoot}/.gitignore`, 'utf8'))
} catch { /* no .gitignore */ }
// Agent-specific extra ignores
ig.add(['*.secret','**/*.key','**/*.pem','*.env*','.claude/settings*'])
const allFiles = getAllFiles(projectRoot) // recursive fs walk
const relative = allFiles.map(f => f.replace(projectRoot + '/', ''))
return ig.filter(relative)
}
Parse custom .claudeignore
import { existsSync, readFileSync } from 'fs'
function loadClaudeIgnore(root: string): ReturnType<typeof ignore> {
const ig = ignore()
const claudeignorePath = `${root}/.claudeignore`
if (existsSync(claudeignorePath)) {
ig.add(readFileSync(claudeignorePath, 'utf8'))
}
// Always block secrets regardless
ig.add(['**/*.env','**/*.key','**/*.pem','**/*.p12','**/*.pfx','**/.aws/'])
return ig
}
Bash equivalent
# Use git ls-files to list only tracked + unignored files
git -C /workspaces/yana-ai ls-files --cached --others --exclude-standard \
| grep -v '^releases/logs/'
# Check if a specific file would be ignored
git check-ignore -v releases/logs/session.log
Anti-Fake-Pass Checklist
❌ Absolute paths passed to ig.ignores() → always returns false (must be relative)
❌ Leading slash in pattern → matches root only, not subdirectories
❌ Trailing slash on file rule → only matches directories, not files
❌ .gitignore negation (!pattern) not loaded in order → later negations override
❌ node_modules/ not ignored → agent reads 50k+ files, floods LLM context
❌ .env files not explicitly blocked → secrets leak into agent context
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
暂无简介