next-skill 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/CLAUDE.md +25 -0
- package/index.js +146 -0
- package/package.json +16 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
- **Run tool**: `node index.js`
|
|
7
|
+
- **Global run**: `npx .` (if installed/linked)
|
|
8
|
+
- **Tests**: None specified (`npm test` currently exits with error)
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
This is a CLI utility called `next-skill` that wraps `create-next-app` to automatically inject a specialized `.claude/SKILLS.md` file into the new project.
|
|
12
|
+
|
|
13
|
+
### Core Logic
|
|
14
|
+
- `index.js`: The entry point and main logic.
|
|
15
|
+
- Prompts for a target directory (defaults to current folder).
|
|
16
|
+
- Spawns `npx create-next-app@latest` with the specified directory.
|
|
17
|
+
- On successful creation, it creates a `.claude/SKILLS.md` file in the target directory with a set of predefined project standards.
|
|
18
|
+
|
|
19
|
+
### Project Standards (Injected via SKILLS.md)
|
|
20
|
+
The injected `SKILLS.md` file enforces:
|
|
21
|
+
- **TypeScript**: Strict type safety.
|
|
22
|
+
- **Next.js App Router**: Server Components by default.
|
|
23
|
+
- **Performance**: Image optimization and dynamic imports.
|
|
24
|
+
- **UI**: Mobile-first design, accessibility, and modern aesthetics (glassmorphism).
|
|
25
|
+
- **State**: Prefers local state and custom hooks over global state.
|
package/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
const rl = readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function createSkillsFile(targetDir) {
|
|
14
|
+
const claudeDir = path.join(process.cwd(), targetDir, '.claude');
|
|
15
|
+
const skillsFile = path.join(claudeDir, 'SKILLS.md');
|
|
16
|
+
|
|
17
|
+
console.log('Adding .claude/SKILLS.md...');
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(claudeDir)) {
|
|
20
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const content = `# Project Skills & Standards
|
|
24
|
+
|
|
25
|
+
This project follows high-performance Next.js standards and is optimized for advanced AI assistants (Claude 3.5 Sonnet / 4.6 Opus).
|
|
26
|
+
|
|
27
|
+
## 🎯 Development Standards
|
|
28
|
+
- **SSR Dynamic Rendering**: All routes should prioritize Server-Side Rendering (SSR) for real-time data where applicable. Use \`export const dynamic = 'force-dynamic'\` for pages requiring strict dynamic behavior.
|
|
29
|
+
- **Documentation**: Add proper comments (JSDoc/Block) where needed. Avoid excessive inline comments.
|
|
30
|
+
- **Imports**: Import only what is needed. Keep imports in ascending alphabetical order.
|
|
31
|
+
- **Logging**: Use proper console.logs for debugging and progress tracking. When logging errors, print the error object as it is for full context.
|
|
32
|
+
|
|
33
|
+
## 🎨 Design System & Component Architecture
|
|
34
|
+
- **Atomic Design**: Break down pages into reusable **Atoms** (buttons, inputs), **Molecules** (form fields, cards), and **Organisms** (navbar, hero sections).
|
|
35
|
+
- **Consistency**: Maintain strict adherence to the design system's spacing, typography, and color palette.
|
|
36
|
+
- **Premium Aesthetics**: Use modern color palettes, glassmorphism, and consistent spacing.
|
|
37
|
+
- **Micro-animations**: Implement subtle transitions using Framer Motion or CSS.
|
|
38
|
+
|
|
39
|
+
## ♻️ Code Structure & DRY Principles
|
|
40
|
+
- **Modularity**: Keep components small and focused. One component per file.
|
|
41
|
+
- **Logic Separation**: Keep business logic separate from UI components. Use utility functions for complex calculations.
|
|
42
|
+
- **Self-Documenting Code**: Use descriptive names. Prefer clarity over brevity.
|
|
43
|
+
- **Type Safety**: Use TypeScript strictly. Define interfaces for all data structures.
|
|
44
|
+
|
|
45
|
+
## 🪝 React Hooks Strategy
|
|
46
|
+
- **Custom Hooks**: Extract reusable logic into custom hooks.
|
|
47
|
+
- **Performance**: Use \`useMemo\` and \`useCallback\` strategically to prevent unnecessary re-renders in performance-critical areas.
|
|
48
|
+
- **State Management**: Prefer local state and custom hooks over global state. Use Zustand or Context only when necessary.
|
|
49
|
+
|
|
50
|
+
## 🔐 Environment Security
|
|
51
|
+
- **Strict Requirement**: Use \`.env\` files for ALL credentials, API keys, and environment-specific configurations.
|
|
52
|
+
- **No Hardcoding**: NEVER hardcode secrets in the codebase.
|
|
53
|
+
- **Validation**: Validate environment variables at runtime to ensure they are present.
|
|
54
|
+
|
|
55
|
+
## 🛣️ Routing & Layouts (App Router)
|
|
56
|
+
- **Layout Consistency**: A \`layout.tsx\` file is REQUIRED in every path/page directory to ensure structural consistency.
|
|
57
|
+
- **Error Handling**: Implement \`error.tsx\` and a custom \`not-found.tsx\` (404 page) for a polished user experience.
|
|
58
|
+
- **Server Components**: Use React Server Components (RSC) by default. Only use 'use client' when necessary.
|
|
59
|
+
|
|
60
|
+
## 📝 Writing & Formatting
|
|
61
|
+
- **Consistency**: Follow a consistent naming convention (e.g., PascalCase for components, camelCase for functions/variables).
|
|
62
|
+
- **Format**: Use Prettier and ESLint for automated code formatting and linting.
|
|
63
|
+
|
|
64
|
+
## 🚀 Performance Optimization
|
|
65
|
+
- **Data Fetching**: Prefer Server-side fetching over client-side useEffect.
|
|
66
|
+
- **Image Optimization**: Use next/image with proper priority and sizes.
|
|
67
|
+
- **Dynamic Imports**: Use lazy loading for heavy client components.
|
|
68
|
+
|
|
69
|
+
## 🤖 AI Assistance Standards
|
|
70
|
+
- Always provide full context when requesting refactors.
|
|
71
|
+
- Prefer modern patterns (App Router) over legacy ones.
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
fs.writeFileSync(skillsFile, content);
|
|
75
|
+
console.log('Successfully created .claude/SKILLS.md');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function main() {
|
|
79
|
+
rl.question('Press enter to install in current folder or give a name: ', (folderName) => {
|
|
80
|
+
const targetDir = folderName.trim() || '.';
|
|
81
|
+
const isCurrentDir = targetDir === '.';
|
|
82
|
+
|
|
83
|
+
console.log(`Running: npx create-next-app@latest ${targetDir}`);
|
|
84
|
+
|
|
85
|
+
const args = ['create-next-app@latest', targetDir];
|
|
86
|
+
if (isCurrentDir) {
|
|
87
|
+
args.push('--yes'); // Auto-confirm for current directory
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const child = spawn('npx', args, {
|
|
91
|
+
stdio: 'inherit',
|
|
92
|
+
shell: true
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
child.on('close', (code) => {
|
|
96
|
+
rl.close();
|
|
97
|
+
if (code === 0) {
|
|
98
|
+
console.log('Next.js app created successfully!');
|
|
99
|
+
createSkillsFile(targetDir);
|
|
100
|
+
createProjectFolders(targetDir);
|
|
101
|
+
} else {
|
|
102
|
+
console.error(`create-next-app failed with code ${code}`);
|
|
103
|
+
process.exit(code || 1);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function createProjectFolders(targetDir) {
|
|
110
|
+
const projectPath = path.join(process.cwd(), targetDir);
|
|
111
|
+
const appDir = path.join(projectPath, 'app');
|
|
112
|
+
const pagesDir = path.join(projectPath, 'pages');
|
|
113
|
+
|
|
114
|
+
// Check if it's an App Router project
|
|
115
|
+
if (fs.existsSync(appDir) && !fs.existsSync(pagesDir)) {
|
|
116
|
+
console.log('App Router setup detected. Creating additional folders...');
|
|
117
|
+
const foldersToCreate = ['components', 'lib', 'utils'];
|
|
118
|
+
foldersToCreate.forEach(folder => {
|
|
119
|
+
const folderPath = path.join(projectPath, folder);
|
|
120
|
+
if (!fs.existsSync(folderPath)) {
|
|
121
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
122
|
+
console.log(`Created folder: ${folder}`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Create .env and .env.local files
|
|
128
|
+
const envFiles = ['.env', '.env.local'];
|
|
129
|
+
envFiles.forEach(file => {
|
|
130
|
+
const filePath = path.join(projectPath, file);
|
|
131
|
+
if (!fs.existsSync(filePath)) {
|
|
132
|
+
fs.writeFileSync(filePath, '');
|
|
133
|
+
console.log(`Created file: ${file}`);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (require.main === module) {
|
|
139
|
+
main();
|
|
140
|
+
} else {
|
|
141
|
+
module.exports = {
|
|
142
|
+
createSkillsFile,
|
|
143
|
+
createProjectFolders,
|
|
144
|
+
main
|
|
145
|
+
};
|
|
146
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-skill",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a Next.js app with .claude/SKILLS.md",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"next-skill": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {}
|
|
16
|
+
}
|