Community编程与开发github.com

wuyining0130/c-room

一套面向 AI 辅助B端研发全流程的 Claude Code Skills:从代码仓库扫描建立知识库,到写 PRD、生成原型、出技术方案、生成代码、代码审查,全链路自动加载项目上下文。

c-room 是什么?

c-room is a Claude Code agent skill that 一套面向 AI 辅助B端研发全流程的 Claude Code Skills:从代码仓库扫描建立知识库,到写 PRD、生成原型、出技术方案、生成代码、代码审查,全链路自动加载项目上下文。.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add wuyining0130/c-room

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Purpose

The technical design document is ready; the next step is to write the code. The traditional approach requires a developer to read the technical design, review existing code, and write code file by file. The problem is that the technical design already specifies the interface design, DDLs, scope of changes, and task breakdown—yet a developer must manually translate all this information into code. This process is highly repetitive and error-prone (misspelled parameter names, inconsistent API paths, missed service changes).

This skill reads the technical design, PRD, prototype, and coding knowledge base. Following the task breakdown in the technical design, it generates/modifies code files directly in the target repository. It does not generate "scaffolding" or "template code"—it generates implementations containing complete business logic, ready for code review (CR).

The core capability lies in deep use of the coding-knowledge: By leveraging symbol indexes, call chains, DDLs, and code conventions from the coding knowledge base, the generated code maintains consistency with the existing project in naming style, layered structure, and exception handling patterns. It looks like it was written by a long-term team member, not an outsourced contractor.

Inputs

  • requirements/{module}/tech-design.md (primary input, containing API designs, DDLs, task breakdowns, and change scopes)
  • requirements/{module}/prd-draft.md (acceptance criteria, business rules, and edge cases)
  • requirements/{module}/prototype/ (frontend page structure for reference)
  • coding-knowledge/ (core reference—code style, architecture patterns, symbol indexes, call chains, DDL patterns, code conventions)
  • Target code repository path (specified by the user, or extracted from the change scopes in the tech design)

Workflow

Phase 0: Read Inputs, Build Context

0.1 Read tech-design.md

Extract the following information as the authoritative source for subsequent generation:

  • Scope of changes (which repositories are affected, which files need to be added/modified)
  • Interface designs (API list, request parameters, response structures, error codes)
  • Database changes (DDLs)
  • Task breakdown (T-01, T-02... with dependencies)
  • Interaction sequence diagrams (inter-service call relationships)
  • Reused interface parameter descriptions (distinguishing parameter and behavior differences)

0.2 Read prd-draft.md

Extract the following information to ensure complete business logic:

  • Feature list and acceptance criteria (ensure generated code covers every feature point)
  • Business rules and edge cases (ensure corresponding validation logic in code)
  • Error handling requirements (specific error message text)

0.3 Deep Read coding-knowledge (Core Step)

This is the biggest difference between code-gen and ordinary AI code generation. Instead of "reading for a rough understanding," it extracts specific coding patterns layer by layer according to the code layers.

Layer 1: Basic Conventions (Must Read)

Read the files under coding-knowledge/infra/ to extract global coding constraints:

  • code-quality.md → Naming conventions (camelCase vs snake_case, prefix/suffix conventions), comment style, exception handling patterns, logging conventions
  • Other infrastructure conventions → Middleware usage patterns (MQ producer/consumer patterns, cache operation patterns)

Layer 2: Repository Architecture (Read per affected repository)

For each repository listed in the tech design, read the files under coding-knowledge/repos/{repo}/:

  • architecture.md → Package structure and layering conventions. When creating new files, determine which package to place them in and how to name classes. Pay special attention to "this service is not responsible for" descriptions—avoid writing logic that doesn't belong to that service
  • symbols.md → Index of signatures for existing classes and methods. This is the entry point for "style learning"—from here, find existing implementations of the same type (e.g., existing Controllers, Services). Phase 1 will later Read the complete source code based on these
  • database-schema.md → Real DDLs of existing tables. When creating new tables, reference field naming conversion rules (e.g., create_time vs createdAt), index naming conventions (e.g., idx_ prefix), charset and engine settings
  • call-chains.md → Actual cross-service invocation code. If the tech design involves cross-service calls, find the actual invocation method used by the project (Feign Client? RestTemplate? WebClient? gRPC stub?), as well as error handling and timeout configuration patterns

Layer 3: Business Domain (Read on Demand)

If the tech design involves cross-service collaboration, read coding-knowledge/business/domains/{domain}/:

  • cross-service.md → Cross-repository call relationships and data flows

0.4 Style Learning (Key Step)

From symbols.md, locate 2-3 existing implementation files of the same type and read their complete source code using the Read tool. The goal is to learn the project's coding patterns, not just look at signatures.

Details:

Code Layer to GenerateReference Object from symbols.mdLearning Points
Entity/ModelExisting Entity class in the same repositoryAnnotation usage, field naming conversion, base class inheritance, auditing field handling
Mapper/RepositoryExisting Mapper/Repository in the same repositoryMyBatis XML vs annotations, custom query method naming patterns, pagination implementation
ServiceExisting Service class in the same repositoryTransaction annotation usage, exception throwing pattern, dependency injection style (constructor vs @Autowired)
ControllerExisting Controller class in the same repositoryUnified response wrapper, parameter validation annotations, permission annotations, Swagger annotation style
Frontend API layerExisting API file in the same projectAxios encapsulation method, request/response interceptors, error handling
Frontend pageExisting list page/form page in the same projectComponent library usage, state management method, search condition layout

The output of style learning is an implicit "coding checklist"—no need to output to the user, but every line of code generated in Phase 2 must follow it. For example:

  • "All Controllers in this project use @RestController + @RequestMapping, not @Controller + @ResponseBody"
  • "Service layer exceptions uniformly use throw new BusinessException(ErrorCode.XXX) instead of returning error codes"
  • "All query methods are named listXxx/getXxx, not queryXxx/findXxx"

Phase 1: Generate Plan (User Confirmation)

Must present a plan to the user and obtain confirmation before writing any code.

Based on the analysis results from Phase 0, output a structured generation plan:

## Code Generation Plan

### Code Style Reference
- Backend reference: {Path to the reference Controller/Service file located from symbols.md}
- Frontend reference: {Path to the reference component located from existing pages}
- Code conventions: {Key constraints from coding-knowledge/infra/code-quality.md}

### Backend ({Repository Name})
| # | Operation | File Path | Description | Corresponding Task |
|---|-----------|-----------|-------------|-------------------|
| 1 | New | {Accurate package path derived from architecture.md}/XxxEntity.java | New entity class | T-01 |
| 2 | New | {Package path}/XxxMapper.java | New Mapper interface | T-01 |
| 3 | Modify | {Accurate file path from symbols.md}:L{Line number} | New method createXxx() | T-02 |
| 4 | New | {Package path}/XxxController.java | New CRUD interface | T-03 |

### Frontend ({Repository Name})
| # | Operation | File Path | Description | Corresponding Task |
|---|-----------|-----------|-------------|-------------------|
| 1 | New | src/api/xxx.js | API call layer | T-05 |
| 2 | New | src/pages/xxx/index.vue | List page (reference prototype/list.html) | T-05 |
| 3 | New | src/pages/xxx/form.vue | New/Edit form | T-05 |

### Database
- Execute the DDL from tech-design (confirmed consistent with database-schema.md style)

### Notes
- {Items requiring user confirmation}

File paths in the plan must be exact paths—not guessed, but derived from architecture.md (package structure) and symbols.md (existing file locations). For operations modifying existing files, annotate the line numbers.

Begin Phase 2 only after user confirmation.

Phase 2: Generate Code by Dependency Order

Generation Principles: Generate from bottom layer to top layer based on dependencies, ensuring correct reference relationships. Write each file immediately after generation.

Backend Generation Order

Follow the order: Entity → Mapper/Repository → Service → Controller → Config/Other:

1. Entity/Model Layer

  • Generate entity classes based on the DDL from tech-design
  • Patterns learned from Phase 0.4: Field annotation style (JPA @Column vs MyBatis-Plus @TableField), base class inheritance (is there a BaseEntity?), auditing fields (how are createTime/updateTime handled?), logical delete fields
  • Reference from database-schema.md: Field naming conversion rules (specific way to convert database create_time to Java createTime—some projects use @TableField("create_time"), others rely on global configuration for automatic conversion)

2. Mapper/Repository Layer

  • Generate data access interfaces corresponding to the Entity
  • Patterns learned from Phase 0.4: MyBatis XML vs annotations, whether to extend BaseMapper<T>, custom query method naming conventions, pagination implementation (PageHelper? MyBatis-Plus IPage?)
  • Include custom query methods mentioned in tech-design

3. Service Layer

  • Implement business logic, corresponding to the processing flow of each interface in tech-design
  • Patterns learned from Phase 0.4: Transaction annotation usage (@Transactional propagation level habits), exception handling patterns (custom BusinessException? Unified ErrorCode enum?), dependency injection style (constructor injection vs @Autowired), logging habits
  • Derive validation logic from PRD acceptance criteria: Each acceptance condition corresponds to a validation branch
  • Cross-service invocation: Find the actual invocation method used by the project from call-chains.md and replicate its code pattern (instead of inventing a new invocation method)

4. Controller Layer

  • API paths, parameters, and response structures must strictly follow the interface design from tech-design
  • Patterns learned from Phase 0.4: Unified response wrapper class (Result<T>? ResponseEntity<T>?), parameter validation annotations (@Valid + JSR 303 vs manual validation), permission annotations (@PreAuthorize? Custom @Permission?), Swagger/OpenAPI annotation style
  • Use the business error codes defined in tech-design

5. Config/Other

  • MQ Consumer/Producer (if tech-design involves it)—find the existing MQ code pattern from call-chains.md
  • Menu/permission configuration files (if needed)
  • New constant/enum classes

Frontend Generation Order

Follow the order: API call layer → Route config → Page components:

1. API Call Layer

  • Generate API methods based on the interface list from tech-design
  • Patterns learned from Phase 0.4: Axios encapsulation method (unified request function? Independent API files?), request/response interceptor handling
  • Method names and parameter names correspond to the interface IDs in tech-design

2. Route Configuration

  • Register routes for new pages
  • Reference the organization of existing route files

3. Page Components

  • Reference page structure from prototype/: The table column order, search condition layout, and dialog structure in the prototype directly guide the component code
  • Use the component library of the project's actual tech stack (determine if it's Element UI, Ant Design, a custom component library, etc., from coding-knowledge or package.json)
  • Derive table column definitions from the API response fields in tech-design
  • Derive form fields and validation rules from the API request parameters in tech-design

Generation Process for Each File

  1. If it's a new file:
    • Confirm the target directory exists (use ls)
    • Create using the Write tool
  2. If it's a modification of an existing file:
    • First Read the complete file content
    • Use Edit for precise modification (do not reformat surrounding code)
  3. Write to the file system immediately after generation (do not batch and write at the end)

Phase 3: Generate Report

Generate code-gen-report.md under the requirements/{module}/ directory:

---
title: "{Module Name} - Code Generation Report"
tech_design_version: "{Tech Design Version}"
date: "{Generation Date}"
---

# {Module Name} - Code Generation Report

## 1. Generation Overview

| Repository | New Files | Modified Files | Corresponding Tasks |
|------------|-----------|----------------|---------------------|
| {Repository Name} | {N} | {M} | T-01 ~ T-03 |

## 2. Code Style Reference

| Code Layer | Referenced Existing File | Key Patterns Learned |
|------------|--------------------------|----------------------|
| Controller | {File Path} | Unified return Result<T>, uses @Valid for validation |
| Service | {File Path} | Constructor injection, BusinessException exception handling |
| Entity | {File Path} | Extends BaseEntity, @TableField annotation |

## 3. File List

### {Repository Name}

#### New Files
| File Path | Description | Corresponding Tech Design Task |
|-----------|-------------|--------------------------------|
| src/.../XxxEntity.java | New entity | T-01 |

#### Modified Files
| File Path | Modification Content | Corresponding Tech Design Task |
|-----------|---------------------|--------------------------------|
| src/.../XxxService.java | New method createXxx() | T-02 |

## 4. Requirements Coverage Check

| PRD Feature | Interface ID | Code File | Acceptance Criteria Coverage |
|-------------|--------------|-----------|------------------------------|
| F-01 | API-01, API-02 | XxxController.java | Full coverage |
| F-02 | API-03 | XxxService.java | Partial coverage (Q-01 pending item not implemented) |

## 5. Uncovered Items

{Tasks listed in tech-design but not generated in this run, with reasons}

## 6. Notes

{Items requiring manual handling by the developer, e.g.:}
- New configuration items needed in the configuration center
- DDL that requires manual execution
- Business logic needing manual confirmation
- Inconsistencies found between coding-knowledge and tech-design

Phase 4: Output Summary

Upon completion, inform the user:

  1. Location of the code generation report
  2. Number of new/modified files (per repository)
  3. Coverage of corresponding tech-design tasks
  4. Items requiring manual handling
  5. Suggest using /code-review to review the generated code

Output Directory

requirements/{module}/
├── prd-draft.md              ← PRD final draft (input)
├── review/                   ← prd-review output
├── prototype/                ← proto-gen output
├── tech-design.md            ← tech-design output (input)
└── code-gen-report.md        ← this skill's output

Actual code changes are written directly to the target repository directory (not under requirements/).

Relationship with Other Skills

coding-knowledge-init                         ← Step Zero: Project Map
  Generates coding-knowledge/
        ↓ (Reference)
project-import → knowledge-init → prd-draft → prd-review → proto-gen
                                                                ↓
                                              tech-design → code-gen → code-review
                                                             ↑
                                                     coding-knowledge/
                                                     (Deep Utilization)
  • Prerequisite: The technical design from tech-design is the primary input; the coding knowledge base from coding-knowledge-init is the core reference
  • Subsequent: The generated code changes are reviewed by code-review
  • Relationship with tech-design: tech-design defines "what to do" (interface designs, DDLs, task breakdowns), code-gen executes "how to do it" (generates actual code). The interface IDs (API-XX) and task IDs (T-XX) in tech-design are the direct index for code-gen
  • Relationship with coding-knowledge: coding-knowledge is code-gen's "coding mentor"—
    • symbols.md tells you what classes and methods exist in the project and where to find same-type references
    • architecture.md tells you which package new code goes into and what layering to follow
    • database-schema.md tells you what style to use for table creation
    • call-chains.md tells you how to write cross-service calls
    • infra/code-quality.md tells you what conventions you must follow
    • Code can still be generated without coding-knowledge, but the quality degrades from "written by a senior" to "written by an intern"

Modifying Existing Code vs. Adding New Features

The AI automatically determines whether each file is a "modification of existing code" or a "new file" based on the change scopes in tech-design, and employs different generation strategies.

Golden Rule When Modifying Existing Code

Only change what needs to be changed; do not touch what shouldn't be moved. This is the most common and most serious problem in modifying existing code—the AI reads existing code, then "conveniently" refactors surrounding logic, introducing regression bugs.

Specific Requirements:

  • First Read the complete existing file, understand the context before taking action
  • Use Edit for precise modification, do not use Write to overwrite the entire file
  • Do not rename existing variables/methods, even if the naming seems suboptimal—that's another requirement
  • Do not adjust the formatting of existing code (indentation, blank lines, import order), unless it is directly adjacent to your new code
  • Do not "optimize" existing logic—if tech-design says "add a validation in the createOrder method," only add the validation; do not modify other logic in createOrder
  • Consider insertion position for new methods: Insert in a reasonable position based on the project's existing method arrangement habits (e.g., CRUD order, public before private)

Judging Criteria

SignalJudgmentGeneration Strategy
tech-design marks "Modify: XxxService:L120"Modify existing codeRead → Edit precise modification
tech-design marks "New: {Package Path}/XxxController.java"New fileWrite complete file
tech-design marks "New method createXxx()"Add within existing fileRead → Edit, insert at appropriate position

Generation Principles

Style consistency is the top priority: Generated code must look like a natural extension of the existing project code. The approach is not "read the conventions and then go by feeling," but:

  1. From symbols.md, find existing implementation files of the same type
  2. Read the complete source code to extract coding patterns
  3. New code strictly replicates these patterns—the same annotation combinations, the same method naming, the same exception handling approach

tech-design is the authoritative source: API paths, parameter names, response structures, and error codes follow tech-design; do not improvise. If you think tech-design has issues (e.g., unreasonable parameter types), annotate them in the report's "Notes" section, but still generate the code according to tech-design.

coding-knowledge is the coding mentor: When faced with the question "how should this be written here?", the first reaction is to check coding-knowledge, not to guess based on general knowledge. For example:

  • "How is pagination implemented in this project?" → Check pagination-related methods in symbols.md
  • "What method is used for cross-service calls?" → Check call-chains.md
  • "How are exceptions thrown?" → Check code-quality.md and the implementation of reference Services

Do not break existing code: When modifying existing files, only add/modify code at necessary locations; do not reformat or refactor surrounding code. Use the Edit tool for precise modification; do not use Write to overwrite the entire file.

Business logic must be complete: Do not just generate method signatures and TODO comments; generate code with complete business logic. Derive validation rules from PRD acceptance criteria, and derive processing flows from tech-design sequence diagrams.

Generate in batches and write promptly: Follow Phase 2's order to generate files one by one, writing each file immediately after generation. Do not batch and output at the end—if an error occurs midway, the files already written are unaffected.

Common Pitfalls

Skipping style learning and generating directly: Not reading an existing Controller in the project before generating a new one, resulting in completely different annotation combinations and return value wrappers. Style learning in Phase 0.4 cannot be omitted.

Only looking at symbols.md without reading the source code: symbols.md only has signature indexes; it cannot show the coding patterns within method bodies (how transactions are used, how exceptions are thrown, how logs are printed). You must Read the complete source code of 2-3 reference files.

Interface parameters inconsistent with tech-design: tech-design specifies knowledgeType, but the code uses knowledge_type or type. Parameter names must strictly follow tech-design.

Missing modification files: tech-design says to modify 3 files, but code-gen only modifies 2. The plan checklist in Phase 1 must completely cover the change scopes in tech-design.

Frontend code not referencing the prototype: The page structure in prototype/ is the visual expression of the PRD. Frontend code should reference the layout and component structure of the prototype, rather than redesigning the page from scratch.

Only generating signatures without implementations: The generated Service method bodies are full of // TODO: implement. The value of this skill lies in generating complete business logic implementations, not leaving blanks for the developer to fill in.

"Convenient" refactoring when modifying existing code: When modifying an existing method, only add the required logic; do not rename variables, adjust code formatting, or optimize surrounding logic. These "improvements" are the main source of regression bugs.

Duplicating existing logic when modifying existing code: tech-design says "add a new validation step in the existing flow," but code-gen rewrites the entire process (including existing logic). Only incremental code should be written; existing logic must remain unchanged.

Ignoring the "not responsible" annotations in coding-knowledge: architecture.md states "this service is not responsible for XXX," but the code includes that logic. Check the service's responsibility boundaries before generating code.

Inconsistent cross-service invocation methods: The existing project code uses Feign Client to call other services, but the generated code uses RestTemplate. You must learn the actual invocation method from call-chains.md or reference code.

相关技能