universal-dev-standards 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/uds.js +75 -0
- package/bundled/core/ai-friendly-architecture.md +542 -0
- package/bundled/core/refactoring-standards.md +342 -120
- package/bundled/locales/zh-CN/README.md +210 -509
- package/bundled/locales/zh-CN/core/ai-friendly-architecture.md +306 -0
- package/bundled/locales/zh-CN/core/refactoring-standards.md +10 -9
- package/bundled/locales/zh-CN/docs/AI-AGENT-ROADMAP.md +82 -22
- package/bundled/locales/zh-CN/integrations/gemini-cli/GEMINI.md +35 -3
- package/bundled/locales/zh-CN/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +89 -3
- package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +8 -4
- package/bundled/locales/zh-CN/skills/claude-code/commands/refactor.md +178 -0
- package/bundled/locales/zh-CN/skills/claude-code/refactoring-assistant/SKILL.md +243 -97
- package/bundled/locales/zh-TW/README.md +211 -490
- package/bundled/locales/zh-TW/core/ai-friendly-architecture.md +306 -0
- package/bundled/locales/zh-TW/core/refactoring-standards.md +347 -125
- package/bundled/locales/zh-TW/docs/AI-AGENT-ROADMAP.md +82 -22
- package/bundled/locales/zh-TW/integrations/gemini-cli/GEMINI.md +35 -3
- package/bundled/locales/zh-TW/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +89 -3
- package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +8 -4
- package/bundled/locales/zh-TW/skills/claude-code/commands/refactor.md +178 -0
- package/bundled/locales/zh-TW/skills/claude-code/refactoring-assistant/SKILL.md +198 -52
- package/bundled/skills/claude-code/README.md +8 -0
- package/bundled/skills/claude-code/agents/README.md +305 -0
- package/bundled/skills/claude-code/agents/code-architect.md +259 -0
- package/bundled/skills/claude-code/agents/doc-writer.md +406 -0
- package/bundled/skills/claude-code/agents/reviewer.md +353 -0
- package/bundled/skills/claude-code/agents/spec-analyst.md +374 -0
- package/bundled/skills/claude-code/agents/test-specialist.md +364 -0
- package/bundled/skills/claude-code/commands/refactor.md +173 -0
- package/bundled/skills/claude-code/refactoring-assistant/SKILL.md +161 -63
- package/bundled/skills/claude-code/workflows/README.md +303 -0
- package/bundled/skills/claude-code/workflows/code-review.workflow.yaml +186 -0
- package/bundled/skills/claude-code/workflows/feature-dev.workflow.yaml +174 -0
- package/bundled/skills/claude-code/workflows/integrated-flow.workflow.yaml +238 -0
- package/bundled/skills/claude-code/workflows/large-codebase-analysis.workflow.yaml +226 -0
- package/package.json +11 -1
- package/src/commands/agent.js +417 -0
- package/src/commands/ai-context.js +552 -0
- package/src/commands/check.js +3 -3
- package/src/commands/init.js +6 -3
- package/src/commands/workflow.js +425 -0
- package/src/config/ai-agent-paths.js +217 -13
- package/src/core/constants.js +514 -0
- package/src/core/errors.js +398 -0
- package/src/core/manifest.js +473 -0
- package/src/core/paths.js +398 -0
- package/src/prompts/init.js +7 -5
- package/src/utils/agent-adapter.js +320 -0
- package/src/utils/agents-installer.js +393 -0
- package/src/utils/context-chunker.js +467 -0
- package/src/utils/copier.js +59 -99
- package/src/utils/hasher.js +2 -16
- package/src/utils/integration-generator.js +28 -52
- package/src/utils/workflows-installer.js +545 -0
- package/standards-registry.json +174 -24
package/bin/uds.js
CHANGED
|
@@ -8,6 +8,9 @@ import { checkCommand } from '../src/commands/check.js';
|
|
|
8
8
|
import { updateCommand } from '../src/commands/update.js';
|
|
9
9
|
import { configureCommand } from '../src/commands/configure.js';
|
|
10
10
|
import { skillsCommand } from '../src/commands/skills.js';
|
|
11
|
+
import { agentListCommand, agentInstallCommand, agentInfoCommand } from '../src/commands/agent.js';
|
|
12
|
+
import { workflowListCommand, workflowInstallCommand, workflowInfoCommand } from '../src/commands/workflow.js';
|
|
13
|
+
import { aiContextInitCommand, aiContextValidateCommand, aiContextGraphCommand } from '../src/commands/ai-context.js';
|
|
11
14
|
import { setLanguage, setLanguageExplicit, detectLanguage } from '../src/i18n/messages.js';
|
|
12
15
|
|
|
13
16
|
const require = createRequire(import.meta.url);
|
|
@@ -98,4 +101,76 @@ program
|
|
|
98
101
|
.description('List installed Claude Code skills')
|
|
99
102
|
.action(skillsCommand);
|
|
100
103
|
|
|
104
|
+
// Agent command with subcommands
|
|
105
|
+
const agentCommand = program
|
|
106
|
+
.command('agent')
|
|
107
|
+
.description('Manage UDS agents for AI tools');
|
|
108
|
+
|
|
109
|
+
agentCommand
|
|
110
|
+
.command('list')
|
|
111
|
+
.description('List available and installed agents')
|
|
112
|
+
.option('--installed', 'Show installation status for all AI tools')
|
|
113
|
+
.action(agentListCommand);
|
|
114
|
+
|
|
115
|
+
agentCommand
|
|
116
|
+
.command('install [agent-name]')
|
|
117
|
+
.description('Install agents (specify name or "all" for all agents)')
|
|
118
|
+
.option('-t, --tool <tool>', 'Target AI tool (default: claude-code)')
|
|
119
|
+
.option('-g, --global', 'Install to user level instead of project level')
|
|
120
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
121
|
+
.action(agentInstallCommand);
|
|
122
|
+
|
|
123
|
+
agentCommand
|
|
124
|
+
.command('info <agent-name>')
|
|
125
|
+
.description('Show detailed information about an agent')
|
|
126
|
+
.action(agentInfoCommand);
|
|
127
|
+
|
|
128
|
+
// Workflow command with subcommands
|
|
129
|
+
const workflowCommand = program
|
|
130
|
+
.command('workflow')
|
|
131
|
+
.description('Manage UDS workflows for AI tools');
|
|
132
|
+
|
|
133
|
+
workflowCommand
|
|
134
|
+
.command('list')
|
|
135
|
+
.description('List available and installed workflows')
|
|
136
|
+
.option('--installed', 'Show installation status for all AI tools')
|
|
137
|
+
.action(workflowListCommand);
|
|
138
|
+
|
|
139
|
+
workflowCommand
|
|
140
|
+
.command('install [workflow-name]')
|
|
141
|
+
.description('Install workflows (specify name or "all" for all workflows)')
|
|
142
|
+
.option('-t, --tool <tool>', 'Target AI tool (default: claude-code)')
|
|
143
|
+
.option('-g, --global', 'Install to user level instead of project level')
|
|
144
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
145
|
+
.action(workflowInstallCommand);
|
|
146
|
+
|
|
147
|
+
workflowCommand
|
|
148
|
+
.command('info <workflow-name>')
|
|
149
|
+
.description('Show detailed information about a workflow')
|
|
150
|
+
.action(workflowInfoCommand);
|
|
151
|
+
|
|
152
|
+
// AI Context command with subcommands
|
|
153
|
+
const aiContextCommand = program
|
|
154
|
+
.command('ai-context')
|
|
155
|
+
.description('Manage .ai-context.yaml configuration for AI-friendly architecture');
|
|
156
|
+
|
|
157
|
+
aiContextCommand
|
|
158
|
+
.command('init')
|
|
159
|
+
.description('Generate .ai-context.yaml configuration file')
|
|
160
|
+
.option('-f, --force', 'Overwrite existing configuration')
|
|
161
|
+
.option('-y, --yes', 'Use defaults, skip interactive prompts')
|
|
162
|
+
.action(aiContextInitCommand);
|
|
163
|
+
|
|
164
|
+
aiContextCommand
|
|
165
|
+
.command('validate')
|
|
166
|
+
.description('Validate .ai-context.yaml configuration')
|
|
167
|
+
.option('-v, --verbose', 'Show full configuration')
|
|
168
|
+
.action(aiContextValidateCommand);
|
|
169
|
+
|
|
170
|
+
aiContextCommand
|
|
171
|
+
.command('graph')
|
|
172
|
+
.description('Show module dependency graph')
|
|
173
|
+
.option('-m, --mermaid', 'Output Mermaid diagram format')
|
|
174
|
+
.action(aiContextGraphCommand);
|
|
175
|
+
|
|
101
176
|
program.parse();
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
# AI-Friendly Architecture Standards
|
|
2
|
+
|
|
3
|
+
> **Language**: English | [繁體中文](../locales/zh-TW/core/ai-friendly-architecture.md)
|
|
4
|
+
|
|
5
|
+
**Version**: 1.0.0
|
|
6
|
+
**Last Updated**: 2026-01-21
|
|
7
|
+
**Applicability**: All software projects collaborating with AI assistants
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
This standard defines architecture and documentation practices that maximize the effectiveness of AI-assisted development. By following these guidelines, projects become more analyzable, understandable, and modifiable by AI tools while maintaining human readability.
|
|
14
|
+
|
|
15
|
+
**Reference Concepts**:
|
|
16
|
+
- RLM (Recursive Language Model) context management principles
|
|
17
|
+
- Token-aware documentation design
|
|
18
|
+
- Modular architecture for AI comprehension
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Table of Contents
|
|
23
|
+
|
|
24
|
+
1. [Core Principles](#core-principles)
|
|
25
|
+
2. [Module Design Standards](#module-design-standards)
|
|
26
|
+
3. [Context Boundary Markers](#context-boundary-markers)
|
|
27
|
+
4. [Documentation Layering](#documentation-layering)
|
|
28
|
+
5. [Metadata Standards](#metadata-standards)
|
|
29
|
+
6. [Query Interface Design](#query-interface-design)
|
|
30
|
+
7. [AI Context Configuration](#ai-context-configuration)
|
|
31
|
+
8. [Anti-Patterns](#anti-patterns)
|
|
32
|
+
9. [Implementation Checklist](#implementation-checklist)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Core Principles
|
|
37
|
+
|
|
38
|
+
### 1. Explicit Over Implicit
|
|
39
|
+
|
|
40
|
+
AI assistants perform best when behavior and structure are explicitly documented rather than implied through convention.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
44
|
+
│ Explicit vs Implicit │
|
|
45
|
+
├─────────────────────────────────────────────────────────────┤
|
|
46
|
+
│ │
|
|
47
|
+
│ ❌ IMPLICIT (Hard for AI) │
|
|
48
|
+
│ └── Magic naming conventions │
|
|
49
|
+
│ └── Undocumented folder structures │
|
|
50
|
+
│ └── Convention-based routing │
|
|
51
|
+
│ └── Assumed knowledge of framework behavior │
|
|
52
|
+
│ │
|
|
53
|
+
│ ✅ EXPLICIT (AI-Friendly) │
|
|
54
|
+
│ └── Documented module responsibilities │
|
|
55
|
+
│ └── Clear entry point annotations │
|
|
56
|
+
│ └── Explicit dependency declarations │
|
|
57
|
+
│ └── Self-documenting configuration files │
|
|
58
|
+
│ │
|
|
59
|
+
└─────────────────────────────────────────────────────────────┘
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Layered Context
|
|
63
|
+
|
|
64
|
+
Structure documentation in layers so AI can access appropriate detail levels based on task complexity.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
68
|
+
│ Context Layering Strategy │
|
|
69
|
+
├─────────────────────────────────────────────────────────────┤
|
|
70
|
+
│ │
|
|
71
|
+
│ Layer 1: Quick Reference (< 500 tokens) │
|
|
72
|
+
│ └── One-liner descriptions │
|
|
73
|
+
│ └── API signatures only │
|
|
74
|
+
│ └── Key entry points │
|
|
75
|
+
│ │
|
|
76
|
+
│ Layer 2: Detailed Guide (< 5,000 tokens) │
|
|
77
|
+
│ └── Full API documentation │
|
|
78
|
+
│ └── Usage examples │
|
|
79
|
+
│ └── Configuration options │
|
|
80
|
+
│ │
|
|
81
|
+
│ Layer 3: Full Examples (unlimited) │
|
|
82
|
+
│ └── Complete implementation examples │
|
|
83
|
+
│ └── Edge case documentation │
|
|
84
|
+
│ └── Migration guides │
|
|
85
|
+
│ │
|
|
86
|
+
└─────────────────────────────────────────────────────────────┘
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. Semantic Boundaries
|
|
90
|
+
|
|
91
|
+
Design clear module boundaries that allow AI to analyze components independently without requiring full project context.
|
|
92
|
+
|
|
93
|
+
### 4. Discoverable Structure
|
|
94
|
+
|
|
95
|
+
Ensure project structure can be understood by analyzing configuration files and entry points without reading all source code.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Module Design Standards
|
|
100
|
+
|
|
101
|
+
### Single Responsibility at Module Level
|
|
102
|
+
|
|
103
|
+
Each module should have a clearly defined, singular purpose that can be summarized in one sentence.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
107
|
+
│ Module Header Template │
|
|
108
|
+
├─────────────────────────────────────────────────────────────┤
|
|
109
|
+
│ │
|
|
110
|
+
│ /** │
|
|
111
|
+
│ * @module auth │
|
|
112
|
+
│ * @description Handles user authentication and session │
|
|
113
|
+
│ * management for the application. │
|
|
114
|
+
│ * │
|
|
115
|
+
│ * @responsibility Authentication and authorization │
|
|
116
|
+
│ * @dependencies [database, crypto, config] │
|
|
117
|
+
│ * @exports {login, logout, verify, refreshToken} │
|
|
118
|
+
│ * @entrypoint ./index.ts │
|
|
119
|
+
│ */ │
|
|
120
|
+
│ │
|
|
121
|
+
└─────────────────────────────────────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Clear Input/Output Contracts
|
|
125
|
+
|
|
126
|
+
Every public interface should have explicit type definitions or documentation.
|
|
127
|
+
|
|
128
|
+
| Element | Requirement | Example |
|
|
129
|
+
|---------|-------------|---------|
|
|
130
|
+
| Function Parameters | Type + description | `@param {string} email - User's email address` |
|
|
131
|
+
| Return Values | Type + possible values | `@returns {Promise<User \| null>}` |
|
|
132
|
+
| Side Effects | Documented explicitly | `@sideeffect Writes to database` |
|
|
133
|
+
| Error Conditions | All possible errors | `@throws {AuthError} Invalid credentials` |
|
|
134
|
+
|
|
135
|
+
### Explicit Dependency Declaration
|
|
136
|
+
|
|
137
|
+
Dependencies should be declared at module level, not hidden in implementation details.
|
|
138
|
+
|
|
139
|
+
**JavaScript/TypeScript:**
|
|
140
|
+
```javascript
|
|
141
|
+
// module: src/auth/index.ts
|
|
142
|
+
// dependencies: [database, crypto, config]
|
|
143
|
+
import { db } from '../database';
|
|
144
|
+
import { hash } from '../crypto';
|
|
145
|
+
import { config } from '../config';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Python:**
|
|
149
|
+
```python
|
|
150
|
+
# module: src/auth/__init__.py
|
|
151
|
+
# dependencies: [database, crypto, config]
|
|
152
|
+
from ..database import db
|
|
153
|
+
from ..crypto import hash_password
|
|
154
|
+
from ..config import settings
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Context Boundary Markers
|
|
160
|
+
|
|
161
|
+
### Module Header Comments
|
|
162
|
+
|
|
163
|
+
Use standardized header comments that AI can parse for quick module understanding.
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
/**
|
|
167
|
+
* ═══════════════════════════════════════════════════════════
|
|
168
|
+
* MODULE: Payment Processing
|
|
169
|
+
* ═══════════════════════════════════════════════════════════
|
|
170
|
+
*
|
|
171
|
+
* PURPOSE: Handles all payment-related operations including
|
|
172
|
+
* processing, refunds, and subscription management.
|
|
173
|
+
*
|
|
174
|
+
* DEPENDENCIES:
|
|
175
|
+
* - stripe: Payment gateway integration
|
|
176
|
+
* - database: Transaction storage
|
|
177
|
+
* - events: Payment event publishing
|
|
178
|
+
*
|
|
179
|
+
* EXPORTS:
|
|
180
|
+
* - processPayment(amount, method): Process single payment
|
|
181
|
+
* - refund(transactionId): Issue refund
|
|
182
|
+
* - createSubscription(plan): Start subscription
|
|
183
|
+
*
|
|
184
|
+
* CONFIGURATION:
|
|
185
|
+
* - STRIPE_SECRET_KEY: Required
|
|
186
|
+
* - PAYMENT_WEBHOOK_SECRET: Required
|
|
187
|
+
*
|
|
188
|
+
* ═══════════════════════════════════════════════════════════
|
|
189
|
+
*/
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Section Dividers
|
|
193
|
+
|
|
194
|
+
Use consistent section dividers within large files:
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
// ============================================================
|
|
198
|
+
// SECTION: Validation Helpers
|
|
199
|
+
// ============================================================
|
|
200
|
+
|
|
201
|
+
// ... validation code ...
|
|
202
|
+
|
|
203
|
+
// ============================================================
|
|
204
|
+
// SECTION: API Handlers
|
|
205
|
+
// ============================================================
|
|
206
|
+
|
|
207
|
+
// ... handler code ...
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Documentation Layering
|
|
213
|
+
|
|
214
|
+
### Level 1: Quick Reference (< 500 tokens)
|
|
215
|
+
|
|
216
|
+
Create `QUICK-REF.md` in each major module:
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
# Auth Module - Quick Reference
|
|
220
|
+
|
|
221
|
+
## Purpose
|
|
222
|
+
User authentication and session management.
|
|
223
|
+
|
|
224
|
+
## Key Functions
|
|
225
|
+
- `login(email, password)` → `Promise<Session>`
|
|
226
|
+
- `logout(sessionId)` → `void`
|
|
227
|
+
- `verify(token)` → `Promise<User | null>`
|
|
228
|
+
|
|
229
|
+
## Configuration
|
|
230
|
+
- `AUTH_SECRET`: JWT signing secret
|
|
231
|
+
- `SESSION_DURATION`: Session lifetime (default: 24h)
|
|
232
|
+
|
|
233
|
+
## Entry Point
|
|
234
|
+
`src/auth/index.ts`
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Level 2: Detailed Guide (< 5,000 tokens)
|
|
238
|
+
|
|
239
|
+
Main `README.md` with comprehensive documentation:
|
|
240
|
+
|
|
241
|
+
```markdown
|
|
242
|
+
# Authentication Module
|
|
243
|
+
|
|
244
|
+
## Overview
|
|
245
|
+
[2-3 paragraph description]
|
|
246
|
+
|
|
247
|
+
## Architecture
|
|
248
|
+
[Diagram or description of internal structure]
|
|
249
|
+
|
|
250
|
+
## API Reference
|
|
251
|
+
[Full function signatures with parameters]
|
|
252
|
+
|
|
253
|
+
## Configuration Options
|
|
254
|
+
[All configuration with defaults and descriptions]
|
|
255
|
+
|
|
256
|
+
## Usage Examples
|
|
257
|
+
[Common use cases with code samples]
|
|
258
|
+
|
|
259
|
+
## Error Handling
|
|
260
|
+
[Error types and handling strategies]
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Level 3: Full Examples (unlimited)
|
|
264
|
+
|
|
265
|
+
Separate `examples/` directory with complete implementations:
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
auth/
|
|
269
|
+
├── QUICK-REF.md # Level 1
|
|
270
|
+
├── README.md # Level 2
|
|
271
|
+
└── examples/ # Level 3
|
|
272
|
+
├── basic-login.ts
|
|
273
|
+
├── oauth-integration.ts
|
|
274
|
+
└── custom-middleware.ts
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Metadata Standards
|
|
280
|
+
|
|
281
|
+
### Package Metadata Extensions
|
|
282
|
+
|
|
283
|
+
Extend standard package files with AI-relevant metadata:
|
|
284
|
+
|
|
285
|
+
**package.json (JavaScript/TypeScript):**
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"name": "my-project",
|
|
289
|
+
"ai-context": {
|
|
290
|
+
"entryPoints": ["src/index.ts", "src/api/index.ts"],
|
|
291
|
+
"modules": {
|
|
292
|
+
"auth": "src/auth/",
|
|
293
|
+
"api": "src/api/",
|
|
294
|
+
"database": "src/db/"
|
|
295
|
+
},
|
|
296
|
+
"ignorePatterns": ["node_modules", "dist", "coverage"],
|
|
297
|
+
"quickRef": "docs/QUICK-REF.md"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**pyproject.toml (Python):**
|
|
303
|
+
```toml
|
|
304
|
+
[tool.ai-context]
|
|
305
|
+
entry_points = ["src/main.py", "src/api/__init__.py"]
|
|
306
|
+
modules = { auth = "src/auth/", api = "src/api/" }
|
|
307
|
+
ignore_patterns = ["__pycache__", ".venv", "*.pyc"]
|
|
308
|
+
quick_ref = "docs/QUICK-REF.md"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### .ai-context.yaml Configuration
|
|
312
|
+
|
|
313
|
+
Dedicated AI context configuration file:
|
|
314
|
+
|
|
315
|
+
```yaml
|
|
316
|
+
# .ai-context.yaml - AI Context Configuration
|
|
317
|
+
version: 1.0.0
|
|
318
|
+
|
|
319
|
+
project:
|
|
320
|
+
name: my-project
|
|
321
|
+
type: web-app # web-app | library | cli | api | monorepo
|
|
322
|
+
primary-language: typescript
|
|
323
|
+
|
|
324
|
+
modules:
|
|
325
|
+
- name: auth
|
|
326
|
+
path: src/auth/
|
|
327
|
+
entry: index.ts
|
|
328
|
+
description: Authentication and authorization
|
|
329
|
+
dependencies: [database, crypto]
|
|
330
|
+
priority: high
|
|
331
|
+
|
|
332
|
+
- name: api
|
|
333
|
+
path: src/api/
|
|
334
|
+
entry: routes.ts
|
|
335
|
+
description: REST API endpoints
|
|
336
|
+
dependencies: [auth, database]
|
|
337
|
+
priority: high
|
|
338
|
+
|
|
339
|
+
- name: utils
|
|
340
|
+
path: src/utils/
|
|
341
|
+
entry: index.ts
|
|
342
|
+
description: Shared utility functions
|
|
343
|
+
dependencies: []
|
|
344
|
+
priority: low
|
|
345
|
+
|
|
346
|
+
analysis-hints:
|
|
347
|
+
entry-points:
|
|
348
|
+
- src/main.ts
|
|
349
|
+
- src/index.ts
|
|
350
|
+
ignore-patterns:
|
|
351
|
+
- node_modules
|
|
352
|
+
- dist
|
|
353
|
+
- coverage
|
|
354
|
+
- "*.test.ts"
|
|
355
|
+
architecture-type: layered # layered | microservices | modular | monolith
|
|
356
|
+
|
|
357
|
+
documentation:
|
|
358
|
+
quick-ref: docs/QUICK-REF.md
|
|
359
|
+
detailed: docs/ARCHITECTURE.md
|
|
360
|
+
examples: docs/examples/
|
|
361
|
+
|
|
362
|
+
context-strategy:
|
|
363
|
+
max-chunk-size: 50000
|
|
364
|
+
overlap: 500
|
|
365
|
+
analysis-pattern: hierarchical
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Query Interface Design
|
|
371
|
+
|
|
372
|
+
### Structured API Documentation Format
|
|
373
|
+
|
|
374
|
+
Design API documentation that's easy to query:
|
|
375
|
+
|
|
376
|
+
```markdown
|
|
377
|
+
## API: createUser
|
|
378
|
+
|
|
379
|
+
**Endpoint**: `POST /api/users`
|
|
380
|
+
**Module**: `src/api/users.ts:45`
|
|
381
|
+
|
|
382
|
+
### Parameters
|
|
383
|
+
| Name | Type | Required | Description |
|
|
384
|
+
|------|------|----------|-------------|
|
|
385
|
+
| email | string | Yes | User's email address |
|
|
386
|
+
| password | string | Yes | Min 8 characters |
|
|
387
|
+
| name | string | No | Display name |
|
|
388
|
+
|
|
389
|
+
### Response
|
|
390
|
+
```json
|
|
391
|
+
{
|
|
392
|
+
"id": "string",
|
|
393
|
+
"email": "string",
|
|
394
|
+
"createdAt": "ISO8601"
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Errors
|
|
399
|
+
| Code | Condition |
|
|
400
|
+
|------|-----------|
|
|
401
|
+
| 400 | Invalid email format |
|
|
402
|
+
| 409 | Email already exists |
|
|
403
|
+
|
|
404
|
+
### Example
|
|
405
|
+
```javascript
|
|
406
|
+
const user = await api.createUser({
|
|
407
|
+
email: 'user@example.com',
|
|
408
|
+
password: 'securePassword123'
|
|
409
|
+
});
|
|
410
|
+
```
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Searchable Code Annotations
|
|
414
|
+
|
|
415
|
+
Use consistent annotation patterns that AI can search for:
|
|
416
|
+
|
|
417
|
+
```javascript
|
|
418
|
+
// @ai-hint: This function is performance-critical
|
|
419
|
+
// @ai-complexity: O(n log n)
|
|
420
|
+
// @ai-dependencies: [sortUtils, comparators]
|
|
421
|
+
function sortLargeDataset(data) {
|
|
422
|
+
// ...
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// @ai-security: Validates user input
|
|
426
|
+
// @ai-validation: email, password strength
|
|
427
|
+
function validateRegistration(input) {
|
|
428
|
+
// ...
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## AI Context Configuration
|
|
435
|
+
|
|
436
|
+
### Recommended Directory Structure
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
project/
|
|
440
|
+
├── .ai-context.yaml # AI context configuration
|
|
441
|
+
├── docs/
|
|
442
|
+
│ ├── QUICK-REF.md # Level 1 documentation
|
|
443
|
+
│ ├── ARCHITECTURE.md # Level 2 documentation
|
|
444
|
+
│ └── examples/ # Level 3 documentation
|
|
445
|
+
├── src/
|
|
446
|
+
│ ├── auth/
|
|
447
|
+
│ │ ├── index.ts # Entry point with module header
|
|
448
|
+
│ │ ├── QUICK-REF.md # Module-level quick reference
|
|
449
|
+
│ │ └── README.md # Module documentation
|
|
450
|
+
│ ├── api/
|
|
451
|
+
│ │ ├── index.ts
|
|
452
|
+
│ │ └── README.md
|
|
453
|
+
│ └── index.ts # Application entry point
|
|
454
|
+
└── CLAUDE.md / INSTRUCTIONS.md # AI instruction file
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Context Priority Guidelines
|
|
458
|
+
|
|
459
|
+
When AI context is limited, prioritize:
|
|
460
|
+
|
|
461
|
+
| Priority | Content Type | Reason |
|
|
462
|
+
|----------|--------------|--------|
|
|
463
|
+
| 1 | Entry points | Understand application structure |
|
|
464
|
+
| 2 | .ai-context.yaml | Module map and dependencies |
|
|
465
|
+
| 3 | QUICK-REF files | Rapid API understanding |
|
|
466
|
+
| 4 | Modified files | Direct task relevance |
|
|
467
|
+
| 5 | Dependency chain | Context for changes |
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Anti-Patterns
|
|
472
|
+
|
|
473
|
+
### ❌ Patterns to Avoid
|
|
474
|
+
|
|
475
|
+
| Anti-Pattern | Problem | Solution |
|
|
476
|
+
|--------------|---------|----------|
|
|
477
|
+
| **Magic strings** | AI can't trace constants | Use typed constants with documentation |
|
|
478
|
+
| **Implicit routing** | Hidden behavior | Document route mappings explicitly |
|
|
479
|
+
| **Global state** | Unpredictable dependencies | Dependency injection with explicit wiring |
|
|
480
|
+
| **Circular dependencies** | Context confusion | Clear hierarchical dependencies |
|
|
481
|
+
| **Monolithic files** | Context overflow | Split into focused modules |
|
|
482
|
+
| **Convention over documentation** | Assumed knowledge | Explicit documentation |
|
|
483
|
+
|
|
484
|
+
### ❌ Documentation Anti-Patterns
|
|
485
|
+
|
|
486
|
+
| Anti-Pattern | Problem | Solution |
|
|
487
|
+
|--------------|---------|----------|
|
|
488
|
+
| **Outdated docs** | Misleading AI | Keep docs in sync with code |
|
|
489
|
+
| **Generated only** | Missing context | Add human-written context |
|
|
490
|
+
| **No examples** | Ambiguous usage | Include working examples |
|
|
491
|
+
| **Wall of text** | Hard to parse | Use structured formats |
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Implementation Checklist
|
|
496
|
+
|
|
497
|
+
### Quick Start (< 1 hour)
|
|
498
|
+
|
|
499
|
+
- [ ] Create `.ai-context.yaml` with module list
|
|
500
|
+
- [ ] Add `QUICK-REF.md` to project root
|
|
501
|
+
- [ ] Document entry points in README
|
|
502
|
+
- [ ] Add module headers to main files
|
|
503
|
+
|
|
504
|
+
### Standard Implementation (< 1 day)
|
|
505
|
+
|
|
506
|
+
- [ ] Complete `.ai-context.yaml` configuration
|
|
507
|
+
- [ ] Add `QUICK-REF.md` to each major module
|
|
508
|
+
- [ ] Document all public APIs with type information
|
|
509
|
+
- [ ] Add section dividers to large files
|
|
510
|
+
- [ ] Create dependency documentation
|
|
511
|
+
|
|
512
|
+
### Full Implementation (< 1 week)
|
|
513
|
+
|
|
514
|
+
- [ ] Three-layer documentation for all modules
|
|
515
|
+
- [ ] Searchable code annotations
|
|
516
|
+
- [ ] Examples directory with use cases
|
|
517
|
+
- [ ] Architecture diagrams
|
|
518
|
+
- [ ] Integration with CI for doc validation
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## Version History
|
|
523
|
+
|
|
524
|
+
| Version | Date | Changes |
|
|
525
|
+
|---------|------|---------|
|
|
526
|
+
| 1.0.0 | 2026-01-21 | Initial release |
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
## Related Standards
|
|
531
|
+
|
|
532
|
+
- [Project Structure](./project-structure.md) - Directory organization
|
|
533
|
+
- [Documentation Structure](./documentation-structure.md) - Documentation organization
|
|
534
|
+
- [Anti-Hallucination](./anti-hallucination.md) - AI accuracy standards
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## License
|
|
539
|
+
|
|
540
|
+
This standard is released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
|
|
541
|
+
|
|
542
|
+
**Source**: [universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
|