Skip to content

Commit 0d30913

Browse files
committed
feature: add tee-slow-output convention to plugin rules
1 parent c502b6c commit 0d30913

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

plugin/rules/tee-slow-output.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
mainAgent: true
3+
subAgents: [all]
4+
---
5+
## Tee Slow Process Output
6+
7+
**MANDATORY:** When running a slow command (build, test suite, long-running script), capture its output with `tee` so
8+
you can re-filter the output later without re-running the command.
9+
10+
**Rationale:** Slow commands can take minutes to complete. If you need to search the output for a different pattern or
11+
review a different section, re-running the command wastes significant time. Capturing the output to a log file lets you
12+
`grep`, `head`, `tail`, or otherwise re-filter the results instantly.
13+
14+
**Pattern:**
15+
16+
```bash
17+
# 1. Create a temporary log file
18+
LOG_FILE=$(mktemp /tmp/build-output-XXXXXX.log)
19+
20+
# 2. Run the slow command with tee to capture output
21+
mvn -f client/pom.xml test 2>&1 | tee "$LOG_FILE"
22+
23+
# 3. Later, re-filter without re-running the command
24+
grep -i "error" "$LOG_FILE"
25+
grep "FAILED" "$LOG_FILE"
26+
tail -50 "$LOG_FILE"
27+
```
28+
29+
**When NOT to tee:**
30+
- **Fast commands** (< 2 seconds) — the overhead of managing a log file outweighs the benefit
31+
- **Trivially small output** — if the full output fits in context, there is nothing to re-filter
32+
- **Commands in `run_in_background`** — background task output is already captured and retrievable
33+
34+
**Cleanup:** Delete the log file when you no longer need it. Do not leave temporary log files behind after the task is
35+
complete.
36+
37+
```bash
38+
rm -f "$LOG_FILE"
39+
```

0 commit comments

Comments
 (0)