Install
$ agentstack add skill-cogni-ai-ou-cogni-ai-agent-skills-context-aware-ops ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Context-Aware Operations Skill
This skill provides patterns and techniques for managing large files and command outputs efficiently, preventing context window exhaustion while maintaining effective problem-solving capabilities.
When to Use
- Before executing commands that might produce large output
- Before reading any file in the codebase
- When debugging issues that might involve large resources
- When searching through codebases
- When working with logs, build outputs, or data files
When Not to Use
- For trivially small, single-file edits where the overhead of checking file size slows down the workflow unnecessarily.
- When the user explicitly demands the full output of a specific file and context limits are known to be sufficient.
- For interactive terminal sessions where pagination tools (
less,more) are natively handled by the user.
Common Pitfalls
- Blind Dumping: Running
caton a build log without checking its size, instantly blowing out the LLM's context window. - Truncating Crucial Errors: Using
headto sample a file when the actual error message resides at the very end of the stack trace (wheretailwas needed). - Ignoring Binary Files: Attempting to read binary artifacts or minified JS without filtering, resulting in unreadable token noise.
Core Principle
Always check before you dump!
Never blindly dump large resources into your context. Always:
- Check the size first
- Use filtering if needed
- Focus on relevant portions only
File Size Checking
Check Line Count
# Fast line count
wc -l filename.txt
# Line count without filename
wc -l (wc -l >&2) | head -20
# Or separately
output_lines=$(command | wc -l)
echo "Command produced $output_lines lines"
if [ $output_lines -gt 100 ]; then
command | head -50
else
command
fi
Filter Common Patterns
# Show only errors and warnings
command 2>&1 | grep -E "error|warn|fail" -i
# Show only specific log levels
command | grep -E "ERROR|WARN|FATAL"
# Exclude verbose/debug lines
command | grep -v -E "DEBUG|TRACE|INFO"
# Show unique errors only
command 2>&1 | grep -i error | sort -u
Paginate Large Output
# First page
command | head -n 50
# Show summary instead of full output
command | wc -l
command | head -20 && echo "... (showing first 20 lines)"
command | tail -20 && echo "... (showing last 20 lines)"
Smart File Viewing Strategy
Decision Tree
#!/bin/bash
FILE=$1
# Check if file exists
if [ ! -f "$FILE" ]; then
echo "File not found: $FILE"
exit 1
fi
# Get line count
LINES=$(wc -l /dev/null || find . -type d | head -20
Context Window Budget Management
Track Usage Mentally
- Small files (2000 lines): Never dump completely
Prioritization Strategy
- Critical: Files directly related to the bug/feature
- Important: Dependencies and related modules
- Nice-to-have: Context and documentation
- Skip: Tangentially related or very large files
When Context is Running Low
# Instead of full file, show:
# 1. File summary
wc -l filename && head -20 filename
# 2. Function/class list
grep -E "^(def|class|function|export)" filename
# 3. Specific section only
sed -n '/start_marker/,/end_marker/p' filename
# 4. Just the relevant function
awk '/^def target_function/,/^def [^t]/' filename.py
Advanced Techniques
Pipe Chains for Efficiency
# Find, filter, and limit in one go
find . -name "*.log" -exec grep -l "ERROR" {} \; | head -10
# Search multiple files, show unique results
grep -rh "pattern" . | sort -u | head -20
# Complex filtering in stages
cat large.txt | \
grep -i "keyword" | \
grep -v "noise" | \
sort -u | \
head -30
Binary Search for Large Files
# Find approximate location of pattern
total_lines=$(wc -l &1 | grep -E "error|warn" -i || echo "Install successful"`
3. **Don't**: `git log`
**Do**: `git log --oneline -20` or `git log --oneline | head -20`
4. **Don't**: `docker logs container`
**Do**: `docker logs --tail 100 container` or `docker logs container 2>&1 | grep -i error`
5. **Don't**: `./run_tests.sh`
**Do**: `./run_tests.sh 2>&1 | tee >(wc -l >&2) | grep -E "fail|error|pass" -i | head -50`
## Remember
- **Size matters**: Always check before you dump
- **Filter first**: Use grep, head, tail, sed, awk
- **Focus**: Only show what's relevant to the current task
- **Summarize**: When in doubt, show a summary rather than everything
- **Iterate**: You can always come back for more details if needed
## Related Skills
- **shell**:
You MUST load this skill when handling shell commands with performance monitoring or timeouts.
Your context window is precious - use it wisely!
## Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- **Author:** [Cogni-AI-OU](https://github.com/Cogni-AI-OU)
- **Source:** [Cogni-AI-OU/cogni-ai-agent-skills](https://github.com/Cogni-AI-OU/cogni-ai-agent-skills)
- **License:** MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.