unix-cli-best-practices
Safe, portable, and efficient command-line patterns for macOS/BSD Unix tools (grep, find, sed, awk, xargs, mdfind, pbcopy, open) and modern alternatives…
Skill by mordechai30
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mordechai30-unix-cli-best-practices
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/unix-cli-best-practices
What's inside
- Skill name
unix-cli-best-practices- Description
- Safe, portable, and efficient command-line patterns for macOS/BSD Unix tools (grep, find, sed, awk, xargs, mdfind, pbcopy, open) and modern alternatives (ripgrep, fd). Covers common shell scripting and one-liner use cases including fast searching, text processing, codebase navigation, and parallel execution.
- License
- BSD-3-Clause
- Instructions
- 173 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# Unix CLI best practices
This guide provides efficient, safe, and portable techniques for manipulating text and finding files from the command line on macOS. By default, macOS uses BSD-derived UNIX utilities (`grep`, `find`, `sed`, `awk`) which have subtle differences from their GNU/Linux counterparts.
When possible, use high-performance replacements (`ripgrep` and `fd`) which respect `.gitignore` rules by default and offer more ergonomic interfaces.
## Modern high-performance alternatives
Use these tools instead of standard BSD utilities for local codebase operations.
### ripgrep (`rg`)
Use `ripgrep` (`rg`) as the preferred tool for searching text. It is faster than standard `grep` and respects `.gitignore` rules by default.
Common use cases:
* Run `rg 'search_term'` to recursively search the current directory.
* Run `rg -S 'term'` to search case-insensitively unless the query contains uppercase letters. Use `rg -i 'term'` for strict case-insensitivity.
* Run `rg -g '*.ts' -g '!*.spec.ts' 'term'` to search `.ts` files while excluding `.spec.ts` files.
* Run `rg -v 'ignore_me'` to print lines that do not match the pattern.
* Run `rg -l 'term'` to list only the names of matching files. Combine with `rg -0` for null-terminated output suitable for `xargs`.
* Run `rg -F 'foo()'` to treat the search pattern as a fixed string rather than a regular expression.
* Run `rg -w 'const'` to match whole words only.
* Run `rg -C 2 'term'` to show two lines of surrounding context. Use `rg -B 2` for preceding context or `rg -A 2` for succeeding context.
Refer to `rg --help` for the complete options list.
### fd
Use `fd` as the preferred tool for traversing the filesystem and finding files. It is faster than standard `find` and respects `.gitignore` rules by default.
Common use cases:
* Run `fd 'pattern'` to find files matching the regex pattern anywhere in their path.
* Run `fd -e py -e txt` to filter results by file extensions.
* Run `fd -t d 'docs'` to find directories. Use `fd -t f` for files and `fd -t l` for symbolic links.
* Run `fd -H` to include hidden files, or `fd -I` to include ignored files (such as `node_modules`). Combine as `fd -HI` to search all files.
* Run `fd -p 'src/assets'` to match the pattern against the full path instead of just the filename.
* Run `fd -e log -x rm` to execute a command on each matching file individually. Use `-X` (e.g., `fd -e log -X rm`) to run the command once with all matching files as arguments.
* Run `fd -a 'pattern'` to return absolute paths instead of relative paths.
Refer to `fd --help` for the complete options list.
## Built-in tools for macOS and BSD
Use these built-in utilities only when `rg` and `fd` are unavailable. Apply precise filters to prevent performance degradation.
### Efficient searching with grep
Do not use `grep | grep -v 'unwanted_dir'` to exclude directories. This approach reads all files before filtering them. Use native exclusion arguments instead to exclude directories at the filesystem level:
```bash
# Slow: reads binary and ignored files
grep -R "pattern" . | grep -v "node_modules"
# Fast: skips the directory completely at the filesystem level
grep -R --exclude-dir=node_modules --exclude-dir=.git "pattern" .
```
Common `grep` flags:
* `-r` or `-R` to search recursively. `-R` follows symbolic links, while `-r` does not.
* `-I` to ignore binary files for faster execution and clean output.
* `--exclude="*.min.js"` to ignore files matching a specific glob.
* `--include="*.dart"` to search only files matching a specific glob.
* `-l` to print only the names of files containing matches.
* `-Z` to print a null character after each filename, which is useful when piping to `xargs -0`.
Example of safely deleting files containing a specific string:
```bash
grep -rlZ -I --exclude-dir=node_modules "DEPRECATED_API" . | xargs -0 rm
```
### High-performance traversal with find
Prevent `find` from traversing irrelevant directory trees by using the `-prune` option.
```bash
# Slow: traverses node_modules entirely, then filters output
find . -name "*.ts" | grep -v "node_modules"
# Fast: skips node_modules entirely
find . -name "node_modules" -prune -o -name "*.ts" -print
```
The expression `-name "node_modules" -prune` stops traversal when encountering a `node_modules` directory. The `-o` (OR) operator specifies that for any other directory or file ending in `.ts`, the path is printed.
### macOS portability with sed
macOS uses BSD `sed`, which differs from GNU `sed` in its handling of in-place editing.
Use the `-i` option with an explicit backup extension. To edit in-place without creating a backup, provide an empty string:
```bash
# Edit in-place without creating a backup
sed -i '' 's/oldName/newName/g' filename.txt
# Edit in-place and create a backup named filename.txt.bak
sed -i '.bak' 's/oldName/newName/g' filename.txt
```
Use the `-E` option to enable extended regular expressions, avoiding the need to escape parentheses and plus signs:
```bash
sed -E 's/(foo|bar)+/baz/g' file.txt
```
### Codebase analysis with awk
Use `awk` for line-by-line data extraction and text processing.
Common use cases:
* Print specific columns from space-separated input:
```bash
ls -l | awk '{print $1, $3}'
```
* Find and print duplicate lines in a file without sorting them first:
```bash
awk '!seen[$0]++' filename.txt
```
* Filter lines based on column values (for example, printing lines where the third column is greater than 100):
```bash
awk '$3 > 100' data.txtFrom mordechai30/flutter-dart-skills, BSD-3-Clause.
More from mordechai30/flutter-dart-skills
- 0.570score
code-documentation
mordechai30
Guide for writing effective code documentation, including docstrings, JSDoc, dartdoc, and implementation comments.
SkillAFreshness: AClaude Code +9 - 0.570score
api-review
mordechai30
Reviews the specified code against the canonical API Design guidelines.
SkillAFreshness: AClaude Code +9 - 0.570score
code-review
mordechai30
Performs a comprehensive, multi-step code review of pull requests or local code changes, using iterative refinement (generation, critique, synthesis) to…
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-gpu-scene-rendering
mordechai30
Build efficient Flutter GPU or flutter_scene render loops, including draw state, instancing, attachment formats, and off-screen render-to-texture output.
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-scene-assets-shaders
mordechai30
Import and animate Scene geometry and textures; author current .fmat materials or Flutter GPU shader bundles; bind shader resources from Dart.
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-gpu-scene-setup
mordechai30
Set up a Flutter app for current Flutter GPU and flutter_scene rendering across native and web targets, including the Scene asset build hook.
SkillAFreshness: AClaude Code +9 - 0.561score
dart-build-cli-app
mordechai30
Build Dart command-line tools with sound argument parsing, streams, exit status, packaging, and subprocess behavior.
SkillAFreshness: AClaude Code +9 - 0.561score
natural-writing
mordechai30
Contains well-defined rules for creating natural, accurate, and readable writing.
SkillAFreshness: AClaude Code +9 - 0.559score
dart-resolve-package-conflicts
mordechai30
Diagnose and resolve Dart or Flutter pub dependency conflicts.
SkillAFreshness: AClaude Code +9 - 0.559score
dart-collect-coverage
mordechai30
Collect and inspect LCOV test coverage for Dart or Flutter projects.
SkillAFreshness: AClaude Code +9 - 0.556score
dart-fix-runtime-errors
mordechai30
Diagnose and fix observed Dart or Flutter runtime failures from a stack trace, failing test, or running app.
SkillAFreshness: AClaude Code +9 - 0.556score
dart-run-static-analysis
mordechai30
Run Dart or Flutter static analysis, interpret diagnostics, and apply focused analyzer fixes.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 29, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- BSD-3-Clause
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from mordechai30
- 0.570score
api-review
mordechai30
Reviews the specified code against the canonical API Design guidelines.
SkillAFreshness: AClaude Code +9 - 0.570score
code-documentation
mordechai30
Guide for writing effective code documentation, including docstrings, JSDoc, dartdoc, and implementation comments.
SkillAFreshness: AClaude Code +9 - 0.570score
code-review
mordechai30
Performs a comprehensive, multi-step code review of pull requests or local code changes, using iterative refinement (generation, critique, synthesis) to…
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-scene-assets-shaders
mordechai30
Import and animate Scene geometry and textures; author current .fmat materials or Flutter GPU shader bundles; bind shader resources from Dart.
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-gpu-scene-rendering
mordechai30
Build efficient Flutter GPU or flutter_scene render loops, including draw state, instancing, attachment formats, and off-screen render-to-texture output.
SkillAFreshness: AClaude Code +9 - 0.561score
flutter-gpu-scene-setup
mordechai30
Set up a Flutter app for current Flutter GPU and flutter_scene rendering across native and web targets, including the Scene asset build hook.
SkillAFreshness: AClaude Code +9
Cite this page
unix-cli-best-practices skill. Agent Mart. https://agentmart.dev/skills/mordechai30-unix-cli-best-practices (last updated 2026-10-24)