テーマ: cli
-
ripgrepのデフォルトフィルタリングは、grep -rと比べてエージェントのコード検索を短縮する
仮説: ripgrepのデフォルトの無視ルール(gitignore対象、隠しファイル、バイナリファイルをスキップ)を使ってリポジトリを検索するコーディングエージェントは、除外設定のない`grep -r`を使うエージェントに比べて、タスクあたりの検索呼び出し回数が少なく、読み込む無関係な出力も少なくて済む。ビルド出力や依存関係の中でのヒットが発生しないためである。測定結果は報告しない。
-
Pythonのコマンドラインツールを設計する: argparse、main()、終了コード
インターフェースはコンソールスクリプトとして登録した`main(argv) -> int`関数にまとめ、argparseの`type`と`choices`で検証し、終了コードの慣習(0は成功、2は使用法エラー、1はその他の失敗、sysexitsのコードは文書化されている場合にのみ)に従い、結果はstdoutに、診断情報はstderrに出力し、SIGINTとbroken pipeを処理する。
-
How do teams run several coding agents in parallel git worktrees without their caches, hooks and ports colliding?
Open question: worktrees give each agent its own branch and files, and the git-worktree documentation says a linked worktree shares everything except per-worktree files such as HEAD and the index, so hooks and configuration are shared while build caches, dependency directories and local ports are often hard-coded; which conventions have kept parallel agent runs isolated, and what broke first?
-
grep, diff, cmp and test/[: exit code 1 means not-found, not failure
grep, diff, cmp and the test/[ builtin all use the same three-way scale: 0 for a positive result, 1 for a negative result that is not an error, and 2 (or >1) for real trouble. Reading 1 as a script failure is the most common misreading an agent makes with these tools.
-
コード検索の grep と ripgrep:再帰、フィルター、終了コード
GNU grep は -r で再帰検索し、--include と --exclude-dir で絞り込み、一致あり、なし、エラーに応じて 0、1、2 で終了する。ripgrep は同様の検索をデフォルトで行い、Git で無視されるファイル、隠しファイル、バイナリーファイルを飛ばす。空の結果を信じる前に、各ツールが何を省くかを把握する。
-
Locale and date pitfalls in coreutils: LC_ALL, character ranges and GNU versus BSD date
The locale silently changes sort order, what [a-z] matches, decimal separators and the default date format; scripts should set LC_ALL=C (or C.UTF-8) and TZ explicitly, request explicit date formats, and avoid GNU-only date -d or BSD-only date -v unless the platform is known.
-
SSH tunnels: local, remote and dynamic port forwarding
ssh -L exposes a remote service on a local port, -R exposes a local service on the remote host, -D provides a SOCKS proxy and -J hops through a bastion; combine them with -N, bind to localhost and set ExitOnForwardFailure so that a forward that could not be set up does not leave a silently useless session.
-
sort, uniq and comm: set operations on text that depend on sorted input
uniq only collapses adjacent duplicates, comm requires both inputs sorted in the same collation, and sort's order follows LC_COLLATE; run such pipelines under LC_ALL=C, pick the right key options (-n, -h, -V, -k, -t) and use comm -12 and comm -23 for intersections and differences.
-
Running Linux administrative commands non-interactively for unattended agents
Interactive defaults — a pager, a confirmation prompt, a locale that reformats numbers, a sudo password prompt with no terminal to answer it — are the most common reasons an unattended agent session hangs or misparses output on Linux. This article lists the flags and environment variables that turn each one off.
-
make as a task runner: phony targets, tabs and one shell per line
A Makefile is a workable entry point for a repository's commands if command targets are declared .PHONY, recipe lines start with a tab, and it is understood that each recipe line runs in its own shell unless .ONESHELL is set; keep the default goal harmless and keep real file dependencies real.
-
find and xargs without surprises: null-separated names, -exec + and dry runs
File names may contain spaces and newlines, so pass them from find to other programs with -print0 and xargs -0 (or find -exec ... {} +), test the selection with -print before adding -delete, and use xargs -r so that an empty list runs nothing.
-
jq を使ってコマンドラインで JSON を扱う
jq は JSON を読み、フィルターを適用し、結果を表示する。通常の文字列には -r、1行1オブジェクトには -c、値を安全に渡すには --arg と --argjson、null や false を終了コードにするには -e、構造を変えるには select、map、to_entries を使う。文字列連結でフィルターを組み立ててはならない。
-
Checking a served TLS certificate chain and its expiry from the command line with openssl
openssl s_client with -servername and -showcerts prints the certificates a server actually sends, which the manual describes as not a verified chain; openssl x509 reads subject, issuer, SANs and the notAfter date of each one, and openssl verify -untrusted rebuilds the chain against a trust store. Check every hostname, and IPv4 and IPv6 separately.
-
Debugging HTTP with curl: verbose output, timing breakdown and forcing the connection
Use curl -v or --trace-ascii to see the exact request and response, --write-out with time_namelookup, time_connect, time_appconnect, time_starttransfer and time_total to locate where the time goes, and --resolve or --connect-to to send a request to one specific server while keeping the Host header and TLS name intact.
-
sed and awk for line-oriented edits: substitution, fields and in-place changes
sed applies editing commands, chiefly s/regexp/replacement/, to each line; awk splits lines into fields and runs pattern-action pairs. Use sed for substitutions and deletions, awk for column work and small aggregations, and handle -i, -n and GNU-versus-BSD differences deliberately.
-
stash と切り替えを繰り返さず、git worktree で並行作業する
git worktree add は同じリポジトリにつながる二つ目の作業ディレクトリを作成する。これにより、緊急修正、レビュー、エージェントのタスクを、現在のチェックアウトに干渉せず、それぞれのブランチで進められる。一つのブランチを同時にチェックアウトできるのは一つの作業ツリーだけであり、作業ツリーの削除には rm ではなく git worktree remove を使う。
機械可読: JSON