Agent skill
context-efficiency
Filter data at the source before it enters context. Use when querying APIs, CLIs, or databases where the full output would be large. Prefer structured output + jq/python filtering over dumping and scanning. Trigger phrases: "find the entity for", "get the ID of", "which service handles", "what's the value of", or any time you'd otherwise dump a large dataset to find one thing.
Install this agent skill to your Project
npx add-skill https://github.com/edmundmiller/dotfiles/tree/main/config/agents/skills/context-efficiency
SKILL.md
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 → use it, then pipe to jq or python3 -c
└─ No → use grep/awk to pre-filter, or hit the raw API with query params
jq patterns
# Get one field from an array of objects
tool -o json | jq -r '.[0].field'
# Filter array by condition
tool -o json | jq '[.[] | select(.state == "on")]'
# Case-insensitive name search
tool -o json | jq -r '.[] | select(.attributes.friendly_name | test("couch"; "i")) | .entity_id'
# Count by group
tool -o json | jq 'group_by(.state) | map({state: .[0].state, count: length})'
# Pluck two fields
tool -o json | jq -r '.[] | [.entity_id, .state] | @tsv'
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()))
"
Tool-specific examples
Home Assistant (hass-cli)
hass-cli -o json state list 'light.*' | jq -r '.[] | select(.state=="on") | .entity_id'
hass-cli -o json area list | jq -r '.[] | [.area_id, .name] | @tsv'
hass-cli -o json device list | jq '[.[] | select(.area_id == "kitchen")]'
GitHub CLI
gh pr checks 42 --json name,state | jq -r '.[] | select(.state=="FAILURE") | .name'
gh issue list --json number,title,labels | jq '[.[] | select(.labels[].name == "bug")]'
gh api repos/:owner/:repo/pulls --jq '.[].head.ref'
Nix
nix eval .#nixosConfigurations.nuc.config.environment.systemPackages --json | jq -r '.[].name' | grep hass
Database
-- Always: WHERE + LIMIT over SELECT *
SELECT entity_id, state FROM states WHERE domain = 'light' ORDER BY last_changed DESC LIMIT 20;
Anti-patterns
# ❌ dumps hundreds of entities to find one
hass-cli state list
# ✅ returns exactly what you need
hass-cli -o json state list 'light.*' | jq -r '.[] | select(.attributes.friendly_name | test("desk"; "i")) | .entity_id'
# ❌ loads full PR list into context
gh pr list
# ✅ targeted
gh pr list --json number,title --jq '.[] | select(.title | test("fix"; "i"))'
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
zbench
Benchmark interactive zsh performance with zsh-bench and track regressions. Use when benchmarking shell startup, comparing zsh latency after config changes, investigating slow shell, or running git bisect on performance. Trigger phrases: "benchmark zsh", "shell is slow", "zbench", "zsh-bench", "shell startup time", "profile zsh", "zsh performance".
nix-rebuild
Rebuild nix-darwin/NixOS system after dotfiles changes. Use when config files managed by Nix (lazygit, ghostty, etc.) need to be regenerated, or after editing any .nix file in the dotfiles repo.
hass-config-flow
Interact with Home Assistant via the REST API on a NixOS host. Use when adding integrations, querying entities, managing config flows, creating API tokens, or automating HA setup programmatically. Also covers identifying device protocols (Matter, Zigbee, Thread, HomeKit) from the device registry. Trigger phrases: "add HA integration", "configure home assistant", "query HA entities", "create HA token", "HA REST API", "pair homekit", "set up matter in HA", "add spotify to HA", "is this device zigbee or thread", "what protocol is this device", "move devices to ZHA", "identify matter devices".
hass-declarative
Manage Home Assistant automations, scenes, and scripts declaratively via NixOS modules. Covers adding/editing/removing entities in the domain-based Nix structure, the ensureEnabled wrapper (initial_state enforcement), the sweep service that cleans orphaned entities, entity identity (IDs, slugs, unique_ids), the eval test assertions, and the build-time manifest. Trigger phrases: "add HA automation", "new scene", "new script", "remove automation", "declarative HA", "sweep unmanaged", "entity drift", "ghost entity", "orphaned automation", "HA domain file", "eval-automations test", "hass assertion", "ensureEnabled", "initial_state".
agenix-secrets
Create, edit, and wire up agenix-encrypted secrets in this dotfiles repo. Use when adding API keys, tokens, credentials, passwords, or any sensitive values to NixOS host configs. Trigger phrases: "add a secret", "encrypt with agenix", "new age secret", "hide this value", "agenix secret".
linear
Read-only Linear issue access via the Linear GraphQL API.
Didn't find tool you were looking for?