Skip to content

Commit d8930c9

Browse files
committed
feat: standards-shaper now updates existing standards based on project
**Major Enhancement**: /standards-shaper intelligently updates existing standards ## Problem Standards-shaper created generic standards that didn't match the project: - ❌ Generic examples (Express when project uses Fastify) - ❌ Wrong framework versions (React 17 when using React 18) - ❌ Generic patterns not specific to project's tech stack - ❌ Had to manually update all examples - ❌ Standards became stale as project evolved ## Solution standards-shaper now has two intelligent modes: ### Create Mode (No existing standards) - Detects tech stack - Generates standards with project-specific examples - All examples match detected frameworks ### Update Mode (Existing standards found) ⭐ NEW - Reads existing standard files - Detects current tech stack - Updates examples to match current stack - Preserves structure and user customizations - Adds project-specific patterns from codebase ## How It Works **Update Process**: ``` 1. Check: if [ -d "droidz/standards" ]; UPDATE mode 2. Detect: Find package.json, analyze imports, check configs 3. Read: Load each existing standard file 4. Update: Replace examples with project-specific ones 5. Report: Show what changed ``` **Example Update Flow**: ```markdown Project detected: Express + TypeScript + Prisma + PostgreSQL backend/api.md: Before: Generic REST examples After: Express + TypeScript + Prisma patterns backend/database.md: Before: Generic SQL After: Prisma Client + PostgreSQL specific queries frontend/components.md: Before: React class components After: React 18 hooks + Server Components frontend/styling.md: Before: CSS Modules examples After: Tailwind CSS v4 patterns ``` ## What Gets Updated **All standards updated with project-specific patterns**: - `error-handling.md` - Try-catch patterns from codebase - `testing.md` - Jest/Vitest/Playwright from package.json - `components.md` - React/Vue/Angular version-specific - `styling.md` - Tailwind/styled-components/CSS Modules - `state-management.md` - Redux/Zustand/Jotai patterns - `api-design.md` - Express/Fastify/Hono/etc - `database.md` - Prisma/TypeORM/Sequelize/Drizzle - `authentication.md` - NextAuth/Passport/Lucia ## Benefits **For Users**: - ✅ Standards match actual tech stack - ✅ Examples use real frameworks from project - ✅ Can re-run to update when upgrading frameworks - ✅ Standards evolve with project - ✅ No manual updates needed **For Teams**: - ✅ New members see project-specific examples - ✅ Standards reflect current architecture - ✅ Consistency across codebase - ✅ Framework upgrades reflected in standards ## Usage ```bash # First time - creates standards > /standards-shaper AI: No standards found, creating... AI: Detected Next.js 15 + React 18 + Prisma ✅ Created standards with Next.js 15 examples # Later - after upgrading to React 19 > /standards-shaper AI: Found existing standards, updating... AI: Detected React 19 (upgraded from 18) AI: Updating components.md with React 19 patterns... ✅ Updated standards to React 19 ``` ## Implementation Details **Detection Logic**: - Check for package.json dependencies - Analyze import statements with Grep - Read framework config files - Identify versions and variants **Update Logic**: - Read existing standard structure - Keep headings and organization - Replace code examples with project-specific ones - Add patterns found in codebase analysis - Preserve any user customizations **Intelligent Updates**: - Only updates examples and patterns - Preserves structure and explanations - Maintains DO/DON'T sections - Keeps user-added content ## Files Modified - droid_cli/default/commands/standards-shaper.md (major update) - claude/default/commands/standards-shaper.md (synced) ## Breaking Changes None - backward compatible. Command works as before for new projects. --- Closes #standards-update Closes #project-specific-standards
1 parent 89f693f commit d8930c9

File tree

6 files changed

+967
-52
lines changed

6 files changed

+967
-52
lines changed

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,93 @@ Without this, Factory CLI ignores the skill file completely.
147147
- `claude/default/skills/*/SKILL.md` (49 files updated, 1 already correct)
148148
- `droid_cli/default/skills/*/SKILL.md` (49 files updated, 1 already correct)
149149

150+
## [4.7.0] - 2024-11-24
151+
152+
### Changed
153+
- **standards-shaper Updates Existing Standards**: Command now intelligently updates existing standards based on project
154+
- Detects tech stack and updates examples in existing standard files
155+
- Replaces generic examples with project-specific patterns
156+
- Preserves structure while updating content to match your frameworks
157+
- Example: Updates `api.md` from generic REST to your Express+TypeScript+Prisma patterns
158+
159+
### Enhanced
160+
- **/standards-shaper command** now has two modes:
161+
- **Create mode**: Generates new standards from scratch (if no standards exist)
162+
- **Update mode**: Updates existing standards to match current project (if standards found)
163+
164+
### Technical Details
165+
166+
**Update Mode Behavior**:
167+
```
168+
1. Check for existing standards
169+
2. Read each standard file
170+
3. Detect project tech stack (React, Next.js, Express, Prisma, etc.)
171+
4. Update examples in standards to match detected stack
172+
5. Add project-specific patterns from codebase analysis
173+
6. Preserve user customizations
174+
```
175+
176+
**Example Update**:
177+
```markdown
178+
Before (generic in backend/api.md):
179+
app.get('/users/:id', async (req, res) => {
180+
// Generic example
181+
})
182+
183+
After (project-specific with detected Express + TypeScript + Prisma):
184+
app.get('/api/v1/users/:id', async (req: Request, res: Response) => {
185+
const user = await prisma.user.findUnique({
186+
where: { id: req.params.id }
187+
});
188+
if (!user) return res.status(404).json({ error: 'User not found' });
189+
res.json(user);
190+
});
191+
```
192+
193+
**What Gets Updated**:
194+
- `error-handling.md` - Updated with project's try-catch patterns
195+
- `testing.md` - Updated with detected test framework (Jest/Vitest/etc)
196+
- `components.md` - Updated with React/Vue/Angular version-specific patterns
197+
- `styling.md` - Updated with Tailwind/CSS-in-JS/etc found in project
198+
- `state-management.md` - Updated with Redux/Zustand/Pinia/etc patterns
199+
- `api-design.md` - Updated with Express/FastAPI/etc patterns
200+
- `database.md` - Updated with PostgreSQL/MongoDB/Prisma/etc examples
201+
- `authentication.md` - Updated with NextAuth/Passport/etc patterns
202+
203+
### Impact
204+
- ✅ Standards now stay synchronized with project tech stack
205+
- ✅ Examples in standards match actual frameworks used
206+
- ✅ No more generic "best practices" - project-specific guidance
207+
- ✅ Standards evolve as project evolves
208+
- ✅ Can re-run `/standards-shaper` to update standards when upgrading frameworks
209+
210+
### User Experience
211+
212+
**Before v4.7.0**:
213+
```
214+
> /standards-shaper
215+
AI: Creates generic standards
216+
Result: backend/api.md has generic Express examples (but you use Fastify!)
217+
```
218+
219+
**After v4.7.0**:
220+
```
221+
> /standards-shaper
222+
AI: Detected existing standards, updating...
223+
AI: Found Fastify + TypeScript + PostgreSQL
224+
AI: Updating api.md with Fastify patterns...
225+
226+
Result: backend/api.md now has Fastify-specific examples matching your project!
227+
```
228+
229+
**Output Shows Changes**:
230+
```
231+
✅ Updated api-design.md - Changed from Express to Fastify patterns
232+
✅ Updated database.md - Changed from generic SQL to PostgreSQL + node-postgres
233+
✅ Updated components.md - Changed from React 17 to React 18 patterns
234+
✅ Updated styling.md - Changed from CSS Modules to Tailwind CSS v4
235+
```
236+
150237
## [4.6.0] - 2024-11-24
151238

152239
### Added

droidz_installer/payloads/claude/default/commands/standards-shaper.md

Lines changed: 128 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,30 +142,53 @@ Use Grep to find existing patterns:
142142
- API patterns: Grep "api|endpoint|route"
143143
```
144144

145-
### PHASE 4: Generate Standards Documents
145+
### PHASE 4: Generate/Update Standards Documents
146146

147-
Create comprehensive standards files based on research and project analysis.
147+
Create or update comprehensive standards files based on research and project analysis.
148148

149-
#### Step 4.1: Create directory structure
149+
#### Step 4.1: Check for existing standards
150+
151+
First, check if standards already exist:
152+
153+
```bash
154+
if [ -d "droidz/standards" ]; then
155+
echo "✅ Found existing standards directory"
156+
UPDATING_STANDARDS=true
157+
else
158+
echo "📝 Creating new standards directory"
159+
UPDATING_STANDARDS=false
160+
fi
161+
```
162+
163+
**If updating existing standards**:
164+
- Read each existing standard file
165+
- Keep the structure but update examples to match detected tech stack
166+
- Add project-specific patterns found in codebase
167+
- Preserve any user customizations (check git diff if available)
168+
169+
**If creating new standards**:
170+
- Generate from templates with project-specific content
171+
172+
#### Step 4.2: Create/Update directory structure
150173

151174
```
152175
droidz/standards/
153176
├── README.md
154177
├── global/
155178
│ ├── coding-principles.md
156-
│ ├── error-handling.md
157-
│ ├── testing.md
179+
│ ├── error-handling.md [UPDATE with project's error patterns]
180+
│ ├── testing.md [UPDATE with detected test framework]
158181
│ ├── security.md
159182
│ └── performance.md
160183
├── frontend/ [if frontend detected]
161-
│ ├── components.md
162-
│ ├── styling.md
163-
│ ├── state-management.md
184+
│ ├── components.md [UPDATE with React/Vue/Angular patterns]
185+
│ ├── styling.md [UPDATE with Tailwind/CSS-in-JS/etc]
186+
│ ├── state-management.md [UPDATE with Redux/Zustand/Pinia/etc]
164187
│ └── routing.md
165188
├── backend/ [if backend detected]
166-
│ ├── api-design.md
167-
│ ├── database.md
168-
│ ├── authentication.md
189+
│ ├── api-design.md [UPDATE with Express/FastAPI/etc patterns]
190+
│ ├── database.md [UPDATE with PostgreSQL/MongoDB/etc]
191+
│ ├── authentication.md [UPDATE with NextAuth/Passport/etc]
169192
│ └── error-responses.md
170193
└── infrastructure/ [if scope includes it]
171194
├── deployment.md
@@ -284,15 +307,53 @@ Each standard file should follow this format:
284307
- [Tools and linters]
285308
```
286309

287-
#### Step 4.3: Generate content for each standard
310+
#### Step 4.3: Generate/Update content for each standard
311+
312+
For each standard file:
288313

289-
For each standard file, include:
314+
**If updating existing standard**:
315+
1. Read current content
316+
2. Keep structure (headings, sections)
317+
3. Update examples to use detected frameworks
318+
4. Add patterns found in codebase analysis
319+
5. Replace generic examples with project-specific ones
320+
6. Preserve user customizations
290321

322+
**Example Update Process for `backend/api.md`**:
323+
```javascript
324+
// Detected: Express + TypeScript + PostgreSQL
325+
326+
// Before (generic):
327+
```
328+
app.get('/users/:id', async (req, res) => {
329+
// Generic example
330+
})
331+
```
332+
333+
// After (project-specific):
334+
```
335+
app.get('/api/v1/users/:id', async (req: Request, res: Response) => {
336+
const user = await prisma.user.findUnique({
337+
where: { id: req.params.id }
338+
});
339+
if (!user) return res.status(404).json({ error: 'User not found' });
340+
res.json(user);
341+
});
342+
```
343+
344+
**If creating new standard**, include:
291345
1. **Research-backed content** (if tools available)
292346
2. **Framework-specific patterns** (from detected tech stack)
293347
3. **Project-specific patterns** (from codebase analysis)
294-
4. **Concrete examples** (with actual code)
295-
5. **Clear dos and don'ts** (with explanations)
348+
4. **Concrete examples** (with actual code from the project)
349+
5. **Clear dos and don'ts** (with project-relevant explanations)
350+
351+
**Critical**: Always use project's actual:
352+
- Framework versions (React 18, Next.js 15, etc.)
353+
- Database (PostgreSQL, MongoDB, etc.)
354+
- Testing framework (Jest, Vitest, Playwright, etc.)
355+
- Styling approach (Tailwind, CSS Modules, styled-components, etc.)
356+
- State management (Redux, Zustand, Jotai, etc.)
296357
297358
### PHASE 5: Create README.md
298359
@@ -378,8 +439,59 @@ Standards should be updated when:
378439

379440
### PHASE 6: Inform User
380441

381-
Output to user:
442+
Output to user (adjust based on whether updating or creating):
443+
444+
**If updated existing standards**:
445+
```
446+
✅ Project standards updated successfully!
447+
448+
📁 Standards Location: droidz/standards/
449+
450+
📋 Updated Standards:
451+
452+
Global:
453+
✅ error-handling.md - Updated with try-catch patterns from codebase
454+
✅ testing.md - Updated with Jest + React Testing Library examples
455+
456+
Frontend:
457+
✅ components.md - Updated with React 18 patterns
458+
✅ styling.md - Updated with Tailwind CSS v4 examples
459+
✅ state-management.md - Updated with Zustand patterns found in /src/store
460+
461+
Backend:
462+
✅ api-design.md - Updated with Express + TypeScript patterns
463+
✅ database.md - Updated with Prisma + PostgreSQL examples
464+
465+
📊 Research Used:
466+
✅ Exa Code Context - React 18 best practices
467+
✅ Ref Documentation - Next.js 15 App Router
468+
✅ Codebase Analysis - Found 47 components, 12 API routes
469+
✅ Framework Knowledge - Next.js 15, PostgreSQL 16
470+
471+
🔄 Changes Made:
472+
• Replaced generic examples with Next.js 15 App Router patterns
473+
• Added Server Components vs Client Components guidelines
474+
• Updated API examples to match /app/api structure
475+
• Database examples now use Prisma (found in project)
476+
• Tailwind CSS v4 patterns (detected from config)
477+
478+
💡 What Changed:
479+
• All code examples now match your tech stack
480+
• Patterns reflect your actual codebase structure
481+
• DO/DON'T examples use your frameworks
482+
• Standards are now project-specific, not generic
483+
484+
💡 Next Steps:
485+
486+
1. Review updated standards in droidz/standards/
487+
2. Verify examples match your coding style
488+
3. Add any team-specific conventions
489+
4. Standards will automatically guide all future development
490+
491+
🔗 Workflow Guide: droidz/standards/RECOMMENDED_WORKFLOW.md
492+
```
382493

494+
**If created new standards**:
383495
```
384496
✅ Project standards created successfully!
385497

0 commit comments

Comments
 (0)