Files
codebase-analysis/references/commands.md
T
Rodin 6df0e383bc refactor: parameterize environment — no hardcoded paths
Configuration (CLONE_DIR, CLONE_HOST, GIT_REMOTE, GIT_ORG, GIT_TOKEN_PATH)
provided by invoker's workspace context. Commands reference shows
Gitea + GitHub examples.
2026-04-30 12:00:09 -07:00

3.5 KiB

Commands Reference

Shell patterns for each phase. Load only when you need the exact syntax — the SKILL.md tells you WHAT to look for; this tells you HOW.


Phase 1: Shape

# Clone (always full — never --depth 1)
cd $CLONE_DIR && git clone <url>

# Dimensions
du -sh <repo>
find . -name "*.go" | grep -v vendor | wc -l   # Go files
git log --oneline | wc -l                        # commits
git log --format="%an" | sort -u | wc -l         # contributors
ls -d */                                         # top-level dirs

Phase 2: Import Hierarchy

# Go: most-imported internal packages
grep -rh '"<module>/' --include="*.go" \
  | sed 's/.*"<module>\///' | sed 's/".*//' \
  | cut -d/ -f1 | sort | uniq -c | sort -rn | head -15

# Elixir: most-aliased modules
grep -rh "alias " --include="*.ex" \
  | sed 's/.*alias //' | cut -d. -f1-2 \
  | sort | uniq -c | sort -rn | head -15

Phase 3: Interfaces

# Go interfaces (skip test/mock/generated)
grep -rn "type.*interface {" --include="*.go" \
  | grep -v test | grep -v mock | grep -v _gen.go

# Elixir behaviours/protocols
grep -rn "@callback\|@behaviour\|defprotocol" --include="*.ex"

Phase 4: Quality Markers

# TODOs (non-test, note format)
grep -rn "TODO" --include="*.go" | grep -v test | wc -l
grep -rh "// TODO" --include="*.go" | head -5  # check format

# Other markers
grep -rn "FIXME\|HACK" --include="*.go" | grep -v test | wc -l

# Test ratio
find . -name "*_test.go" | wc -l    # test files
find . -name "*mock*" | wc -l       # mock files

Phase 6: Git Archaeology

# When was a file/pattern introduced?
git log --all --oneline --diff-filter=A -- path/to/file

# Who wrote it and why?
git log --format="%an%n%ad%n%s%n%b" <commit> -1

# When was a string added/removed (pickaxe search)?
git log -p -S "pattern_string" -- relevant/path/

# TODOs added with context
git log --all -p -S "TODO" -- lib/ \
  | grep "^commit\|^+.*TODO\|^-.*TODO" | head -20

# Find if full clone or shallow
git rev-parse --is-shallow-repository
# Unshallow if needed
git fetch --unshallow

Phase 7: PR Lookup

# Find PR by title/content
gh api "search/issues?q=repo:<org>/<repo>+<keywords>+type:pr" \
  --jq '.items[] | {number: .number, title: .title}'

# Read PR metadata
gh api repos/<org>/<repo>/pulls/<num> \
  --jq '{title, body: (.body | split("\n") | .[0:30] | join("\n")), comments, review_comments, created_at, merged_at}'

# Read review comments (the debate)
gh api "repos/<org>/<repo>/pulls/<num>/comments?per_page=30" \
  --jq '.[] | select(.body | length > 50) | {user: .user.login, body: (.body | split("\n") | .[0:5] | join("\n"))}'

# Read issue comments
gh api repos/<org>/<repo>/issues/<num>/comments \
  --jq '.[] | {user: .user.login, body: (.body | split("\n") | .[0:6] | join("\n"))}'

Output: Repo Creation & Push

Adapt to your git remote (Gitea, GitHub, GitLab, etc.):

# Gitea example:
GITEA_TOKEN=$(cat $GIT_TOKEN_PATH)
curl -s -X POST "https://<git-host>/api/v1/user/repos" \
  -H "Authorization: token $GITEA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "<project>-conventions", "auto_init": true, "default_branch": "master", "license": "MIT"}'

# GitHub example:
gh repo create $GIT_ORG/<project>-conventions --public --clone

# Clone, add content, push
cd <project>-conventions
git config user.name "<your-name>"
git config user.email "<your-email>"
# ... add files ...
git add -A && git commit -m "docs: initial conventions from <org>/<project>" && git push