Skip to content
Skills Library
Data & analytics · Automation

context-efficiency

/context-efficiency

Filters large API, CLI, or database results before retrieval. Use when a query needs source-side selection or projection to avoid oversized output.

Repository
dotfiles ↗
Licence
MIT
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Filters large API, CLI, or database results before retrieval. Use when a query needs source-side selection or projection to avoid oversized output.

Original author description

Filters large API, CLI, or database results before retrieval. Use when a query needs source-side selection or projection to avoid oversized output.

How it works

  1. Decision tree
  2. Structured-output patterns
  3. jq/python fallback patterns
  4. Bounded command output
  5. Oversized tool results
  6. Tool-specific examples
  7. Anti-patterns
Original SKILL.md headings · 126 lines, 573 words
SKILL.md preview
---
name: context-efficiency
description: Filters large API, CLI, or database results before retrieval. Use when a query needs source-side selection or projection to avoid oversized output.
license: MIT
---

# Context Efficiency: Filter at the Source

Every token of noise in context is a token the model spends navigating instead
of reasoning. Spend a few tokens on a precise query; save many on the backend.

## Decision tree

```
Does the tool support structured output? (--json, -o json, --format json)
├─ Yes → select fields with jg when available; if `command -v jg` fails, use tool-native selectors, python3 -c, or jq instead of retrying
└─ No → pre-filter with path scopes, grep, head, API params, or SQL LIMIT
```

## Structured-output patterns

```bash

# Select one field or path
tool -o json | jg 'precise.selector'


# Select a set of fields from each array item via disjunction
tool -o json | jg '[*].(id|name|status)'


# Transform when selection is not enough
tool -o json | python3 -c 'import json,sys; print(json.load(sys.stdin)[0]["field"])'
```

## jq/python fallback patterns

Use these when the transformation is value-based filtering (not just path
selection) that `jg`'s path-query language cannot express.

```bash
# python3 -c patterns
# Count by state
tool -o json | python3 -c "
import json, sys; d = json.load(sys.stdin)
from collections import Counter; print(Counter(x['state'] for x in d))
"

# Find matching entity
tool -o json | python3 -c "
import json, sys; d = json.load(sys.stdin)
print(next(x['entity_id'] for x in d if 'couch' in x['attributes'].get('friendly_name','').lower()))
"
```

## Bounded command output

Before running commands that can dump a tree, log, search result, build output,
or API collection, add a path scope, `--limit`, `head`, structured selector, or
SQL `LIMIT`. Do not raise output-token caps to compensate for an unbounded
command. If output truncates, rerun a narrower command instead of scanning the
dump.

## Oversized tool results

If a read, MCP call, or CLI returns "output too large" or saves overflow to a
file, do not retry the same broad request. Recover with a narrower query:

1. Re-run the source tool with tighter fields, date ranges, IDs, channel/project
   filters, or lower limits.
2. If the tool saved an overflow artifact, search or read only the relevant
   ranges from that saved file.
3. Prefer summaries or metadata endpoints before transcripts, full logs, Slack
   exports, calendar event lists, or issue dumps.

```bash
# ❌ broad transcript/log dump
tool get-transcript --id "$id"

# ✅ metadata or filtered content first
tool get-notes --id "$id"
tool search --query '"exact error" after:2026-01-01' --limit 5
```

## Tool-specific examples

### Home Assistant (hass-cli)

```bash
hass-cli -o json state list 'light.*' | jg '[*].(entity_id|state|attributes.friendly_name)'
hass-cli -o json area list | jg '[*].(area_id|name)'
hass-cli -o json device list | jq '[.[] | select(.area_id=="kitchen") | {id,name,area_id}]'
```

### GitHub CLI

```bash
gh pr checks 42 --json name,state | jq '[.[] | select(.state!="SUCCESS") | .name]'
gh issue list --json number,title,labels --limit 30 | jq '[.[] | select(.labels[].name=="bug") | {number,title}]'
gh api repos/:owner/:repo/pulls --jq '.[].head.ref'
```

### Nix

```bash
nix eval .#packages.aarch64-darwin --apply builtins.attrNames --json | jg '[*]'
```

### Database

```sql
-- Always: WHERE + LIMIT over SELECT *
SELECT entity_id, state FROM states WHERE domain = 'light' ORDER BY last_changed DESC LIMIT 20;
```

## Anti-patterns

```bash
# ❌ dumps hundreds of entities to find one
hass-cli state list

# ✅ returns exactly what you need
hass-cli -o json state list 'light.*' | jq '.[] | select(.attributes.friendly_name | test("desk"; "i"))'

# ❌ loads full PR list into context
gh pr list

# ✅ targeted
gh pr list --json number,title --limit 30 | jq '[.[] | select(.title | test("fix";"i"))]'
```

Versions

RepositoryScoreLicence
This page · edmundmiller/dotfiles100MIT
Esposter/Esposter90Apache-2.0

Database snapshot: 13.11.2026 · package version c7aeb16bf92f (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

No similar skills in the database.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.