claude-code-starter 0.4.1 → 0.7.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.
Files changed (2) hide show
  1. package/dist/cli.js +414 -359
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { execSync, spawn } from "child_process";
4
5
  import fs3 from "fs";
5
6
  import path3 from "path";
6
7
  import { fileURLToPath } from "url";
@@ -535,7 +536,6 @@ import path2 from "path";
535
536
  function generateArtifacts(projectInfo) {
536
537
  const artifacts = [];
537
538
  const { techStack, rootDir } = projectInfo;
538
- artifacts.push(generateClaudeMd(projectInfo));
539
539
  artifacts.push(generateSettings(techStack));
540
540
  artifacts.push(...generateSkills(techStack));
541
541
  artifacts.push(...generateAgents(techStack));
@@ -562,7 +562,7 @@ function writeArtifacts(artifacts, rootDir, force) {
562
562
  fs2.mkdirSync(dir, { recursive: true });
563
563
  const exists = fs2.existsSync(fullPath);
564
564
  if (exists && !force) {
565
- const shouldPreserve = artifact.path.includes("state/task.md") || artifact.path === ".claude/CLAUDE.md";
565
+ const shouldPreserve = artifact.path.includes("state/task.md");
566
566
  if (shouldPreserve) {
567
567
  skipped.push(artifact.path);
568
568
  continue;
@@ -577,202 +577,6 @@ function writeArtifacts(artifacts, rootDir, force) {
577
577
  }
578
578
  return { created, updated, skipped };
579
579
  }
580
- function generateClaudeMd(projectInfo) {
581
- const { techStack, name, description } = projectInfo;
582
- const sections = [];
583
- sections.push(`# ${name}`);
584
- sections.push("");
585
- if (description) {
586
- sections.push(`> ${description}`);
587
- sections.push("");
588
- }
589
- sections.push("## Start Here");
590
- sections.push("");
591
- sections.push("Check `.claude/state/task.md` for your current task.");
592
- sections.push("");
593
- sections.push("## Tech Stack");
594
- sections.push("");
595
- if (techStack.primaryLanguage) {
596
- sections.push(`- **Language**: ${formatLanguage(techStack.primaryLanguage)}`);
597
- }
598
- if (techStack.primaryFramework) {
599
- sections.push(`- **Framework**: ${formatFramework(techStack.primaryFramework)}`);
600
- }
601
- if (techStack.packageManager) {
602
- sections.push(`- **Package Manager**: ${techStack.packageManager}`);
603
- }
604
- if (techStack.testingFramework) {
605
- sections.push(`- **Testing**: ${techStack.testingFramework}`);
606
- }
607
- if (techStack.linter) {
608
- sections.push(`- **Linter**: ${techStack.linter}`);
609
- }
610
- sections.push("");
611
- sections.push("## Commands");
612
- sections.push("");
613
- sections.push("| Command | Purpose |");
614
- sections.push("|---------|---------|");
615
- sections.push("| `/task <desc>` | Start or switch to a new task |");
616
- sections.push("| `/status` | Show current task state |");
617
- sections.push("| `/done` | Mark current task complete |");
618
- sections.push("| `/analyze <area>` | Deep-dive into specific code |");
619
- sections.push("| `/code-review` | Review changes for quality and security |");
620
- sections.push("");
621
- sections.push("## Common Operations");
622
- sections.push("");
623
- sections.push("```bash");
624
- sections.push(getCommonCommands(techStack));
625
- sections.push("```");
626
- sections.push("");
627
- sections.push("## Rules");
628
- sections.push("");
629
- sections.push("1. **State First** - Always read `.claude/state/task.md` when resuming");
630
- sections.push("2. **One Task** - Focus on one thing at a time");
631
- sections.push("3. **Test Before Done** - Run tests before marking complete");
632
- sections.push("4. **Update State** - Keep task.md current as you work");
633
- sections.push("5. **Match Patterns** - Follow existing code conventions");
634
- sections.push("6. **TDD Workflow** - Write failing tests first, then implement");
635
- sections.push("");
636
- sections.push("## Quality Gates");
637
- sections.push("");
638
- sections.push("Enforced constraints for code quality:");
639
- sections.push("");
640
- sections.push("| Constraint | Limit | Action |");
641
- sections.push("|------------|-------|--------|");
642
- sections.push("| Lines per function | 20 max | Decompose immediately |");
643
- sections.push("| Parameters per function | 3 max | Use options object |");
644
- sections.push("| Lines per file | 200 max | Split by responsibility |");
645
- sections.push("| Test coverage | 80% min | Add tests before merge |");
646
- sections.push("");
647
- sections.push("## Skills");
648
- sections.push("");
649
- sections.push("Reference these for specialized workflows:");
650
- const skills = getSkillsForStack(techStack);
651
- for (const skill of skills) {
652
- sections.push(`- \`.claude/skills/${skill.name}.md\` - ${skill.description}`);
653
- }
654
- sections.push("");
655
- const agents = getAgentsForStack(techStack);
656
- if (agents.length > 0) {
657
- sections.push("## Agents");
658
- sections.push("");
659
- sections.push("Specialized agents available:");
660
- for (const agent of agents) {
661
- sections.push(`- \`${agent.name}\` - ${agent.description}`);
662
- }
663
- sections.push("");
664
- }
665
- sections.push("## File References");
666
- sections.push("");
667
- sections.push("Use `path/to/file.ts:123` format when referencing code.");
668
- sections.push("");
669
- return {
670
- type: "claude-md",
671
- path: ".claude/CLAUDE.md",
672
- content: sections.join("\n"),
673
- isNew: true
674
- };
675
- }
676
- function getCommonCommands(stack) {
677
- const commands = [];
678
- switch (stack.packageManager) {
679
- case "bun":
680
- commands.push("# Install dependencies");
681
- commands.push("bun install");
682
- commands.push("");
683
- commands.push("# Run development server");
684
- commands.push("bun dev");
685
- commands.push("");
686
- commands.push("# Run tests");
687
- commands.push("bun test");
688
- commands.push("");
689
- commands.push("# Build");
690
- commands.push("bun run build");
691
- break;
692
- case "pnpm":
693
- commands.push("# Install dependencies");
694
- commands.push("pnpm install");
695
- commands.push("");
696
- commands.push("# Run development server");
697
- commands.push("pnpm dev");
698
- commands.push("");
699
- commands.push("# Run tests");
700
- commands.push("pnpm test");
701
- break;
702
- case "yarn":
703
- commands.push("# Install dependencies");
704
- commands.push("yarn");
705
- commands.push("");
706
- commands.push("# Run development server");
707
- commands.push("yarn dev");
708
- commands.push("");
709
- commands.push("# Run tests");
710
- commands.push("yarn test");
711
- break;
712
- case "npm":
713
- commands.push("# Install dependencies");
714
- commands.push("npm install");
715
- commands.push("");
716
- commands.push("# Run development server");
717
- commands.push("npm run dev");
718
- commands.push("");
719
- commands.push("# Run tests");
720
- commands.push("npm test");
721
- break;
722
- case "pip":
723
- case "poetry":
724
- commands.push("# Install dependencies");
725
- commands.push(
726
- stack.packageManager === "poetry" ? "poetry install" : "pip install -r requirements.txt"
727
- );
728
- commands.push("");
729
- commands.push("# Run tests");
730
- commands.push("pytest");
731
- commands.push("");
732
- commands.push("# Run server");
733
- commands.push("uvicorn main:app --reload");
734
- break;
735
- case "cargo":
736
- commands.push("# Build");
737
- commands.push("cargo build");
738
- commands.push("");
739
- commands.push("# Run tests");
740
- commands.push("cargo test");
741
- commands.push("");
742
- commands.push("# Run");
743
- commands.push("cargo run");
744
- break;
745
- case "go":
746
- commands.push("# Run tests");
747
- commands.push("go test ./...");
748
- commands.push("");
749
- commands.push("# Build");
750
- commands.push("go build");
751
- commands.push("");
752
- commands.push("# Run");
753
- commands.push("go run .");
754
- break;
755
- default:
756
- commands.push("# No package manager detected");
757
- commands.push("# Add your common commands here");
758
- }
759
- if (stack.linter) {
760
- commands.push("");
761
- commands.push("# Lint");
762
- switch (stack.linter) {
763
- case "eslint":
764
- commands.push(`${stack.packageManager === "bun" ? "bun" : "npx"} eslint .`);
765
- break;
766
- case "biome":
767
- commands.push(`${stack.packageManager === "bun" ? "bun" : "npx"} biome check .`);
768
- break;
769
- case "ruff":
770
- commands.push("ruff check .");
771
- break;
772
- }
773
- }
774
- return commands.join("\n");
775
- }
776
580
  function generateSettings(stack) {
777
581
  const permissions = ["Read(**)", "Edit(**)", "Write(.claude/**)", "Bash(git:*)"];
778
582
  const pkgManagers = ["npm", "yarn", "pnpm", "bun", "npx"];
@@ -845,51 +649,6 @@ function generateSettings(stack) {
845
649
  isNew: true
846
650
  };
847
651
  }
848
- function getSkillsForStack(stack) {
849
- const skills = [
850
- // Core methodology skills
851
- { name: "pattern-discovery", description: "Finding codebase patterns" },
852
- { name: "systematic-debugging", description: "Debugging approach" },
853
- { name: "testing-methodology", description: "Testing strategy" },
854
- // Process discipline skills
855
- { name: "iterative-development", description: "TDD loops until tests pass" },
856
- { name: "commit-hygiene", description: "Atomic commits and PR size limits" },
857
- { name: "code-deduplication", description: "Prevent semantic code duplication" },
858
- { name: "simplicity-rules", description: "Code complexity constraints" },
859
- { name: "security", description: "Security patterns and secrets management" }
860
- ];
861
- if (stack.frameworks.includes("nextjs")) {
862
- skills.push({ name: "nextjs-patterns", description: "Next.js App Router patterns" });
863
- }
864
- if (stack.frameworks.includes("react") || stack.frameworks.includes("nextjs")) {
865
- skills.push({ name: "react-components", description: "React component patterns" });
866
- }
867
- if (stack.frameworks.includes("fastapi")) {
868
- skills.push({ name: "fastapi-patterns", description: "FastAPI endpoint patterns" });
869
- }
870
- if (stack.frameworks.includes("nestjs")) {
871
- skills.push({ name: "nestjs-patterns", description: "NestJS module patterns" });
872
- }
873
- if (stack.frameworks.includes("prisma") || stack.frameworks.includes("drizzle")) {
874
- skills.push({ name: "database-patterns", description: "Database and ORM patterns" });
875
- }
876
- if (stack.frameworks.includes("swiftui")) {
877
- skills.push({ name: "swiftui-patterns", description: "SwiftUI declarative UI patterns" });
878
- }
879
- if (stack.frameworks.includes("uikit")) {
880
- skills.push({ name: "uikit-patterns", description: "UIKit view controller patterns" });
881
- }
882
- if (stack.frameworks.includes("vapor")) {
883
- skills.push({ name: "vapor-patterns", description: "Vapor server-side Swift patterns" });
884
- }
885
- if (stack.frameworks.includes("jetpack-compose")) {
886
- skills.push({ name: "compose-patterns", description: "Jetpack Compose UI patterns" });
887
- }
888
- if (stack.frameworks.includes("android-views")) {
889
- skills.push({ name: "android-views-patterns", description: "Android XML views patterns" });
890
- }
891
- return skills;
892
- }
893
652
  function generateSkills(stack) {
894
653
  const artifacts = [];
895
654
  artifacts.push(generatePatternDiscoverySkill());
@@ -3303,16 +3062,6 @@ Before PR merge:
3303
3062
  isNew: true
3304
3063
  };
3305
3064
  }
3306
- function getAgentsForStack(stack) {
3307
- const agents = [
3308
- { name: "code-reviewer", description: "Reviews code for quality and security" },
3309
- { name: "test-writer", description: "Generates tests for code" }
3310
- ];
3311
- if (stack.hasDocker) {
3312
- agents.push({ name: "docker-helper", description: "Helps with Docker and containerization" });
3313
- }
3314
- return agents;
3315
- }
3316
3065
  function generateAgents(stack) {
3317
3066
  const artifacts = [];
3318
3067
  artifacts.push(generateCodeReviewerAgent(stack));
@@ -3827,90 +3576,331 @@ Provide:
3827
3576
  isNew: true
3828
3577
  };
3829
3578
  }
3830
- function formatLanguage(lang) {
3831
- const names = {
3832
- typescript: "TypeScript",
3833
- javascript: "JavaScript",
3834
- python: "Python",
3835
- go: "Go",
3836
- rust: "Rust",
3837
- java: "Java",
3838
- ruby: "Ruby",
3839
- csharp: "C#",
3840
- swift: "Swift",
3841
- kotlin: "Kotlin",
3842
- php: "PHP",
3843
- cpp: "C++"
3844
- };
3845
- return names[lang] || lang;
3579
+
3580
+ // src/prompt.ts
3581
+ function getAnalysisPrompt(projectInfo) {
3582
+ const context = buildContextSection(projectInfo);
3583
+ return `${ANALYSIS_PROMPT}
3584
+
3585
+ ---
3586
+
3587
+ ## Pre-detected Context
3588
+
3589
+ The static analyzer has already detected the following about this project.
3590
+ Use this as a starting point - verify and expand on it during your analysis.
3591
+
3592
+ ${context}
3593
+
3594
+ ---
3595
+
3596
+ ## Execute Now
3597
+
3598
+ 1. Read this entire prompt to understand all phases
3599
+ 2. Execute Phase 1 completely - read files, analyze code, gather all data
3600
+ 3. Execute Phase 2 - generate the CLAUDE.md using only discovered information
3601
+ 4. Execute Phase 3 - verify quality before writing
3602
+ 5. Use the Write tool to create \`.claude/CLAUDE.md\` with the final content
3603
+ 6. Output a brief summary of what was generated and any gaps found
3604
+
3605
+ Do NOT output the full CLAUDE.md to stdout. Write it to disk using the Write tool.`;
3846
3606
  }
3847
- function formatFramework(fw) {
3848
- const names = {
3849
- // JavaScript/TypeScript Frontend
3850
- nextjs: "Next.js",
3851
- react: "React",
3852
- vue: "Vue.js",
3853
- nuxt: "Nuxt",
3854
- svelte: "Svelte",
3855
- sveltekit: "SvelteKit",
3856
- angular: "Angular",
3857
- astro: "Astro",
3858
- remix: "Remix",
3859
- gatsby: "Gatsby",
3860
- solid: "Solid.js",
3861
- // JavaScript/TypeScript Backend
3862
- express: "Express",
3863
- nestjs: "NestJS",
3864
- fastify: "Fastify",
3865
- hono: "Hono",
3866
- elysia: "Elysia",
3867
- koa: "Koa",
3868
- // Python
3869
- fastapi: "FastAPI",
3870
- django: "Django",
3871
- flask: "Flask",
3872
- starlette: "Starlette",
3873
- // Go
3874
- gin: "Gin",
3875
- echo: "Echo",
3876
- fiber: "Fiber",
3877
- // Rust
3878
- actix: "Actix",
3879
- axum: "Axum",
3880
- rocket: "Rocket",
3881
- // Ruby
3882
- rails: "Rails",
3883
- sinatra: "Sinatra",
3884
- // Java/Kotlin
3885
- spring: "Spring",
3886
- quarkus: "Quarkus",
3887
- // Android
3888
- "jetpack-compose": "Jetpack Compose",
3889
- "android-views": "Android Views",
3890
- room: "Room",
3891
- hilt: "Hilt",
3892
- "ktor-android": "Ktor",
3893
- // Swift/iOS
3894
- swiftui: "SwiftUI",
3895
- uikit: "UIKit",
3896
- vapor: "Vapor",
3897
- swiftdata: "SwiftData",
3898
- combine: "Combine",
3899
- // CSS/UI
3900
- tailwind: "Tailwind CSS",
3901
- shadcn: "shadcn/ui",
3902
- chakra: "Chakra UI",
3903
- mui: "Material UI",
3904
- // Database/ORM
3905
- prisma: "Prisma",
3906
- drizzle: "Drizzle",
3907
- typeorm: "TypeORM",
3908
- sequelize: "Sequelize",
3909
- mongoose: "Mongoose",
3910
- sqlalchemy: "SQLAlchemy"
3911
- };
3912
- return names[fw] || fw;
3607
+ function buildContextSection(projectInfo) {
3608
+ const { name, description, techStack, fileCount } = projectInfo;
3609
+ const lines = [];
3610
+ lines.push(`- **Project Name**: ${name}`);
3611
+ if (description) {
3612
+ lines.push(`- **Description**: ${description}`);
3613
+ }
3614
+ lines.push(`- **Source Files**: ${fileCount}`);
3615
+ if (techStack.primaryLanguage) {
3616
+ lines.push(`- **Primary Language**: ${techStack.primaryLanguage}`);
3617
+ }
3618
+ if (techStack.languages.length > 1) {
3619
+ lines.push(
3620
+ `- **Other Languages**: ${techStack.languages.filter((l) => l !== techStack.primaryLanguage).join(", ")}`
3621
+ );
3622
+ }
3623
+ if (techStack.primaryFramework) {
3624
+ lines.push(`- **Primary Framework**: ${techStack.primaryFramework}`);
3625
+ }
3626
+ if (techStack.frameworks.length > 1) {
3627
+ lines.push(
3628
+ `- **Other Frameworks**: ${techStack.frameworks.filter((f) => f !== techStack.primaryFramework).join(", ")}`
3629
+ );
3630
+ }
3631
+ if (techStack.packageManager) {
3632
+ lines.push(`- **Package Manager**: ${techStack.packageManager}`);
3633
+ }
3634
+ if (techStack.testingFramework) {
3635
+ lines.push(`- **Testing Framework**: ${techStack.testingFramework}`);
3636
+ }
3637
+ if (techStack.linter) {
3638
+ lines.push(`- **Linter**: ${techStack.linter}`);
3639
+ }
3640
+ if (techStack.formatter) {
3641
+ lines.push(`- **Formatter**: ${techStack.formatter}`);
3642
+ }
3643
+ if (techStack.bundler) {
3644
+ lines.push(`- **Bundler**: ${techStack.bundler}`);
3645
+ }
3646
+ if (techStack.isMonorepo) {
3647
+ lines.push("- **Monorepo**: yes");
3648
+ }
3649
+ if (techStack.hasDocker) {
3650
+ lines.push("- **Docker**: yes");
3651
+ }
3652
+ if (techStack.hasCICD && techStack.cicdPlatform) {
3653
+ lines.push(`- **CI/CD**: ${techStack.cicdPlatform}`);
3654
+ }
3655
+ return lines.join("\n");
3913
3656
  }
3657
+ var ANALYSIS_PROMPT = `You are a senior software architect performing a comprehensive codebase analysis.
3658
+ Your goal is to generate a professional \`.claude/CLAUDE.md\` file that gives Claude
3659
+ complete context to work effectively in this project.
3660
+
3661
+ **This is NOT a generic template.** Every section must contain information specific to THIS
3662
+ project, discovered through actual file reading and analysis. If you cannot determine
3663
+ something, omit that section entirely - do not fill in generic boilerplate.
3664
+
3665
+ ---
3666
+
3667
+ ## Phase 1: Discovery (Read Before You Write)
3668
+
3669
+ Perform these analysis steps IN ORDER. Do not skip any step. Do not start writing
3670
+ the CLAUDE.md until all discovery is complete.
3671
+
3672
+ ### 1.1 Project Identity
3673
+
3674
+ - Read \`package.json\`, \`pyproject.toml\`, \`Cargo.toml\`, \`go.mod\`, \`Gemfile\`, or equivalent
3675
+ - Extract: project name, version, description, author, license
3676
+ - Read \`README.md\` if it exists - extract the project's purpose in one sentence
3677
+ - Check for a \`docs/\` folder and scan for architecture docs
3678
+
3679
+ ### 1.2 Directory Structure Map
3680
+
3681
+ - List the top-level directories and their purposes
3682
+ - Identify the source code root (\`src/\`, \`lib/\`, \`app/\`, \`pkg/\`, etc.)
3683
+ - Identify test directories (\`tests/\`, \`__tests__/\`, \`spec/\`, \`test/\`, etc.)
3684
+ - Identify configuration directories (\`.github/\`, \`.vscode/\`, \`config/\`, etc.)
3685
+ - Note any monorepo structure (\`packages/\`, \`apps/\`, \`services/\`)
3686
+ - Map the directory tree to a max depth of 3 levels (excluding \`node_modules\`, \`.git\`, \`dist\`, \`build\`, \`__pycache__\`, \`.next\`, \`target\`)
3687
+
3688
+ ### 1.3 Tech Stack Deep Scan
3689
+
3690
+ Go beyond just detecting names. For each technology found, note HOW it is used:
3691
+
3692
+ - **Languages**: Primary and secondary. Check config files for strictness settings
3693
+ - **Frameworks**: Read the main entry point to confirm framework usage patterns
3694
+ - **Package Manager**: Check lock files
3695
+ - **Database**: Check for ORM configs, connection strings in env examples, database drivers
3696
+ - **Authentication**: Look for auth libraries, auth middleware, session configs
3697
+ - **API Layer**: REST routes, GraphQL schemas, tRPC routers, gRPC proto files
3698
+ - **State Management**: Redux, Zustand, Pinia, Context API patterns
3699
+ - **Styling**: CSS modules, Tailwind config, styled-components, Sass
3700
+ - **Build Tools**: Check build configs
3701
+ - **CI/CD**: Read workflow files
3702
+ - **Infrastructure**: Docker, Terraform, Kubernetes manifests
3703
+
3704
+ ### 1.4 Architecture Pattern Recognition
3705
+
3706
+ Read 5-10 key source files to identify:
3707
+
3708
+ - **Architecture Style**: MVC, Clean Architecture, Hexagonal, Microservices, Monolith, Serverless
3709
+ - **Code Organization**: Feature-based, Layer-based, Domain-based
3710
+ - **Dependency Injection**: How dependencies are wired
3711
+ - **Data Flow**: How data moves through the application
3712
+ - **Error Handling Pattern**: How errors are caught, transformed, and reported
3713
+ - **API Pattern**: RESTful conventions, GraphQL resolvers, RPC style
3714
+
3715
+ ### 1.5 Entry Points & Key Files
3716
+
3717
+ Identify and read these critical files:
3718
+
3719
+ - **Application Entry**: main.ts, index.ts, app.ts, server.ts, main.py, app.py, main.go, main.rs
3720
+ - **Route/API Definitions**: Where routes/endpoints are registered
3721
+ - **Configuration**: Environment loading, app config
3722
+ - **Database Schema**: Models, migrations, schema definitions
3723
+ - **Middleware Chain**: Authentication, logging, error handling
3724
+ - **Type Definitions**: Shared types, interfaces, schemas
3725
+ - **Constants**: Shared constants, status codes, error codes
3726
+
3727
+ ### 1.6 Code Conventions (Read Actual Code)
3728
+
3729
+ Read at least 3-5 source files and document the ACTUAL patterns used:
3730
+
3731
+ - **Naming**: camelCase vs snake_case, file naming, component naming
3732
+ - **Imports**: Absolute vs relative, import ordering, barrel exports
3733
+ - **Exports**: Default vs named exports, re-export patterns
3734
+ - **Function Style**: Arrow functions vs function declarations, async/await patterns
3735
+ - **Error Handling**: try/catch style, Result types, error-first callbacks
3736
+ - **Type Annotations**: Explicit vs inferred, interface vs type
3737
+ - **File Structure**: How individual files are organized
3738
+
3739
+ ### 1.7 Development Workflow
3740
+
3741
+ - **Scripts**: Read all scripts from package.json or equivalent
3742
+ - **Environment Variables**: Read \`.env.example\`, \`.env.sample\`, or \`.env.template\` - list ALL required variables
3743
+ - **Pre-commit Hooks**: Check \`.husky/\`, \`.lefthook.yml\`, lint-staged config
3744
+ - **Code Quality**: Linter/formatter rules and config
3745
+ - **Testing Setup**: Test config files, test utilities, fixtures, mocks
3746
+ - **Database Operations**: Migrations, seed data, reset commands
3747
+
3748
+ ### 1.8 Domain Knowledge
3749
+
3750
+ - **Business Entities**: Core domain objects (User, Order, Product, etc.)
3751
+ - **Key Workflows**: Main user flows
3752
+ - **External Integrations**: Third-party APIs, webhooks, payment gateways
3753
+ - **Background Jobs**: Queue systems, cron jobs, scheduled tasks
3754
+
3755
+ ---
3756
+
3757
+ ## Phase 2: Generate the CLAUDE.md
3758
+
3759
+ Using ONLY information discovered in Phase 1, generate the \`.claude/CLAUDE.md\` file.
3760
+ Every section must contain PROJECT-SPECIFIC content. Skip sections that don't apply.
3761
+
3762
+ ### Output Structure
3763
+
3764
+ The CLAUDE.md MUST follow this structure:
3765
+
3766
+ \`\`\`markdown
3767
+ # {Project Name}
3768
+
3769
+ > {One-line description from README or package.json}
3770
+
3771
+ ## Overview
3772
+
3773
+ {2-3 sentences: what this project does, who it's for, core value proposition.
3774
+ Written for an AI assistant that needs to understand PURPOSE to make good decisions.}
3775
+
3776
+ ## Architecture
3777
+
3778
+ {Describe the actual architecture pattern found}
3779
+
3780
+ ### Directory Structure
3781
+
3782
+ \\\`\\\`\\\`
3783
+ {Actual directory tree, depth 3, with annotations}
3784
+ \\\`\\\`\\\`
3785
+
3786
+ ### Data Flow
3787
+
3788
+ {How a typical request flows through the system}
3789
+
3790
+ ### Key Files
3791
+
3792
+ | File | Purpose |
3793
+ |------|---------|
3794
+ | \`path/to/file\` | What it does |
3795
+
3796
+ ## Tech Stack
3797
+
3798
+ | Category | Technology | Notes |
3799
+ |----------|-----------|-------|
3800
+ | Language | X | Config details |
3801
+ | Framework | Y | How it's used |
3802
+
3803
+ ## Development Setup
3804
+
3805
+ ### Prerequisites
3806
+
3807
+ {Exact versions and tools needed}
3808
+
3809
+ ### Getting Started
3810
+
3811
+ \\\`\\\`\\\`bash
3812
+ {Actual commands to get running}
3813
+ \\\`\\\`\\\`
3814
+
3815
+ ### Environment Variables
3816
+
3817
+ | Variable | Description | Example |
3818
+ |----------|-------------|---------|
3819
+ | \`VAR_NAME\` | What it's for | \`example_value\` |
3820
+
3821
+ ## Common Commands
3822
+
3823
+ \\\`\\\`\\\`bash
3824
+ {Actual commands from package.json scripts or equivalent}
3825
+ \\\`\\\`\\\`
3826
+
3827
+ ## Code Conventions
3828
+
3829
+ ### Naming
3830
+
3831
+ {ACTUAL naming patterns found}
3832
+
3833
+ ### Patterns to Follow
3834
+
3835
+ {3-5 patterns with file references as examples}
3836
+
3837
+ ### Anti-Patterns to Avoid
3838
+
3839
+ {What NOT to do based on codebase conventions}
3840
+
3841
+ ## Testing
3842
+
3843
+ ### Running Tests
3844
+
3845
+ \\\`\\\`\\\`bash
3846
+ {actual test commands}
3847
+ \\\`\\\`\\\`
3848
+
3849
+ ### Writing Tests
3850
+
3851
+ {Testing patterns, utilities, fixtures available}
3852
+
3853
+ ## Domain Knowledge
3854
+
3855
+ ### Core Entities
3856
+
3857
+ {Main domain objects and relationships}
3858
+
3859
+ ### Key Workflows
3860
+
3861
+ {3-5 most important workflows}
3862
+
3863
+ ## Gotchas & Important Notes
3864
+
3865
+ {3-10 non-obvious things about this project that would trip up a newcomer}
3866
+
3867
+ ## Rules
3868
+
3869
+ 1. **Read before writing** - Understand existing patterns before adding code
3870
+ 2. **Match conventions** - Follow the patterns documented above
3871
+ 3. **Test everything** - Write tests, run existing tests after changes
3872
+ 4. {project-specific rules discovered during analysis}
3873
+ \`\`\`
3874
+
3875
+ ---
3876
+
3877
+ ## Phase 3: Quality Checklist
3878
+
3879
+ Before writing the CLAUDE.md, verify:
3880
+
3881
+ - [ ] Every section contains PROJECT-SPECIFIC information (not generic boilerplate)
3882
+ - [ ] File paths referenced actually exist in the project
3883
+ - [ ] Commands listed are verified from package.json scripts or equivalent
3884
+ - [ ] Code conventions were observed from ACTUAL source files
3885
+ - [ ] The "Gotchas" section contains genuinely useful, non-obvious information
3886
+ - [ ] An AI reading this CLAUDE.md could add a new feature following existing patterns
3887
+ - [ ] Sections without real content have been omitted entirely
3888
+
3889
+ ---
3890
+
3891
+ ## Important Guidelines
3892
+
3893
+ 1. **Be specific, not generic.** "Uses React with hooks" is useless. "Uses React 18 with Server Components via Next.js App Router, client components in src/components/client/ with 'use client' directive" is useful.
3894
+
3895
+ 2. **Reference real files.** Every pattern should reference an actual file as an example. Use \`path/to/file.ts:lineNumber\` format.
3896
+
3897
+ 3. **Prioritize actionable information.** Focus on what helps an AI write correct code: where to put new code, what patterns to follow, what to avoid, how to test.
3898
+
3899
+ 4. **Skip empty sections.** Only include sections with real content.
3900
+
3901
+ 5. **Keep it maintainable.** Don't include metrics that go stale quickly.
3902
+
3903
+ 6. **Respect existing CLAUDE.md.** If one exists, read it first and preserve manually-added sections.`;
3914
3904
 
3915
3905
  // src/cli.ts
3916
3906
  var __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
@@ -3947,13 +3937,16 @@ ${pc.bold("OPTIONS")}
3947
3937
 
3948
3938
  ${pc.bold("WHAT IT DOES")}
3949
3939
  1. Analyzes your repository's tech stack
3950
- 2. Detects frameworks, languages, and tools
3940
+ 2. Launches Claude CLI to deeply analyze your codebase
3951
3941
  3. Generates tailored Claude Code configurations:
3952
- - CLAUDE.md with project-specific instructions
3942
+ - CLAUDE.md with project-specific instructions (via Claude analysis)
3953
3943
  - Skills for your frameworks (Next.js, FastAPI, etc.)
3954
3944
  - Agents for code review and testing
3955
3945
  - Rules matching your code style
3956
3946
 
3947
+ ${pc.bold("REQUIREMENTS")}
3948
+ Claude CLI must be installed: https://claude.ai/download
3949
+
3957
3950
  ${pc.bold("MORE INFO")}
3958
3951
  https://github.com/cassmtnr/claude-code-starter
3959
3952
  `);
@@ -3969,10 +3962,10 @@ function showTechStack(projectInfo, verbose) {
3969
3962
  console.log(pc.bold("Tech Stack"));
3970
3963
  console.log();
3971
3964
  if (techStack.primaryLanguage) {
3972
- console.log(` ${pc.bold("Language:")} ${formatLanguage2(techStack.primaryLanguage)}`);
3965
+ console.log(` ${pc.bold("Language:")} ${formatLanguage(techStack.primaryLanguage)}`);
3973
3966
  }
3974
3967
  if (techStack.primaryFramework) {
3975
- console.log(` ${pc.bold("Framework:")} ${formatFramework2(techStack.primaryFramework)}`);
3968
+ console.log(` ${pc.bold("Framework:")} ${formatFramework(techStack.primaryFramework)}`);
3976
3969
  }
3977
3970
  if (techStack.packageManager) {
3978
3971
  console.log(` ${pc.bold("Package Manager:")} ${techStack.packageManager}`);
@@ -4105,8 +4098,8 @@ ${projectInfo.name}${projectInfo.description ? ` - ${projectInfo.description}` :
4105
4098
 
4106
4099
  New project - setting up from scratch.
4107
4100
 
4108
- ${preferences?.framework ? `**Framework:** ${formatFramework2(preferences.framework)}` : ""}
4109
- ${preferences?.primaryLanguage ? `**Language:** ${formatLanguage2(preferences.primaryLanguage)}` : ""}
4101
+ ${preferences?.framework ? `**Framework:** ${formatFramework(preferences.framework)}` : ""}
4102
+ ${preferences?.primaryLanguage ? `**Language:** ${formatLanguage(preferences.primaryLanguage)}` : ""}
4110
4103
 
4111
4104
  ## Next Steps
4112
4105
 
@@ -4121,7 +4114,7 @@ ${preferences?.primaryLanguage ? `**Language:** ${formatLanguage2(preferences.pr
4121
4114
  }
4122
4115
  fs3.writeFileSync(taskPath, content);
4123
4116
  }
4124
- function formatLanguage2(lang) {
4117
+ function formatLanguage(lang) {
4125
4118
  const names = {
4126
4119
  typescript: "TypeScript",
4127
4120
  javascript: "JavaScript",
@@ -4138,7 +4131,7 @@ function formatLanguage2(lang) {
4138
4131
  };
4139
4132
  return names[lang] || lang;
4140
4133
  }
4141
- function formatFramework2(fw) {
4134
+ function formatFramework(fw) {
4142
4135
  const names = {
4143
4136
  nextjs: "Next.js",
4144
4137
  react: "React",
@@ -4184,6 +4177,53 @@ function formatFramework2(fw) {
4184
4177
  };
4185
4178
  return names[fw] || fw;
4186
4179
  }
4180
+ function checkClaudeCli() {
4181
+ try {
4182
+ execSync("claude --version", { stdio: "ignore" });
4183
+ return true;
4184
+ } catch {
4185
+ return false;
4186
+ }
4187
+ }
4188
+ function runClaudeAnalysis(projectDir, projectInfo) {
4189
+ return new Promise((resolve) => {
4190
+ const prompt = getAnalysisPrompt(projectInfo);
4191
+ console.log(pc.cyan("Launching Claude for deep project analysis..."));
4192
+ console.log(pc.gray("Claude will read your codebase and generate a comprehensive CLAUDE.md"));
4193
+ console.log();
4194
+ const child = spawn(
4195
+ "claude",
4196
+ [
4197
+ "-p",
4198
+ prompt,
4199
+ "--allowedTools",
4200
+ "Read",
4201
+ "Glob",
4202
+ "Grep",
4203
+ `Write(.claude/**)`,
4204
+ `Edit(.claude/**)`
4205
+ ],
4206
+ {
4207
+ cwd: projectDir,
4208
+ stdio: ["ignore", "inherit", "inherit"]
4209
+ }
4210
+ );
4211
+ child.on("error", (err) => {
4212
+ console.error(pc.red(`Failed to launch Claude CLI: ${err.message}`));
4213
+ resolve(false);
4214
+ });
4215
+ child.on("close", (code) => {
4216
+ if (code === 0) {
4217
+ console.log();
4218
+ console.log(pc.green("Claude analysis complete!"));
4219
+ resolve(true);
4220
+ } else {
4221
+ console.error(pc.red(`Claude exited with code ${code}`));
4222
+ resolve(false);
4223
+ }
4224
+ });
4225
+ });
4226
+ }
4187
4227
  async function main() {
4188
4228
  const args = parseArgs(process.argv.slice(2));
4189
4229
  if (args.help) {
@@ -4232,7 +4272,12 @@ async function main() {
4232
4272
  }
4233
4273
  console.log();
4234
4274
  }
4235
- console.log(pc.gray("Generating configuration..."));
4275
+ if (!checkClaudeCli()) {
4276
+ console.error(pc.red("Claude CLI is required but not found."));
4277
+ console.error(pc.gray("Install it from: https://claude.ai/download"));
4278
+ process.exit(1);
4279
+ }
4280
+ console.log(pc.gray("Generating supporting configuration..."));
4236
4281
  console.log();
4237
4282
  const result = generateArtifacts(projectInfo);
4238
4283
  const { created, updated, skipped } = writeArtifacts(result.artifacts, projectDir, args.force);
@@ -4256,10 +4301,17 @@ async function main() {
4256
4301
  }
4257
4302
  console.log();
4258
4303
  createTaskFile(projectInfo, preferences);
4259
- const totalFiles = created.length + updated.length;
4304
+ const success = await runClaudeAnalysis(projectDir, projectInfo);
4305
+ if (!success) {
4306
+ console.error(pc.red("Claude analysis failed. Please try again."));
4307
+ process.exit(1);
4308
+ }
4309
+ const totalFiles = created.length + updated.length + 1;
4310
+ console.log();
4260
4311
  console.log(pc.green(`Done! (${totalFiles} files)`));
4261
4312
  console.log();
4262
4313
  console.log(pc.bold("Generated for your stack:"));
4314
+ console.log(pc.cyan(" CLAUDE.md (deep analysis by Claude)"));
4263
4315
  const skills = result.artifacts.filter((a) => a.type === "skill");
4264
4316
  const agents = result.artifacts.filter((a) => a.type === "agent");
4265
4317
  const rules = result.artifacts.filter((a) => a.type === "rule");
@@ -4279,26 +4331,29 @@ async function main() {
4279
4331
  console.log();
4280
4332
  console.log(`${pc.cyan("Next step:")} Run ${pc.bold("claude")} to start working!`);
4281
4333
  console.log();
4282
- if (!projectInfo.isExisting) {
4283
- console.log(pc.gray("Tip: Use /task to define your first task"));
4284
- } else {
4285
- console.log(pc.gray("Tip: Use /analyze to explore specific areas of your codebase"));
4286
- }
4334
+ console.log(
4335
+ pc.gray("Your CLAUDE.md was generated by deep analysis - review it with: cat .claude/CLAUDE.md")
4336
+ );
4337
+ }
4338
+ var isMain = process.argv[1] === fileURLToPath(import.meta.url);
4339
+ if (isMain) {
4340
+ main().catch((err) => {
4341
+ console.error(pc.red("Error:"), err.message);
4342
+ if (process.env.DEBUG) {
4343
+ console.error(err.stack);
4344
+ }
4345
+ process.exit(1);
4346
+ });
4287
4347
  }
4288
- main().catch((err) => {
4289
- console.error(pc.red("Error:"), err.message);
4290
- if (process.env.DEBUG) {
4291
- console.error(err.stack);
4292
- }
4293
- process.exit(1);
4294
- });
4295
4348
  export {
4349
+ checkClaudeCli,
4296
4350
  createTaskFile,
4297
- formatFramework2 as formatFramework,
4298
- formatLanguage2 as formatLanguage,
4351
+ formatFramework,
4352
+ formatLanguage,
4299
4353
  getVersion,
4300
4354
  parseArgs,
4301
4355
  promptNewProject,
4356
+ runClaudeAnalysis,
4302
4357
  showBanner,
4303
4358
  showHelp,
4304
4359
  showTechStack
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-starter",
3
- "version": "0.4.1",
3
+ "version": "0.7.0",
4
4
  "description": "A lightweight starter kit for AI-assisted development with Claude Code",
5
5
  "keywords": [
6
6
  "claude",