@ngocbaongo/ai-agent-init 1.0.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/README.md +82 -0
- package/bin/cli.js +92 -0
- package/package.json +38 -0
- package/templates/ai_bootstrap.md +133 -0
- package/templates/readme_template.md +71 -0
- package/templates/rules_flutter.md +59 -0
- package/templates/rules_go.md +43 -0
- package/templates/rules_nodejs.md +39 -0
- package/templates/rules_python.md +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# π€ ai-agent-init
|
|
2
|
+
|
|
3
|
+
> Bootstrap any project with AI-agent-ready documentation in seconds.
|
|
4
|
+
|
|
5
|
+
Stop wasting time explaining your project structure to every new AI Agent. Run one command, point your agent to one file, and get a fully documented, standardized project.
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
Every time you start a new AI coding session, you waste tokens and time re-explaining:
|
|
10
|
+
- What tech stack you're using
|
|
11
|
+
- What architecture patterns to follow
|
|
12
|
+
- What naming conventions to use
|
|
13
|
+
- Where files should go
|
|
14
|
+
|
|
15
|
+
## The Solution
|
|
16
|
+
|
|
17
|
+
`ai-agent-init` drops a smart bootstrap file into your project. You point your AI Agent to it, and the agent does the rest β generating tailored documentation for your specific codebase, then cleaning up after itself.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 1. cd into any project (new or existing)
|
|
23
|
+
cd my-project
|
|
24
|
+
|
|
25
|
+
# 2. Run the initializer
|
|
26
|
+
npx ai-agent-init init
|
|
27
|
+
|
|
28
|
+
# 3. Tell your AI Agent (Cursor, Copilot, Cline, Gemini, etc.):
|
|
29
|
+
# "Read docs/ai/ai_bootstrap.md and set up this project."
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**That's it.** The agent will:
|
|
33
|
+
- π Analyze your codebase and detect the tech stack
|
|
34
|
+
- π Generate `docs/ai/rules.md` β conventions tailored to your project
|
|
35
|
+
- πΊοΈ Generate `docs/ai/project_map.md` β a map of your folder structure
|
|
36
|
+
- π Create or update `README.md` with real project info
|
|
37
|
+
- βοΈ Create `.cursorrules` and `.clinerules` at the root
|
|
38
|
+
- π§Ή Delete all template files automatically
|
|
39
|
+
|
|
40
|
+
## Supported Tech Stacks
|
|
41
|
+
|
|
42
|
+
The bootstrap templates cover conventions for:
|
|
43
|
+
|
|
44
|
+
| Stack | Detected By |
|
|
45
|
+
|---|---|
|
|
46
|
+
| Flutter / Dart | `pubspec.yaml` |
|
|
47
|
+
| Python | `requirements.txt`, `pyproject.toml` |
|
|
48
|
+
| Node.js / TypeScript | `package.json` |
|
|
49
|
+
| Go | `go.mod` |
|
|
50
|
+
| Generic | Fallback for any other project |
|
|
51
|
+
|
|
52
|
+
## What Gets Generated
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
your-project/
|
|
56
|
+
βββ docs/
|
|
57
|
+
β βββ ai/
|
|
58
|
+
β βββ rules.md β Code conventions & architecture for this project
|
|
59
|
+
β βββ project_map.md β Folder structure map with descriptions
|
|
60
|
+
βββ README.md β Updated with real project info
|
|
61
|
+
βββ .cursorrules β For Cursor IDE
|
|
62
|
+
βββ .clinerules β For Cline / Roo-Code
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Why This Works
|
|
66
|
+
|
|
67
|
+
The key insight is: **AI Agents are great at reading context and adapting**. Instead of writing complex detection logic in the CLI, we give the agent a clear instruction file (`ai_bootstrap.md`) and let it figure out the specifics. This makes the tool:
|
|
68
|
+
|
|
69
|
+
- β
**Adaptive** β works with any language or framework
|
|
70
|
+
- β
**Accurate** β agent reads actual code, not just file names
|
|
71
|
+
- β
**Lightweight** β CLI has zero dependencies
|
|
72
|
+
- β
**Self-cleaning** β no template clutter after setup
|
|
73
|
+
|
|
74
|
+
## Contributing
|
|
75
|
+
|
|
76
|
+
Contributions welcome! To add a new tech stack template:
|
|
77
|
+
1. Add a `templates/rules_<tech>.md` file
|
|
78
|
+
2. Reference it in `templates/ai_bootstrap.md`'s detection table
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT Β© [ngocbaomobile](https://github.com/ngocbaomobile)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const command = args[0];
|
|
8
|
+
|
|
9
|
+
const CYAN = '\x1b[36m';
|
|
10
|
+
const GREEN = '\x1b[32m';
|
|
11
|
+
const YELLOW = '\x1b[33m';
|
|
12
|
+
const RESET = '\x1b[0m';
|
|
13
|
+
const BOLD = '\x1b[1m';
|
|
14
|
+
|
|
15
|
+
function log(msg) { console.log(`${CYAN}[ai-agent-init]${RESET} ${msg}`); }
|
|
16
|
+
function success(msg) { console.log(`${GREEN}β${RESET} ${msg}`); }
|
|
17
|
+
function warn(msg) { console.log(`${YELLOW}β ${RESET} ${msg}`); }
|
|
18
|
+
|
|
19
|
+
function printHelp() {
|
|
20
|
+
console.log(`
|
|
21
|
+
${BOLD}ai-agent-init${RESET} β Bootstrap any project with AI-agent-ready documentation.
|
|
22
|
+
|
|
23
|
+
${BOLD}Usage:${RESET}
|
|
24
|
+
npx ai-agent-init init Copy AI bootstrap templates to current directory
|
|
25
|
+
npx ai-agent-init help Show this help message
|
|
26
|
+
|
|
27
|
+
${BOLD}Workflow:${RESET}
|
|
28
|
+
1. cd into your project directory
|
|
29
|
+
2. Run: npx ai-agent-init init
|
|
30
|
+
3. Tell your AI agent: "Read docs/ai/ai_bootstrap.md and set up the project"
|
|
31
|
+
4. The AI agent will generate all docs and clean up the template files
|
|
32
|
+
|
|
33
|
+
${BOLD}Supports:${RESET}
|
|
34
|
+
Flutter β’ Python β’ Node.js / TypeScript β’ Go β’ Generic
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function copyDirRecursive(src, dest) {
|
|
39
|
+
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
40
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
41
|
+
const srcPath = path.join(src, entry.name);
|
|
42
|
+
const destPath = path.join(dest, entry.name);
|
|
43
|
+
if (entry.isDirectory()) {
|
|
44
|
+
copyDirRecursive(srcPath, destPath);
|
|
45
|
+
} else {
|
|
46
|
+
if (fs.existsSync(destPath)) {
|
|
47
|
+
warn(`Skipped (already exists): ${destPath}`);
|
|
48
|
+
} else {
|
|
49
|
+
fs.copyFileSync(srcPath, destPath);
|
|
50
|
+
success(`Created: ${path.relative(process.cwd(), destPath)}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function init() {
|
|
57
|
+
const cwd = process.cwd();
|
|
58
|
+
const templatesDir = path.join(__dirname, '..', 'templates');
|
|
59
|
+
const destDir = path.join(cwd, 'docs', 'ai');
|
|
60
|
+
|
|
61
|
+
console.log(`\n${BOLD}π ai-agent-init${RESET}\n`);
|
|
62
|
+
log(`Copying AI bootstrap templates to: ${destDir}\n`);
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(templatesDir)) {
|
|
65
|
+
console.error('Error: templates directory not found. Please reinstall ai-agent-init.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
copyDirRecursive(templatesDir, destDir);
|
|
70
|
+
|
|
71
|
+
console.log(`
|
|
72
|
+
${GREEN}${BOLD}β
Done!${RESET}
|
|
73
|
+
|
|
74
|
+
${BOLD}Next step β tell your AI Agent:${RESET}
|
|
75
|
+
${CYAN}"Read the file docs/ai/ai_bootstrap.md and follow the instructions to set up this project."${RESET}
|
|
76
|
+
|
|
77
|
+
The agent will:
|
|
78
|
+
β’ Analyze the codebase and detect the tech stack
|
|
79
|
+
β’ Generate docs/ai/rules.md, docs/ai/project_map.md, README.md
|
|
80
|
+
β’ Create .cursorrules / .clinerules at the root
|
|
81
|
+
β’ Clean up all template files automatically
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
86
|
+
printHelp();
|
|
87
|
+
} else if (command === 'init') {
|
|
88
|
+
init();
|
|
89
|
+
} else {
|
|
90
|
+
console.error(`Unknown command: "${command}". Run "npx ai-agent-init help" for usage.`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ngocbaongo/ai-agent-init",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Bootstrap any project with AI-agent-ready documentation and conventions. Run once, let the AI do the rest.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai-agent",
|
|
7
|
+
"cursor",
|
|
8
|
+
"copilot",
|
|
9
|
+
"project-template",
|
|
10
|
+
"conventions",
|
|
11
|
+
"bootstrap",
|
|
12
|
+
"developer-tools"
|
|
13
|
+
],
|
|
14
|
+
"author": "ngocbaongo",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+ssh://git@github.com/ngocbaomobile/ai-agent-init.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/ngocbaomobile/ai-agent-init#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/ngocbaomobile/ai-agent-init/issues"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"aia": "./bin/cli.js",
|
|
26
|
+
"ai-agent-init": "./bin/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin/",
|
|
30
|
+
"templates/"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "node bin/cli.js --help"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=16.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# π€ AI BOOTSTRAP INSTRUCTIONS
|
|
2
|
+
|
|
3
|
+
> **This is a temporary file for AI Agent setup. You must delete it after completing all steps.**
|
|
4
|
+
|
|
5
|
+
Hello AI Agent! You have been invoked to standardize this codebase and make it AI-agent-friendly.
|
|
6
|
+
Follow the steps below carefully and in order.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Step 1: Analyze the Codebase
|
|
11
|
+
|
|
12
|
+
Scan the project root directory and determine:
|
|
13
|
+
- The **primary programming language(s)** used
|
|
14
|
+
- The **framework(s)** in use (e.g. Flutter, FastAPI, Next.js, Express, Go standard lib)
|
|
15
|
+
- The **architecture pattern** if identifiable (e.g. Clean Architecture, MVC, Feature-first)
|
|
16
|
+
- The **existing folder structure** (top-level directories and their apparent purpose)
|
|
17
|
+
|
|
18
|
+
**Detection signals to look for:**
|
|
19
|
+
| File/Folder Found | Tech Stack |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `pubspec.yaml` | Flutter / Dart |
|
|
22
|
+
| `requirements.txt` / `pyproject.toml` / `setup.py` | Python |
|
|
23
|
+
| `package.json` | Node.js / TypeScript / JavaScript |
|
|
24
|
+
| `go.mod` | Go |
|
|
25
|
+
| `Cargo.toml` | Rust |
|
|
26
|
+
| `build.gradle` / `settings.gradle` | Android / Kotlin |
|
|
27
|
+
| `*.xcodeproj` / `*.xcworkspace` | iOS / Swift |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Step 2: Generate `docs/ai/rules.md`
|
|
32
|
+
|
|
33
|
+
Create the file `docs/ai/rules.md` with the following sections, filling in details specific to **this project's actual tech stack and patterns**:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
# Project Rules & Conventions
|
|
37
|
+
|
|
38
|
+
## Tech Stack
|
|
39
|
+
- Language: [e.g. Dart 3.x]
|
|
40
|
+
- Framework: [e.g. Flutter 3.x]
|
|
41
|
+
- State Management: [e.g. BLoC]
|
|
42
|
+
- Key Libraries: [list the most important ones from pubspec/package.json/requirements]
|
|
43
|
+
|
|
44
|
+
## Architecture
|
|
45
|
+
[Describe the architecture. E.g. "This project uses Clean Architecture with 3 layers: Data, Domain, Presentation."]
|
|
46
|
+
|
|
47
|
+
## Folder Structure Conventions
|
|
48
|
+
[Describe what goes where. E.g. "Features are organized under lib/features/<feature_name>/ with bloc/, data/, domain/, presentation/ sub-folders."]
|
|
49
|
+
|
|
50
|
+
## Naming Conventions
|
|
51
|
+
- Files: [e.g. snake_case.dart]
|
|
52
|
+
- Classes: [e.g. PascalCase]
|
|
53
|
+
- Variables: [e.g. camelCase]
|
|
54
|
+
- Constants: [e.g. kConstantName or UPPER_SNAKE_CASE]
|
|
55
|
+
|
|
56
|
+
## Code Conventions
|
|
57
|
+
- [Key rules, e.g. "Always use dependency injection via GetIt"]
|
|
58
|
+
- [e.g. "Never put business logic in Widgets"]
|
|
59
|
+
- [e.g. "All API calls must go through a Repository interface"]
|
|
60
|
+
|
|
61
|
+
## Approved Libraries
|
|
62
|
+
Only use the libraries already listed in the dependency file. Do NOT add new packages without explicit user approval.
|
|
63
|
+
|
|
64
|
+
## What NOT To Do
|
|
65
|
+
- [e.g. "Do not use setState in pages that have a BLoC"]
|
|
66
|
+
- [e.g. "Do not hardcode strings β use the l10n/localization system"]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Step 3: Generate `docs/ai/project_map.md`
|
|
72
|
+
|
|
73
|
+
Scan the active directories (exclude: `.git`, build artifacts, `node_modules`, `.venv`, `.dart_tool`, `.gradle`, `Pods`, etc.) and create `docs/ai/project_map.md`:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
# Project Map
|
|
77
|
+
|
|
78
|
+
> Auto-generated by ai-agent-init. Update this file when the structure changes significantly.
|
|
79
|
+
|
|
80
|
+
## Overview
|
|
81
|
+
[1-2 sentence description of what this project does]
|
|
82
|
+
|
|
83
|
+
## Root Structure
|
|
84
|
+
[List top-level directories/files with a short description of their purpose]
|
|
85
|
+
|
|
86
|
+
## Key Entry Points
|
|
87
|
+
- Main file: [e.g. lib/main.dart or main.py or src/index.ts]
|
|
88
|
+
- Config: [e.g. pubspec.yaml or package.json]
|
|
89
|
+
- Tests: [e.g. test/ or __tests__/]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Step 4: Create or Update `README.md`
|
|
95
|
+
|
|
96
|
+
If `README.md` does not exist, create it. If it exists but is a placeholder, update it. Use the template from `docs/ai/templates/readme_template.md` as a guide, replacing all placeholders with actual project information you have discovered.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Step 5: Create AI Config Files at Root
|
|
101
|
+
|
|
102
|
+
Create the following files at the **project root** by copying the content of `docs/ai/rules.md` into them:
|
|
103
|
+
|
|
104
|
+
- `.cursorrules` β for Cursor IDE
|
|
105
|
+
- `.clinerules` β for Cline / Roo-Code (VS Code extension)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Step 6: Cleanup (CRITICAL β Do Not Skip)
|
|
110
|
+
|
|
111
|
+
After successfully creating and verifying all files above:
|
|
112
|
+
|
|
113
|
+
1. **Delete** the `docs/ai/templates/` directory and all its contents.
|
|
114
|
+
2. **Delete this file** (`docs/ai/ai_bootstrap.md`).
|
|
115
|
+
3. Report back to the user with:
|
|
116
|
+
- Detected tech stack summary
|
|
117
|
+
- List of files generated
|
|
118
|
+
- Any assumptions made that the user should review
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## β
Definition of Done
|
|
123
|
+
|
|
124
|
+
The setup is complete when these files exist and have real content (not placeholders):
|
|
125
|
+
- [ ] `docs/ai/rules.md`
|
|
126
|
+
- [ ] `docs/ai/project_map.md`
|
|
127
|
+
- [ ] `README.md`
|
|
128
|
+
- [ ] `.cursorrules`
|
|
129
|
+
- [ ] `.clinerules`
|
|
130
|
+
|
|
131
|
+
And these have been deleted:
|
|
132
|
+
- [ ] `docs/ai/ai_bootstrap.md` (this file)
|
|
133
|
+
- [ ] `docs/ai/templates/` (entire directory)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# [Project Name]
|
|
2
|
+
|
|
3
|
+
> [One-sentence description of what this project does and who it's for]
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
[2-3 paragraphs describing the project: what problem it solves, how it works at a high level, and what makes it unique or important]
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
[Insert a simple ASCII or Mermaid diagram of the architecture here]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Key concepts:**
|
|
18
|
+
- [Architecture layer 1]: [Description]
|
|
19
|
+
- [Architecture layer 2]: [Description]
|
|
20
|
+
|
|
21
|
+
## Tech Stack
|
|
22
|
+
|
|
23
|
+
| Category | Technology |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Language | [e.g. Dart 3.x] |
|
|
26
|
+
| Framework | [e.g. Flutter 3.x] |
|
|
27
|
+
| State Management | [e.g. BLoC] |
|
|
28
|
+
| Backend / API | [e.g. REST / GraphQL / Firebase] |
|
|
29
|
+
| Database | [e.g. PostgreSQL / Hive / SQLite] |
|
|
30
|
+
|
|
31
|
+
## Getting Started
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
- [e.g. Flutter SDK >= 3.0]
|
|
35
|
+
- [e.g. Node.js >= 18]
|
|
36
|
+
|
|
37
|
+
### Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Clone the repository
|
|
41
|
+
git clone [repo-url]
|
|
42
|
+
cd [project-name]
|
|
43
|
+
|
|
44
|
+
# Install dependencies
|
|
45
|
+
[e.g. flutter pub get / npm install / pip install -r requirements.txt]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Running the Project
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Development
|
|
52
|
+
[e.g. flutter run / npm run dev / python main.py]
|
|
53
|
+
|
|
54
|
+
# Tests
|
|
55
|
+
[e.g. flutter test / npm test / pytest]
|
|
56
|
+
|
|
57
|
+
# Build
|
|
58
|
+
[e.g. flutter build apk / npm run build]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Project Structure
|
|
62
|
+
|
|
63
|
+
See [`docs/ai/project_map.md`](docs/ai/project_map.md) for a full directory map.
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
See [`docs/ai/rules.md`](docs/ai/rules.md) for code conventions and architecture guidelines used in this project.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
[MIT / Apache 2.0 / etc.]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Flutter / Dart β Rules & Conventions Template
|
|
2
|
+
|
|
3
|
+
> AI Agent: Use this file as reference to fill in `docs/ai/rules.md` for a Flutter project.
|
|
4
|
+
> Adapt every section to match what you actually observe in the codebase.
|
|
5
|
+
|
|
6
|
+
## Tech Stack
|
|
7
|
+
- Language: Dart 3.x
|
|
8
|
+
- Framework: Flutter 3.x
|
|
9
|
+
- State Management: [BLoC / Riverpod / GetX / Provider β detect from pubspec.yaml]
|
|
10
|
+
- Navigation: [GoRouter / AutoRoute / Navigator 2.0 β detect from pubspec.yaml]
|
|
11
|
+
- DI: [GetIt / Injectable β detect from pubspec.yaml]
|
|
12
|
+
- Networking: [Dio / http]
|
|
13
|
+
- Local DB: [Hive / Isar / sqflite β if present]
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
This project uses **Clean Architecture** with the following layers:
|
|
17
|
+
- **Data**: API clients, repositories (implementation), DTOs, local data sources
|
|
18
|
+
- **Domain**: Entities, repository interfaces, use cases
|
|
19
|
+
- **Presentation**: BLoC/Cubit, Pages, Widgets
|
|
20
|
+
|
|
21
|
+
## Folder Structure
|
|
22
|
+
```
|
|
23
|
+
lib/
|
|
24
|
+
βββ core/ # Shared utilities, base classes, theme, router
|
|
25
|
+
βββ features/ # One folder per feature
|
|
26
|
+
β βββ <feature>/
|
|
27
|
+
β βββ data/
|
|
28
|
+
β βββ domain/
|
|
29
|
+
β βββ presentation/
|
|
30
|
+
β βββ bloc/
|
|
31
|
+
β βββ pages/
|
|
32
|
+
β βββ widgets/
|
|
33
|
+
βββ main.dart
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Naming Conventions
|
|
37
|
+
- Files: `snake_case.dart`
|
|
38
|
+
- Classes: `PascalCase`
|
|
39
|
+
- BLoC classes: `FeatureNameBloc`, `FeatureNameState`, `FeatureNameEvent`
|
|
40
|
+
- Variables/methods: `camelCase`
|
|
41
|
+
- Constants: `kConstantName`
|
|
42
|
+
- Widgets: `FeatureNameWidget` or `FeatureNamePage`
|
|
43
|
+
|
|
44
|
+
## Code Conventions
|
|
45
|
+
- Never put business logic inside Widget build() methods
|
|
46
|
+
- Use dependency injection (GetIt) for all use cases and repositories
|
|
47
|
+
- All Widgets that depend on BLoC must use BlocBuilder / BlocListener / BlocConsumer
|
|
48
|
+
- Use `freezed` for immutable state and data classes if available
|
|
49
|
+
- Prefer `const` constructors wherever possible
|
|
50
|
+
- Each feature must be self-contained; cross-feature access only through core/
|
|
51
|
+
|
|
52
|
+
## Approved Libraries
|
|
53
|
+
Only use libraries already declared in `pubspec.yaml`. Do NOT add new packages without user approval.
|
|
54
|
+
|
|
55
|
+
## What NOT To Do
|
|
56
|
+
- Do NOT use setState in pages that have a BLoC
|
|
57
|
+
- Do NOT hardcode strings β use the localization/l10n system
|
|
58
|
+
- Do NOT import across features directly; use core abstractions
|
|
59
|
+
- Do NOT put API calls inside Widgets or Pages
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Go β Rules & Conventions Template
|
|
2
|
+
|
|
3
|
+
> AI Agent: Use this file as reference to fill in `docs/ai/rules.md` for a Go project.
|
|
4
|
+
> Adapt every section to match what you actually observe in the codebase.
|
|
5
|
+
|
|
6
|
+
## Tech Stack
|
|
7
|
+
- Language: Go 1.21+
|
|
8
|
+
- Framework: [Gin / Echo / Fiber / Chi / None β detect from go.mod]
|
|
9
|
+
- ORM: [GORM / sqlx / raw sql β detect from go.mod]
|
|
10
|
+
- Testing: go test (standard)
|
|
11
|
+
|
|
12
|
+
## Architecture
|
|
13
|
+
Standard Go Project Layout (https://github.com/golang-standards/project-layout):
|
|
14
|
+
```
|
|
15
|
+
cmd/ # Main applications (entry points)
|
|
16
|
+
internal/ # Private application and library code
|
|
17
|
+
pkg/ # Library code usable by external apps
|
|
18
|
+
api/ # API definitions (OpenAPI, proto)
|
|
19
|
+
configs/ # Config files
|
|
20
|
+
scripts/ # Build/install scripts
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Naming Conventions
|
|
24
|
+
- Files: `snake_case.go`
|
|
25
|
+
- Packages: `lowercase`, single word preferred
|
|
26
|
+
- Types/Functions (exported): `PascalCase`
|
|
27
|
+
- Types/Functions (unexported): `camelCase`
|
|
28
|
+
- Interfaces: `Verb`-er pattern (e.g. `Reader`, `Writer`, `Handler`)
|
|
29
|
+
- Constants: `PascalCase` (exported) or `camelCase` (unexported)
|
|
30
|
+
|
|
31
|
+
## Code Conventions
|
|
32
|
+
- Always handle errors explicitly β never ignore with `_`
|
|
33
|
+
- Use `context.Context` as first parameter in functions that do I/O
|
|
34
|
+
- Prefer interfaces for dependency injection
|
|
35
|
+
- Keep functions small and focused (single responsibility)
|
|
36
|
+
- Use `gofmt` and `golangci-lint` for formatting/linting
|
|
37
|
+
- Wrap errors with `fmt.Errorf("context: %w", err)`
|
|
38
|
+
|
|
39
|
+
## What NOT To Do
|
|
40
|
+
- Do NOT use `panic` for normal error handling
|
|
41
|
+
- Do NOT use global variables for state
|
|
42
|
+
- Do NOT return naked errors without context
|
|
43
|
+
- Do NOT ignore the `context.Context` parameter
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Node.js / TypeScript β Rules & Conventions Template
|
|
2
|
+
|
|
3
|
+
> AI Agent: Use this file as reference to fill in `docs/ai/rules.md` for a Node.js/TypeScript project.
|
|
4
|
+
> Adapt every section to match what you actually observe in the codebase.
|
|
5
|
+
|
|
6
|
+
## Tech Stack
|
|
7
|
+
- Language: TypeScript (strict mode preferred)
|
|
8
|
+
- Runtime: Node.js 18+
|
|
9
|
+
- Framework: [Next.js / Express / NestJS / Fastify β detect from package.json]
|
|
10
|
+
- Package Manager: [npm / yarn / pnpm β detect from lockfile]
|
|
11
|
+
- Testing: [Jest / Vitest β detect from package.json]
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
[Detect and describe. Common patterns:]
|
|
15
|
+
- **Next.js App Router**: app/, components/, lib/, hooks/
|
|
16
|
+
- **NestJS**: modules/, controllers/, services/, entities/
|
|
17
|
+
- **Express Layered**: routes/, controllers/, services/, repositories/
|
|
18
|
+
|
|
19
|
+
## Naming Conventions
|
|
20
|
+
- Files: `kebab-case.ts` (Next.js) or `camelCase.ts` (libraries)
|
|
21
|
+
- Classes: `PascalCase`
|
|
22
|
+
- Interfaces: `IPascalCase` or `PascalCase` (without I prefix β depends on project)
|
|
23
|
+
- Functions/variables: `camelCase`
|
|
24
|
+
- Constants: `UPPER_SNAKE_CASE` or `camelCase`
|
|
25
|
+
- React components: `PascalCase.tsx`
|
|
26
|
+
|
|
27
|
+
## Code Conventions
|
|
28
|
+
- Enable `strict: true` in tsconfig.json
|
|
29
|
+
- Use `interface` for object shapes, `type` for unions/intersections
|
|
30
|
+
- Prefer named exports over default exports (except for Next.js pages)
|
|
31
|
+
- All async functions must have proper error handling (try/catch or Result pattern)
|
|
32
|
+
- Use index.ts barrel files for clean imports within modules
|
|
33
|
+
- Never use `any` β use `unknown` and type guards instead
|
|
34
|
+
|
|
35
|
+
## What NOT To Do
|
|
36
|
+
- Do NOT use `var` β always use `const` or `let`
|
|
37
|
+
- Do NOT use `any` type
|
|
38
|
+
- Do NOT mutate function arguments
|
|
39
|
+
- Do NOT mix CommonJS and ESM imports in the same project
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Python β Rules & Conventions Template
|
|
2
|
+
|
|
3
|
+
> AI Agent: Use this file as reference to fill in `docs/ai/rules.md` for a Python project.
|
|
4
|
+
> Adapt every section to match what you actually observe in the codebase.
|
|
5
|
+
|
|
6
|
+
## Tech Stack
|
|
7
|
+
- Language: Python 3.11+
|
|
8
|
+
- Framework: [FastAPI / Django / Flask / None β detect from requirements.txt or pyproject.toml]
|
|
9
|
+
- Package Manager: [pip / Poetry / PDM β detect from pyproject.toml or requirements.txt]
|
|
10
|
+
- Testing: [pytest β standard]
|
|
11
|
+
- Linter/Formatter: [ruff / black / flake8 β detect from config files]
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
[Detect and describe. Common patterns:]
|
|
15
|
+
- **Layered**: routes β services β repositories β models
|
|
16
|
+
- **Domain-Driven**: domain/, application/, infrastructure/, interfaces/
|
|
17
|
+
|
|
18
|
+
## Folder Structure (FastAPI example)
|
|
19
|
+
```
|
|
20
|
+
app/
|
|
21
|
+
βββ api/ # Route handlers (controllers)
|
|
22
|
+
βββ core/ # Config, dependencies, security
|
|
23
|
+
βββ models/ # SQLAlchemy / Pydantic models
|
|
24
|
+
βββ schemas/ # Pydantic request/response schemas
|
|
25
|
+
βββ services/ # Business logic
|
|
26
|
+
βββ repositories/ # DB access layer
|
|
27
|
+
tests/
|
|
28
|
+
main.py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Naming Conventions
|
|
32
|
+
- Files/modules: `snake_case.py`
|
|
33
|
+
- Classes: `PascalCase`
|
|
34
|
+
- Functions/variables: `snake_case`
|
|
35
|
+
- Constants: `UPPER_SNAKE_CASE`
|
|
36
|
+
- Private: `_prefixed_with_underscore`
|
|
37
|
+
|
|
38
|
+
## Code Conventions
|
|
39
|
+
- Use type hints on all function signatures
|
|
40
|
+
- Use Pydantic for data validation and serialization
|
|
41
|
+
- All business logic lives in services/, not in route handlers
|
|
42
|
+
- Use dependency injection via FastAPI's `Depends()` system
|
|
43
|
+
- Follow PEP 8 style guide
|
|
44
|
+
|
|
45
|
+
## What NOT To Do
|
|
46
|
+
- Do NOT put DB queries directly in route handlers
|
|
47
|
+
- Do NOT use mutable default arguments
|
|
48
|
+
- Do NOT ignore exceptions silently β always log or re-raise
|