agent-cli
Free別AIのCLI呼び出しを支援する。Codex以外のCLIを使う依頼で使う。 Codexへの相談・実装委譲は codex Skill を使う。Skill運用の移行は agent-skill-migrate、配置監査は overlay-audit を使う。
The English summary is being prepared. Showing the original description.
実行単位を持つ処理を書く・直すときに、記録する内容とlevelを定める。script、batch、bot、API処理、data処理などの実装や、log不足を調べるときに使う。typo修正や表示だけの変更には適用しない。
The English summary is being prepared. Showing the original description.
See how to installReview the instructions the agent will receive before you install.
実行単位を持つ処理(script、batch、bot、API処理、data処理など)を書く・直すときに適用する。typo修正や表示だけの変更には適用しない。
codeは最初からlogを多めに入れて書く。目的は、実行後にlogだけを読めば「何が入り、何をどう判断し、何件処理し、どこで何秒かかり、なぜ失敗したか」が分かること。後から足すのではなく、実装と同時に入れる。
| 種類 | 内容 | 例 |
|---|---|---|
| 入力 | 起動引数、設定値、読んだfileのpathと件数・期間・hash | loaded path=... rows=1440 start=... end=... |
| 判断 | 分岐ごとの結果と理由(閾値と実際の値) | skip item=alpha reason=value_below_min value=1.2e6 min=5e6 |
| 件数 | 入力・処理・成功・skip・失敗の件数 | done total=120 ok=117 skipped=2 failed=1 |
| 時間 | 処理全体と重い区間の所要時間 | fetch elapsed_ms=842 |
| 失敗 | 例外の種類、message、traceback、対象のID、retry回数、最終的な扱い | logger.exception(...) |
| 外部呼出 | 宛先(host/endpoint)、status code、件数、retry | GET host=api.example.com status=429 retry=2 |
DEBUG: 1件ごとの詳細、中間値。通常は出さず、調査時に有効にする。INFO: 開始・終了、入力の要約、主要な判断、件数、所要時間。通常運用で読む。WARNING: 続行できるが想定外のこと(欠損、fallback、retry、skip)。理由を必ず書く。ERROR: その単位の処理が失敗した。logger.exception でtracebackを残す。except: pass は書かない。続行するならWARNING以上で理由を残す。logger = logging.getLogger(__name__)(または用途名)を使い、print で代用しない。key=value」の形にし、grepと集計がしやすいようにする。値は %s 形式の引数で渡す。logs/<name>.log、または実行記録directory内)。main)で一度だけ行い、libraryの中では設定しない。***)。import logging
import time
import uuid
logger = logging.getLogger("batch_processor")
SAFE_CONFIG_KEYS = ("items", "start", "end", "min_value")
def setup_logging(log_path: str, level: int = logging.INFO) -> None:
fmt = "%(asctime)s %(levelname)s %(name)s %(message)s"
logging.basicConfig(
level=level,
format=fmt,
handlers=[logging.StreamHandler(), logging.FileHandler(log_path, encoding="utf-8")],
)
def run(config: dict, rows_by_item: dict[str, list[dict]]) -> dict:
run_id = uuid.uuid4().hex[:8]
t0 = time.perf_counter()
safe = {k: config.get(k) for k in SAFE_CONFIG_KEYS}
logger.info("start run_id=%s config=%s items=%d", run_id, safe, len(rows_by_item))
ok = skipped = failed = 0
for item, rows in rows_by_item.items():
value = sum(r["value"] for r in rows)
if value < config["min_value"]:
skipped += 1
logger.warning(
"skip run_id=%s item=%s reason=value_below_min value=%.0f min=%.0f",
run_id, item, value, config["min_value"],
)
continue
t1 = time.perf_counter()
try:
result = evaluate(rows)
except Exception:
failed += 1
logger.exception("evaluate_failed run_id=%s item=%s rows=%d", run_id, item, len(rows))
continue
ok += 1
logger.info(
"evaluated run_id=%s item=%s rows=%d result=%.4f elapsed_ms=%.0f",
run_id, item, len(rows), result, (time.perf_counter() - t1) * 1000,
)
elapsed = time.perf_counter() - t0
logger.info(
"done run_id=%s total=%d ok=%d skipped=%d failed=%d elapsed_s=%.2f",
run_id, len(rows_by_item), ok, skipped, failed, elapsed,
)
return {"ok": ok, "skipped": skipped, "failed": failed}
外部APIを呼ぶときは、tokenを含まない宛先とstatusだけを残す。
resp = session.get(url, params=params, timeout=10)
logger.info("http_get host=%s path=%s status=%d items=%d",
urlsplit(url).hostname, urlsplit(url).path, resp.status_code, len(resp.json()))
rg -i "token|secret|password|authorization" などで確認する。No reviews yet. Tell others what you thought.
No login needed. Share how it worked for you, ask a question, or note where it did not run.
No comments yet. Be the first to write one.
別AIのCLI呼び出しを支援する。Codex以外のCLIを使う依頼で使う。 Codexへの相談・実装委譲は codex Skill を使う。Skill運用の移行は agent-skill-migrate、配置監査は overlay-audit を使う。
The English summary is being prepared. Showing the original description.
明示されたCodex・CursorのSkill運用移行を、指定設計と既存点検に基づき適用する。一般的な指示ファイルの整理は instruction-refactor を使う。通常の実装依頼では起動しない。
The English summary is being prepared. Showing the original description.
明示されたリポジトリのSkill・Agent・呼出し・生成配布を点検または移行する。通常の実装・レビュー・調査では起動しない。一般的な指示ファイルの整理は instruction-refactor を使う。
The English summary is being prepared. Showing the original description.
デザインシステムの作成・監査・保守、デザイントークンやUIの一貫性・個性・アクセシビリティの改善に使う。
The English summary is being prepared. Showing the original description.
プロジェクトのデザインシステムを SSOT として作成・監査・更新する。トークン、デザインシステムに関わるアクセシビリティ、Typography、Motion、aesthetic direction の作業に使う。デザインシステムに紐づかない単発UI実装や個別デザインレビューには使わない。
The English summary is being prepared. Showing the original description.
AIに日記を書かせるスキル。会話を振り返り、AI視点の自由な日記風テキストを生成して保存する。「日記書いて」「AI日記」「日記風に振り返って」「感想を日記にして」「diary」「write a diary」といった日記・感想の依頼に使う。作業改善の振り返りは /retro、知見の記録や要約は /ai-ltm を使う。
The English summary is being prepared. Showing the original description.