AgentSkillsCN

codestyle

当用户提出“生成代码模板”、“创建 CRUD”、“生成脚手架”、“代码生成器”、“生成控制器”、“生成服务”、“生成实体”、“使用模板生成代码”,或需要代码模板的检索与生成时,应使用此技能。通过基于 JAR 的 CLI 提供代码模板搜索与内容检索功能。

SKILL.md
--- frontmatter
name: codestyle
description: This skill should be used when the user asks to "generate code template", "create CRUD", "generate scaffold", "code generator", "generate controller", "generate service", "generate entity", "use template to generate code", or needs code template retrieval and generation. Provides code template search and content retrieval via jar-based CLI.

Codestyle

Code template retrieval and generation via jar-based CLI tool.

Skill Location

Jar file: scripts/codestyle-server.jar (relative to this SKILL.md)

Installation paths:

  • Personal: ~/.claude/skills/codestyle/scripts/codestyle-server.jar
  • Project: .claude/skills/codestyle/scripts/codestyle-server.jar
  • Plugin: <plugin-path>/skills/codestyle/scripts/codestyle-server.jar

Workflow

  1. Initialize project config (REQUIRED): You MUST create .codestyle/cfg.json in the current working directory (project root) before executing any search or get command:
    bash
    mkdir -p .codestyle && cat > .codestyle/cfg.json << 'EOF'
    {
      "repository": {
        "repository-dir": "cache",
        "remote-path": "https://api.codestyle.top",
        "remote-search-enabled": false,
        "remote-search-timeout-ms": 5000,
        "api-key": ""
      }
    }
    EOF
    
  2. Locate skill directory (where this SKILL.md is located)
  3. Execute search "keyword" based on user requirements
  4. Parse returned directory tree, select matching template path
  5. Execute get "full-path" to retrieve template content
  6. List variables, request user confirmation, generate code

Commands

Replace <SKILL_DIR> with actual skill installation path.

Search templates:

bash
java -jar <SKILL_DIR>/scripts/codestyle-server.jar search "keyword"

Get template content:

bash
java -jar <SKILL_DIR>/scripts/codestyle-server.jar get "path"

Search Keyword Formats

FormatDescriptionExample
KeywordFull-text searchCRUD, login, export
groupId/artifactIdExact matchcontinew/crud-plus
MixedCombined searchuser CRUD

Result Types

Single result: Returns directory tree directly. Select path and execute get.

Multiple results: Returns matching list. Ask user to choose or use groupId/artifactId for exact search.

No result: Not found locally. Suggest synonyms or enable remote search (remote-search-enabled: true).

Path Format

Template path: groupId/artifactId/version/filePath/filename.ftl

Example: continew/crud-plus/1.0.0/src/main/java/controller/Controller.ftl

Configuration

Config loading order (later overrides former):

  1. jar-directory/cfg.json (global)
  2. current-working-directory/.codestyle/cfg.json (project)

Reference Files

FilePurpose
references/config.mdConfiguration options
references/template-syntax.mdOutput format parsing & variable handling