127 lines
3.5 KiB
Markdown
127 lines
3.5 KiB
Markdown
# 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
# 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:
|
|
|
|
```bash
|
|
# Create repo via API (example — adapt auth and endpoint to your forge)
|
|
TOKEN=$(cat $GIT_TOKEN_PATH)
|
|
curl -s -X POST "$GIT_REMOTE/api/v1/user/repos" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"name": "<project>-conventions", "auto_init": true, "default_branch": "master", "license": "MIT"}'
|
|
|
|
# Or use your forge's CLI:
|
|
# gh repo create $GIT_ORG/<project>-conventions --public --clone
|
|
# glab project create <project>-conventions
|
|
|
|
# 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
|
|
```
|