ctxinit 0.1.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/LICENSE +21 -0
- package/README.md +484 -0
- package/bin/ctx.js +3 -0
- package/dist/analysis/index.d.ts +2 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +18 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/static-analysis.d.ts +79 -0
- package/dist/analysis/static-analysis.d.ts.map +1 -0
- package/dist/analysis/static-analysis.js +279 -0
- package/dist/analysis/static-analysis.js.map +1 -0
- package/dist/bootstrap/index.d.ts +8 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +13 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/orchestrator.d.ts +48 -0
- package/dist/bootstrap/orchestrator.d.ts.map +1 -0
- package/dist/bootstrap/orchestrator.js +363 -0
- package/dist/bootstrap/orchestrator.js.map +1 -0
- package/dist/bootstrap/validator.d.ts +25 -0
- package/dist/bootstrap/validator.d.ts.map +1 -0
- package/dist/bootstrap/validator.js +412 -0
- package/dist/bootstrap/validator.js.map +1 -0
- package/dist/build/atomic.d.ts +74 -0
- package/dist/build/atomic.d.ts.map +1 -0
- package/dist/build/atomic.js +235 -0
- package/dist/build/atomic.js.map +1 -0
- package/dist/build/index.d.ts +10 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +26 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/lock.d.ts +102 -0
- package/dist/build/lock.d.ts.map +1 -0
- package/dist/build/lock.js +297 -0
- package/dist/build/lock.js.map +1 -0
- package/dist/build/manifest.d.ts +138 -0
- package/dist/build/manifest.d.ts.map +1 -0
- package/dist/build/manifest.js +269 -0
- package/dist/build/manifest.js.map +1 -0
- package/dist/build/orchestrator.d.ts +103 -0
- package/dist/build/orchestrator.d.ts.map +1 -0
- package/dist/build/orchestrator.js +524 -0
- package/dist/build/orchestrator.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +77 -0
- package/dist/cli/bootstrap.d.ts.map +1 -0
- package/dist/cli/bootstrap.js +527 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/build.d.ts +32 -0
- package/dist/cli/build.d.ts.map +1 -0
- package/dist/cli/build.js +156 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/diff.d.ts +23 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +226 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/hooks.d.ts +29 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +176 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/init.d.ts +53 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +254 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/lint.d.ts +46 -0
- package/dist/cli/lint.d.ts.map +1 -0
- package/dist/cli/lint.js +210 -0
- package/dist/cli/lint.js.map +1 -0
- package/dist/cli/migrate.d.ts +28 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +350 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/verify.d.ts +21 -0
- package/dist/cli/verify.d.ts.map +1 -0
- package/dist/cli/verify.js +209 -0
- package/dist/cli/verify.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +262 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler/agents-compiler.d.ts +24 -0
- package/dist/compiler/agents-compiler.d.ts.map +1 -0
- package/dist/compiler/agents-compiler.js +192 -0
- package/dist/compiler/agents-compiler.js.map +1 -0
- package/dist/compiler/base-compiler.d.ts +152 -0
- package/dist/compiler/base-compiler.d.ts.map +1 -0
- package/dist/compiler/base-compiler.js +180 -0
- package/dist/compiler/base-compiler.js.map +1 -0
- package/dist/compiler/claude-compiler.d.ts +24 -0
- package/dist/compiler/claude-compiler.d.ts.map +1 -0
- package/dist/compiler/claude-compiler.js +182 -0
- package/dist/compiler/claude-compiler.js.map +1 -0
- package/dist/compiler/cursor-compiler.d.ts +33 -0
- package/dist/compiler/cursor-compiler.d.ts.map +1 -0
- package/dist/compiler/cursor-compiler.js +136 -0
- package/dist/compiler/cursor-compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +7 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +24 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/rule-selector.d.ts +115 -0
- package/dist/compiler/rule-selector.d.ts.map +1 -0
- package/dist/compiler/rule-selector.js +273 -0
- package/dist/compiler/rule-selector.js.map +1 -0
- package/dist/compiler/token-estimator.d.ts +74 -0
- package/dist/compiler/token-estimator.d.ts.map +1 -0
- package/dist/compiler/token-estimator.js +191 -0
- package/dist/compiler/token-estimator.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +18 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +48 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +175 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/git/gitignore.d.ts +59 -0
- package/dist/git/gitignore.d.ts.map +1 -0
- package/dist/git/gitignore.js +268 -0
- package/dist/git/gitignore.js.map +1 -0
- package/dist/git/hooks.d.ts +34 -0
- package/dist/git/hooks.d.ts.map +1 -0
- package/dist/git/hooks.js +129 -0
- package/dist/git/hooks.js.map +1 -0
- package/dist/git/husky.d.ts +52 -0
- package/dist/git/husky.d.ts.map +1 -0
- package/dist/git/husky.js +219 -0
- package/dist/git/husky.js.map +1 -0
- package/dist/git/index.d.ts +9 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +15 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/base-provider.d.ts +43 -0
- package/dist/llm/base-provider.d.ts.map +1 -0
- package/dist/llm/base-provider.js +91 -0
- package/dist/llm/base-provider.js.map +1 -0
- package/dist/llm/index.d.ts +17 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +36 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/prompts/bootstrap-prompt.d.ts +27 -0
- package/dist/llm/prompts/bootstrap-prompt.d.ts.map +1 -0
- package/dist/llm/prompts/bootstrap-prompt.js +278 -0
- package/dist/llm/prompts/bootstrap-prompt.js.map +1 -0
- package/dist/llm/prompts/index.d.ts +5 -0
- package/dist/llm/prompts/index.d.ts.map +1 -0
- package/dist/llm/prompts/index.js +11 -0
- package/dist/llm/prompts/index.js.map +1 -0
- package/dist/llm/provider-factory.d.ts +27 -0
- package/dist/llm/provider-factory.d.ts.map +1 -0
- package/dist/llm/provider-factory.js +213 -0
- package/dist/llm/provider-factory.js.map +1 -0
- package/dist/llm/providers/claude-api.d.ts +21 -0
- package/dist/llm/providers/claude-api.d.ts.map +1 -0
- package/dist/llm/providers/claude-api.js +110 -0
- package/dist/llm/providers/claude-api.js.map +1 -0
- package/dist/llm/providers/claude-code.d.ts +21 -0
- package/dist/llm/providers/claude-code.d.ts.map +1 -0
- package/dist/llm/providers/claude-code.js +120 -0
- package/dist/llm/providers/claude-code.js.map +1 -0
- package/dist/llm/providers/codex-cli.d.ts +25 -0
- package/dist/llm/providers/codex-cli.d.ts.map +1 -0
- package/dist/llm/providers/codex-cli.js +129 -0
- package/dist/llm/providers/codex-cli.js.map +1 -0
- package/dist/llm/providers/cursor-cli.d.ts +24 -0
- package/dist/llm/providers/cursor-cli.d.ts.map +1 -0
- package/dist/llm/providers/cursor-cli.js +106 -0
- package/dist/llm/providers/cursor-cli.js.map +1 -0
- package/dist/llm/providers/gemini-api.d.ts +20 -0
- package/dist/llm/providers/gemini-api.d.ts.map +1 -0
- package/dist/llm/providers/gemini-api.js +121 -0
- package/dist/llm/providers/gemini-api.js.map +1 -0
- package/dist/llm/providers/gemini-cli.d.ts +20 -0
- package/dist/llm/providers/gemini-cli.d.ts.map +1 -0
- package/dist/llm/providers/gemini-cli.js +109 -0
- package/dist/llm/providers/gemini-cli.js.map +1 -0
- package/dist/llm/providers/interactive.d.ts +42 -0
- package/dist/llm/providers/interactive.d.ts.map +1 -0
- package/dist/llm/providers/interactive.js +200 -0
- package/dist/llm/providers/interactive.js.map +1 -0
- package/dist/llm/providers/openai-api.d.ts +21 -0
- package/dist/llm/providers/openai-api.d.ts.map +1 -0
- package/dist/llm/providers/openai-api.js +107 -0
- package/dist/llm/providers/openai-api.js.map +1 -0
- package/dist/llm/types.d.ts +128 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +8 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/parser/index.d.ts +3 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +19 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/path-security.d.ts +40 -0
- package/dist/parser/path-security.d.ts.map +1 -0
- package/dist/parser/path-security.js +183 -0
- package/dist/parser/path-security.js.map +1 -0
- package/dist/parser/rule-parser.d.ts +50 -0
- package/dist/parser/rule-parser.d.ts.map +1 -0
- package/dist/parser/rule-parser.js +203 -0
- package/dist/parser/rule-parser.js.map +1 -0
- package/dist/schemas/config.d.ts +202 -0
- package/dist/schemas/config.d.ts.map +1 -0
- package/dist/schemas/config.js +96 -0
- package/dist/schemas/config.js.map +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +19 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/rule.d.ts +67 -0
- package/dist/schemas/rule.d.ts.map +1 -0
- package/dist/schemas/rule.js +44 -0
- package/dist/schemas/rule.js.map +1 -0
- package/package.json +69 -0
- package/templates/architecture.md +35 -0
- package/templates/bootstrap-prompt.md +242 -0
- package/templates/config.yaml +25 -0
- package/templates/project.md +44 -0
- package/templates/rules/example.md +36 -0
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ctxinit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified context architecture for AI coding assistants (Claude Code, Cursor, Codex)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ctx": "./bin/ctx.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test:coverage": "jest --coverage",
|
|
15
|
+
"lint": "eslint src --ext .ts",
|
|
16
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
17
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
18
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
19
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"ai",
|
|
23
|
+
"context",
|
|
24
|
+
"claude",
|
|
25
|
+
"cursor",
|
|
26
|
+
"codex",
|
|
27
|
+
"cli",
|
|
28
|
+
"developer-tools"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"bin",
|
|
38
|
+
"templates"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/stone16/ctxinit.git"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@eslint/js": "^9.39.1",
|
|
46
|
+
"@types/inquirer": "^9.0.9",
|
|
47
|
+
"@types/jest": "^30.0.0",
|
|
48
|
+
"@types/node": "^24.10.1",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
50
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
51
|
+
"eslint": "^9.39.1",
|
|
52
|
+
"jest": "^30.2.0",
|
|
53
|
+
"prettier": "^3.7.4",
|
|
54
|
+
"ts-jest": "^29.4.6",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"typescript-eslint": "^8.48.1"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@types/minimatch": "^5.1.2",
|
|
60
|
+
"chalk": "^4.1.2",
|
|
61
|
+
"commander": "^14.0.2",
|
|
62
|
+
"fast-glob": "^3.3.3",
|
|
63
|
+
"gray-matter": "^4.0.3",
|
|
64
|
+
"inquirer": "^12.11.1",
|
|
65
|
+
"minimatch": "^10.1.1",
|
|
66
|
+
"yaml": "^2.8.2",
|
|
67
|
+
"zod": "^4.1.13"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
<!-- This file describes your project's architecture for AI assistants -->
|
|
4
|
+
|
|
5
|
+
## System Design
|
|
6
|
+
|
|
7
|
+
<!-- Describe the high-level architecture -->
|
|
8
|
+
|
|
9
|
+
## Component Structure
|
|
10
|
+
|
|
11
|
+
<!-- Explain how components are organized -->
|
|
12
|
+
|
|
13
|
+
## Data Flow
|
|
14
|
+
|
|
15
|
+
<!-- Describe how data moves through the system -->
|
|
16
|
+
|
|
17
|
+
## Key Patterns
|
|
18
|
+
|
|
19
|
+
<!-- Document important design patterns used -->
|
|
20
|
+
|
|
21
|
+
### Pattern 1: [Name]
|
|
22
|
+
|
|
23
|
+
<!-- Description and usage -->
|
|
24
|
+
|
|
25
|
+
## Dependencies
|
|
26
|
+
|
|
27
|
+
<!-- List external dependencies and their purposes -->
|
|
28
|
+
|
|
29
|
+
## Security Considerations
|
|
30
|
+
|
|
31
|
+
<!-- Note any security-related architectural decisions -->
|
|
32
|
+
|
|
33
|
+
## Performance Considerations
|
|
34
|
+
|
|
35
|
+
<!-- Document performance-related architectural choices -->
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Context Bootstrap Request
|
|
2
|
+
|
|
3
|
+
You are helping bootstrap AI coding rules for the project "{{projectName}}".
|
|
4
|
+
|
|
5
|
+
Your goal is to generate modular rule files for the `.context/rules/` directory that will compile into a production-grade CLAUDE.md (or equivalent agent instruction file).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Critical Philosophy: Context Engineering Principles
|
|
10
|
+
|
|
11
|
+
Before generating rules, internalize these principles:
|
|
12
|
+
|
|
13
|
+
### 1. CLAUDE.md is NOT Documentation for Humans
|
|
14
|
+
|
|
15
|
+
It is a **system prompt injection mechanism** - the operating system for an AI agent. Every line must:
|
|
16
|
+
- Be **machine-actionable**, not human-readable prose
|
|
17
|
+
- Be **concise**, **imperative**, and **unambiguous**
|
|
18
|
+
- Purchase significant agentic behavior (treat context as high-value real estate)
|
|
19
|
+
|
|
20
|
+
### 2. Respect LLM Cognitive Architecture
|
|
21
|
+
|
|
22
|
+
LLMs are stateless with limited attention. Key constraints:
|
|
23
|
+
- **Lost in the middle**: Transformers degrade attention mid-context
|
|
24
|
+
- **Saturation point**: ~150-200 distinct instructions is the practical limit
|
|
25
|
+
- **Relevance filtering**: Claude Code ignores context that appears irrelevant to current task
|
|
26
|
+
|
|
27
|
+
**Therefore**: Less is more. Dense, actionable instructions beat verbose explanations.
|
|
28
|
+
|
|
29
|
+
### 3. Never Use CLAUDE.md as a Linter
|
|
30
|
+
|
|
31
|
+
LLMs are probabilistic engines. For deterministic rules (formatting, naming conventions), use actual linters. Reserve CLAUDE.md for:
|
|
32
|
+
- Architectural decisions
|
|
33
|
+
- Workflow patterns
|
|
34
|
+
- Domain-specific context
|
|
35
|
+
- Things that can't be automated
|
|
36
|
+
|
|
37
|
+
### 4. Progressive Disclosure Pattern
|
|
38
|
+
|
|
39
|
+
Don't load everything into root CLAUDE.md. Instead:
|
|
40
|
+
- Root file acts as **map and index**
|
|
41
|
+
- Detailed docs live in `agent_docs/` or `.context/` subdirectories
|
|
42
|
+
- Use referral instructions: "When modifying X, first read `@path/to/detail.md`"
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Project Analysis
|
|
47
|
+
|
|
48
|
+
**Project Name**: {{projectName}}
|
|
49
|
+
**Primary Languages**: {{languages}}
|
|
50
|
+
**Frameworks**: {{frameworks}}
|
|
51
|
+
**Build Tools**: {{buildTools}}
|
|
52
|
+
**Testing**: {{testingTools}}
|
|
53
|
+
|
|
54
|
+
## Directory Structure
|
|
55
|
+
|
|
56
|
+
**Top-level directories**: {{topLevelDirs}}
|
|
57
|
+
**Source structure**: {{srcStructure}}
|
|
58
|
+
**Has tests**: {{hasTests}}
|
|
59
|
+
**Has docs**: {{hasDocs}}
|
|
60
|
+
|
|
61
|
+
{{#packageInfo}}
|
|
62
|
+
## Package Information
|
|
63
|
+
|
|
64
|
+
**Type**: {{type}}
|
|
65
|
+
**Description**: {{description}}
|
|
66
|
+
**Key Dependencies**: {{dependencies}}
|
|
67
|
+
**Scripts**: {{scripts}}
|
|
68
|
+
{{/packageInfo}}
|
|
69
|
+
|
|
70
|
+
{{#existingDocs}}
|
|
71
|
+
## Existing Documentation
|
|
72
|
+
|
|
73
|
+
The following documentation already exists:
|
|
74
|
+
|
|
75
|
+
{{#docs}}
|
|
76
|
+
### {{path}}
|
|
77
|
+
```text
|
|
78
|
+
{{excerpt}}
|
|
79
|
+
```
|
|
80
|
+
{{/docs}}
|
|
81
|
+
{{/existingDocs}}
|
|
82
|
+
|
|
83
|
+
{{#sampleFiles}}
|
|
84
|
+
## Sample Code Files
|
|
85
|
+
|
|
86
|
+
These files represent the coding patterns in this project:
|
|
87
|
+
|
|
88
|
+
{{#files}}
|
|
89
|
+
### {{path}} ({{language}})
|
|
90
|
+
```{{languageLower}}
|
|
91
|
+
{{content}}
|
|
92
|
+
```
|
|
93
|
+
{{/files}}
|
|
94
|
+
{{/sampleFiles}}
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Your Task: Generate Production-Grade Rules
|
|
99
|
+
|
|
100
|
+
Create **3-7 rule files** following the architecture below. Each rule should be **dense and actionable**.
|
|
101
|
+
|
|
102
|
+
### Required Rule Categories
|
|
103
|
+
|
|
104
|
+
#### 1. Project Identity Rule (`project-identity.md`)
|
|
105
|
+
Must include:
|
|
106
|
+
- One-line mission statement
|
|
107
|
+
- Tech stack summary (language, framework, database, infra)
|
|
108
|
+
- Architectural style (monorepo/microservices/modular monolith)
|
|
109
|
+
|
|
110
|
+
#### 2. Architecture Map Rule (`architecture-map.md`)
|
|
111
|
+
Must include:
|
|
112
|
+
- ASCII tree or descriptive map of key directories
|
|
113
|
+
- Purpose of each major directory
|
|
114
|
+
- This prevents agents from wasting tokens running `ls`, `find`, `grep` to understand structure
|
|
115
|
+
|
|
116
|
+
#### 3. Operational Commands Rule (`commands.md`)
|
|
117
|
+
Must include authoritative commands for:
|
|
118
|
+
- Build
|
|
119
|
+
- Test (unit, integration, e2e)
|
|
120
|
+
- Lint/Format
|
|
121
|
+
- Database migrations (if applicable)
|
|
122
|
+
- Deployment (if applicable)
|
|
123
|
+
|
|
124
|
+
Format as imperative instructions:
|
|
125
|
+
```text
|
|
126
|
+
# Build
|
|
127
|
+
Run: `npm run build`
|
|
128
|
+
|
|
129
|
+
# Test
|
|
130
|
+
Run: `npm test` for unit tests
|
|
131
|
+
Run: `npm run test:e2e` for e2e tests
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### 4. Code Patterns Rule (language-specific, e.g., `typescript-patterns.md`)
|
|
135
|
+
Based on the sample files, document:
|
|
136
|
+
- Import organization
|
|
137
|
+
- Error handling patterns
|
|
138
|
+
- Async patterns
|
|
139
|
+
- Naming conventions (only if non-standard)
|
|
140
|
+
|
|
141
|
+
**Important**: Don't duplicate what linters enforce. Focus on patterns that require judgment.
|
|
142
|
+
|
|
143
|
+
#### 5. Do-Not Rules (`boundaries.md`)
|
|
144
|
+
Critical prohibitions. Format as imperative negatives:
|
|
145
|
+
```text
|
|
146
|
+
- Do NOT modify files in `dist/` or `build/` directly
|
|
147
|
+
- Do NOT commit `.env` files
|
|
148
|
+
- Do NOT add dependencies without approval
|
|
149
|
+
- Do NOT use `any` type in TypeScript
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### 6. Git Workflow Rule (`git-workflow.md`)
|
|
153
|
+
Must include:
|
|
154
|
+
- Always submit changes via Pull Request, never commit directly to main
|
|
155
|
+
- Do NOT include "Co-authored-by" in commit messages
|
|
156
|
+
- Commit message format and conventions
|
|
157
|
+
- Branch naming conventions
|
|
158
|
+
|
|
159
|
+
### Optional Rules (if applicable)
|
|
160
|
+
|
|
161
|
+
#### 7. Testing Conventions (`testing.md`)
|
|
162
|
+
If testing tools detected, document:
|
|
163
|
+
- Test file location pattern
|
|
164
|
+
- Mocking conventions
|
|
165
|
+
- Test naming conventions
|
|
166
|
+
- Coverage requirements
|
|
167
|
+
|
|
168
|
+
#### 8. Framework-Specific Patterns
|
|
169
|
+
If frameworks detected, create framework-specific rules.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Rule File Format
|
|
174
|
+
|
|
175
|
+
Each rule must follow this exact format:
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
---
|
|
179
|
+
id: unique-rule-id
|
|
180
|
+
description: Brief description (machine-readable)
|
|
181
|
+
globs:
|
|
182
|
+
- "**/*.ts"
|
|
183
|
+
priority: 50
|
|
184
|
+
tags:
|
|
185
|
+
- category
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
# Rule Title
|
|
189
|
+
|
|
190
|
+
[Dense, imperative instructions here]
|
|
191
|
+
|
|
192
|
+
## Section Name
|
|
193
|
+
|
|
194
|
+
- Bullet points preferred over paragraphs
|
|
195
|
+
- Each point is a discrete instruction
|
|
196
|
+
- Use code blocks for commands and examples
|
|
197
|
+
|
|
198
|
+
## Examples (if needed)
|
|
199
|
+
|
|
200
|
+
\`\`\`typescript
|
|
201
|
+
// GOOD: Brief explanation
|
|
202
|
+
code example
|
|
203
|
+
\`\`\`
|
|
204
|
+
|
|
205
|
+
\`\`\`typescript
|
|
206
|
+
// AVOID: Brief explanation
|
|
207
|
+
anti-pattern
|
|
208
|
+
\`\`\`
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Writing Style Guidelines
|
|
212
|
+
|
|
213
|
+
1. **Imperative voice**: "Use X" not "You should use X" or "X is recommended"
|
|
214
|
+
2. **Dense**: One instruction per line, no filler words
|
|
215
|
+
3. **Specific**: Include file paths, line number references where helpful
|
|
216
|
+
4. **Actionable**: Every sentence should change agent behavior
|
|
217
|
+
5. **No prose**: Avoid explanatory paragraphs. Use structured lists.
|
|
218
|
+
|
|
219
|
+
### Anti-Patterns to Avoid
|
|
220
|
+
|
|
221
|
+
- Generic advice ("write clean code", "follow best practices")
|
|
222
|
+
- Duplicating linter rules
|
|
223
|
+
- Long explanations of "why"
|
|
224
|
+
- Vague instructions ("be careful with X")
|
|
225
|
+
- Marketing language ("elegant", "robust", "scalable")
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Output Format
|
|
230
|
+
|
|
231
|
+
For each rule, output:
|
|
232
|
+
|
|
233
|
+
1. **Filename**: `rule-name.md` (kebab-case)
|
|
234
|
+
2. **Full content**: Complete rule file with frontmatter
|
|
235
|
+
|
|
236
|
+
Create files for `.context/rules/`. Be specific to THIS project's patterns, not generic advice.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Generate Rules Now
|
|
241
|
+
|
|
242
|
+
Analyze the codebase information above. Generate dense, actionable rule files that will make an AI agent effective at working in this specific codebase.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# ctxinit Configuration
|
|
2
|
+
# Documentation: https://github.com/your-org/ctxinit
|
|
3
|
+
|
|
4
|
+
version: "1.0"
|
|
5
|
+
|
|
6
|
+
compile:
|
|
7
|
+
# Claude Code target configuration
|
|
8
|
+
claude:
|
|
9
|
+
max_tokens: 4000
|
|
10
|
+
strategy: priority # priority | directory | glob | tag | all
|
|
11
|
+
always_include: []
|
|
12
|
+
|
|
13
|
+
# Cursor target configuration
|
|
14
|
+
cursor:
|
|
15
|
+
strategy: all
|
|
16
|
+
|
|
17
|
+
# AGENTS.md target configuration
|
|
18
|
+
agents:
|
|
19
|
+
max_tokens: 8000
|
|
20
|
+
strategy: priority
|
|
21
|
+
include_dirs: []
|
|
22
|
+
|
|
23
|
+
# Conflict resolution when rules overlap
|
|
24
|
+
conflict_resolution:
|
|
25
|
+
strategy: priority_wins # priority_wins | merge
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Project Context
|
|
2
|
+
|
|
3
|
+
<!-- This file provides global context about your project for AI assistants -->
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
<!-- Describe your project in 2-3 sentences -->
|
|
8
|
+
|
|
9
|
+
## Tech Stack
|
|
10
|
+
|
|
11
|
+
<!-- List primary technologies, frameworks, and tools -->
|
|
12
|
+
|
|
13
|
+
- Language:
|
|
14
|
+
- Framework:
|
|
15
|
+
- Database:
|
|
16
|
+
- Build Tool:
|
|
17
|
+
|
|
18
|
+
## Key Directories
|
|
19
|
+
|
|
20
|
+
<!-- Explain important directories in your project -->
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
src/ # Source code
|
|
24
|
+
tests/ # Test files
|
|
25
|
+
docs/ # Documentation
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Coding Standards
|
|
29
|
+
|
|
30
|
+
<!-- Summarize key coding conventions -->
|
|
31
|
+
|
|
32
|
+
- Follow existing patterns in the codebase
|
|
33
|
+
- Write tests for new features
|
|
34
|
+
- Keep functions focused and small
|
|
35
|
+
|
|
36
|
+
## Common Commands
|
|
37
|
+
|
|
38
|
+
<!-- List frequently used commands -->
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run dev # Start development server
|
|
42
|
+
npm run test # Run tests
|
|
43
|
+
npm run build # Build for production
|
|
44
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: example-rule
|
|
3
|
+
description: An example rule demonstrating the frontmatter format
|
|
4
|
+
domain: general
|
|
5
|
+
globs:
|
|
6
|
+
- "**/*.ts"
|
|
7
|
+
- "**/*.js"
|
|
8
|
+
priority: 50
|
|
9
|
+
tags:
|
|
10
|
+
- example
|
|
11
|
+
- template
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Example Rule
|
|
15
|
+
|
|
16
|
+
This is an example rule file. Replace this content with your actual coding guidelines.
|
|
17
|
+
|
|
18
|
+
## Guidelines
|
|
19
|
+
|
|
20
|
+
1. **Code Style**: Follow consistent formatting
|
|
21
|
+
2. **Naming**: Use descriptive variable and function names
|
|
22
|
+
3. **Documentation**: Add comments for complex logic
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Good: Descriptive function name
|
|
28
|
+
function calculateTotalPrice(items: Item[]): number {
|
|
29
|
+
return items.reduce((sum, item) => sum + item.price, 0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Avoid: Unclear naming
|
|
33
|
+
function calc(i: any[]): number {
|
|
34
|
+
return i.reduce((s, x) => s + x.p, 0);
|
|
35
|
+
}
|
|
36
|
+
```
|