9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
6.4 KiB
6.4 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-코드-포매팅-code-formatting | 코드 포매팅 (Code Formatting) | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
코드 포매팅 (Code Formatting)
매 한 줄
"매 style debate 의 종결자". Code formatting 은 코드의 visual structure (whitespace, indent, line breaks, quote style) 를 deterministic rule 로 enforce 하는 tooling 영역. 2026 현재 매 모든 mainstream language 는 official 또는 de-facto formatter 를 가지며 (Black, Ruff format, Prettier, gofmt, rustfmt, dart format, ktlint), CI 의 commit hook 의 universal 으로 적용. 매 "어떻게 보일지" 의 human discussion 의 X — 매 tool 의 결정.
매 핵심
매 formatter 의 철학
- Opinionated (매 ideal): 매 minimal config — Black, gofmt, Prettier. 매 bikeshedding 의 elimination.
- Configurable (매 legacy): 매 ESLint stylistic rules, autopep8 — 매 team config drift 의 risk.
- Idempotent:
format(format(x)) == format(x). 매 essential property — CI loop safety. - AST-based: 매 token stream 의 parse → reformat. 매 regex 의 X.
매 linter vs formatter
- Formatter: whitespace, line breaks, quotes (style only). 매 semantics 의 X-change.
- Linter: bugs, anti-patterns, unused vars (semantics). 매 ESLint, Ruff check, golangci-lint.
- 2026 trend: Ruff (Python) 의 both 의 unify —
ruff format+ruff check의 매 single binary. Biome (JS/TS) 의 same path.
매 응용
- Pre-commit hook:
pre-commit(Python),lefthook,husky의 매 staged file 의 format. - CI gate:
ruff format --check/prettier --check— diff 가 있으면 fail. - Editor on-save: VS Code
editor.formatOnSave: true+defaultFormatter. - Mass migration:
git ls-files | xargs ruff format— 매 single PR 의 entire repo reformat.
💻 패턴
Prettier (JS/TS/JSON/MD/CSS) — 2026 v3
// .prettierrc.json
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"plugins": ["prettier-plugin-tailwindcss"]
}
# format all files in repo
npx prettier --write .
# CI check
npx prettier --check .
Ruff format (Python) — 2026 default Python formatter
# pyproject.toml
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true # format code in docstrings
ruff format . # write
ruff format --check . # CI
ruff check --fix . # lint + autofix
Black (Python, legacy but stable)
[tool.black]
line-length = 100
target-version = ["py312"]
skip-string-normalization = false
gofmt / goimports (Go) — bundled with toolchain
gofmt -w ./...
goimports -w ./... # also organizes imports
// before
package main
import("fmt"
"os")
func main(){fmt.Println(os.Args)}
// after gofmt
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Args)
}
rustfmt (Rust)
# rustfmt.toml
edition = "2024"
max_width = 100
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
cargo fmt
cargo fmt -- --check # CI
EditorConfig (cross-tool baseline)
# .editorconfig — every editor respects this
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
[*.{js,ts,tsx,json}]
indent_size = 2
[*.py]
indent_size = 4
[Makefile]
indent_style = tab
Pre-commit hook (universal)
# .pre-commit-config.yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.0
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0
hooks:
- id: prettier
types_or: [javascript, typescript, json, markdown]
CI gate (GitHub Actions)
- name: Check formatting
run: |
ruff format --check .
ruff check .
npx prettier --check .
Mass-format ignore (avoid blame churn)
# .git-blame-ignore-revs
# Ruff format mass-apply 2026-04-15
abc123def456...
git config blame.ignoreRevsFile .git-blame-ignore-revs
매 결정 기준
| 상황 | Approach |
|---|---|
| Python 신규 프로젝트 | Ruff format (Black-compatible, 100x faster) |
| Python legacy | Black 유지 — Ruff 의 drop-in 의 가능 |
| JS/TS | Prettier 또는 Biome (faster, Rust-based) |
| Go | gofmt (no choice, no config) |
| Rust | rustfmt |
| 매 polyglot monorepo | dprint 또는 Trunk |
| Team debate 중 | Opinionated formatter 의 즉시 채택 — 매 discussion close |
기본값: Ruff (Python), Prettier 또는 Biome (web), gofmt (Go), rustfmt (Rust). 매 pre-commit + CI check.
🔗 Graph
- 부모: Code Quality · Developer Experience
- 변형: Linter · Static Analysis
- 응용: 153_pre-commit과_품질_게이트
- Adjacent: Prettier
🤖 LLM 활용
언제: Generated code 의 file write 후 항상 ruff format / prettier --write 의 run — LLM output 의 indent inconsistency 의 normalize. PR diff 의 minimize.
언제 X: Format-only PR 의 logic change 와 mix 의 X — separate commit / PR 로 분리. Reviewer 의 noise 의 reduction.
❌ 안티패턴
- Custom rules everywhere: 매 team-specific style 의 invention. 매 onboarding cost 의 increase. 매 Black/Prettier default 의 accept.
- Format on commit only: Editor save 의 X-format 의 경우 매 every commit 의 noise. Editor integration 의 essential.
- Format + logic 의 mixed PR: Review impossible. 매 separate PR.
- No CI check: Pre-commit 의 bypass 의 가능 (
-n). 매 CI 의 source of truth. tabWidthdebate: 매 EditorConfig 의 fix — once and forget.
🧪 검증 / 중복
- Verified (Prettier docs 2026, Ruff docs 0.6+, Go style guide).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — formatters (Ruff, Prettier, gofmt, rustfmt) + CI/pre-commit patterns |