c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4.7 KiB
4.7 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-codegen | Codegen (GraphQL, OpenAPI, Schema-driven) | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Codegen (Schema-driven Code Generation)
매 한 줄
"매 schema 가 single source of truth". Codegen 은 GraphQL/OpenAPI/Protobuf schema 에서 type 과 client code 를 자동 생성 — 매 manual sync 의 X, drift 의 zero, refactor 매 compile-time safe.
매 핵심
매 주요 도구 (2026)
- GraphQL:
@graphql-codegen/cli(client preset),gql.tada(zero-config inline). - OpenAPI:
openapi-typescript(types),openapi-fetch(typed client),orval(React Query hooks). - gRPC/Protobuf:
bufbuild/protobuf-es,connect-es. - DB schema:
kysely-codegen,drizzle-kit, Prisma.
매 출력 종류
- Type definitions only (lightweight).
- Typed client (operations + types).
- Hooks/composables (React Query, SWR, urql).
- Server stubs (resolvers, controllers).
매 watch vs build-time
- Dev: watch mode → 매 save 시 regen.
- CI:
--check로 매 schema/code drift 검출. - Pre-commit: 매 generated files 매 staged 보장.
💻 패턴
GraphQL client preset (@graphql-codegen/cli)
# codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://api.example.com/graphql',
documents: ['src/**/*.{ts,tsx}'],
generates: {
'src/gql/': {
preset: 'client',
config: { useTypeImports: true, scalars: { DateTime: 'string' } },
},
},
};
export default config;
Using generated graphql() (typed documents)
import { graphql } from '@/gql';
import { useQuery } from '@tanstack/react-query';
const FlightSearch = graphql(`
query FlightSearch($from: String!, $to: String!) {
flights(from: $from, to: $to) { id price airline }
}
`);
export function useFlights(vars: { from: string; to: string }) {
return useQuery({
queryKey: ['flights', vars],
queryFn: () => request('/graphql', FlightSearch, vars),
});
}
gql.tada (zero-config alternative)
import { graphql } from 'gql.tada';
const Query = graphql(`
query Me { me { id email } }
`);
// 매 inferred 매 fully typed — no codegen step
openapi-typescript + openapi-fetch
npx openapi-typescript ./openapi.yaml -o ./src/api/schema.ts
import createClient from 'openapi-fetch';
import type { paths } from './api/schema';
const api = createClient<paths>({ baseUrl: 'https://api.example.com' });
const { data, error } = await api.GET('/users/{id}', {
params: { path: { id: '42' } },
});
// data 매 매 fully typed
orval — React Query hooks from OpenAPI
// orval.config.ts
export default {
api: {
input: './openapi.yaml',
output: {
target: './src/api/generated.ts',
client: 'react-query',
mode: 'tags-split',
},
},
};
Drizzle Kit — DB schema introspection
drizzle-kit introspect:pg --connectionString=$DATABASE_URL --out=./src/db
CI drift check
# .github/workflows/codegen-check.yml
- run: pnpm codegen
- run: git diff --exit-code src/gql src/api
Husky pre-commit
# .husky/pre-commit
pnpm codegen && git add src/gql src/api
매 결정 기준
| 상황 | 도구 |
|---|---|
| GraphQL + React/Vue | @graphql-codegen client preset |
| GraphQL + want zero step | gql.tada |
| OpenAPI types only | openapi-typescript |
| OpenAPI + hooks | orval |
| DB-first | Drizzle / Prisma / Kysely codegen |
기본값: GraphQL → client preset; REST → openapi-typescript + openapi-fetch.
🔗 Graph
- 부모: Type-Safety
- 변형: OpenAPI · gRPC
- 응용: React-Query
- Adjacent: Contract-Testing
🤖 LLM 활용
언제: schema-driven API integration / 매 type drift 매 painful 한 monorepo. 언제 X: 매 throwaway prototype, schema 매 unstable.
❌ 안티패턴
- Hand-writing GraphQL types: 매 drift 의 zero-day issue.
- Committing nothing then expecting safety: 매 generated files 매 commit + CI check 둘 다 필요.
- Running codegen only locally: 매 CI drift check 의 X 면 PR 매 깨짐.
🧪 검증 / 중복
- Verified (the-guild.dev / openapi-ts.dev / orval.dev official docs).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — codegen tools (GraphQL/OpenAPI) with patterns |