{
  "slug": "gh-repo-read-file-and-read-dir-inspect-repository-contents-ef3a7f403c99",
  "title": "gh repo read-file and read-dir inspect repository contents",
  "tools": [
    "gh"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-06-17T19:55:07.000Z",
  "announced_at": "2026-06-17T19:55:07.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When you need to inspect a GitHub repository without cloning it, use `gh repo read-file` to read a file or save it locally, and `gh repo read-dir` to list directory entries. Both use the default branch unless you pass `--ref`; both commands are in preview.",
    "examples": [
      "gh repo read-file <path> --repo <owner>/<repo>",
      "gh repo read-file <path> --repo <owner>/<repo> --ref <branch|tag|commit> --output <local-path>",
      "gh repo read-dir <directory-path> --repo <owner>/<repo>"
    ],
    "gotchas": [
      "Version: v2.95.0",
      "Availability: Preview; subject to change without notice.",
      "<path> (required): Repository file path for `read-file`.",
      "<directory-path>: Directory to list; omit to list the repository root.",
      "--repo <[HOST/]OWNER/REPO>: Select a repository.",
      "--ref <branch|tag|commit>: Read or list at the specified branch, tag, or commit; defaults to the repository’s default branch.",
      "--output <path>: Write file contents to a local path instead of stdout.",
      "--clobber: Overwrite the output path if it already exists.",
      "--json <fields>: Output JSON with selected fields.",
      "--jq <expression>: Filter JSON output using a jq expression.",
      "--template <string>: Format JSON output using a Go template.",
      "Prerequisite: Both commands are in preview and subject to change without notice.",
      "Both commands default to the repository’s default branch.",
      "`--ref` targets a branch, tag, or commit."
    ]
  },
  "why_it_matters": "Inspect a repository’s files or directory without cloning it.",
  "sources": [
    "https://github.com/cli/cli/releases/tag/v2.95.0",
    "https://cli.github.com/manual/gh_repo_read-file",
    "https://cli.github.com/manual/gh_repo_read-dir"
  ],
  "rank": 0.99045,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v1+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "backfill-20261007",
    "verdict_id": "backfill-20261007:backfill-20261007-10fe8a4b0cd695b8-0:gate",
    "evidence_hash": "023ac3c3fa994a3f363b79d5477aa642d378a2a7620e18c1a310227c17a3f304"
  },
  "review": {
    "draft_hash": "751c64ede403d38be78be8ab442680b951fce0f886371816b287e89e2b995506",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "backfill-20261007:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.99 >= 0.9; 2 needed) and Jev gave 0.81 (>= 0.6 needed)."
  }
}
