code-writing

Enforce consistent coding standards for generation, refactoring, and modification tasks.

1|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/kitcaf/skills --skill code-writing-kitcaf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-writing
Source: https://github.com/kitcaf/skills/tree/main/skills/code-writing
Command: npx skills add https://github.com/kitcaf/skills --skill code-writing-kitcaf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

提供通用的软件工程代码编写规范。当在当前项目中生成、重构或修改任何业务代码(含脚本)时自动生效。该规范明确禁止硬编码与魔法数字、禁止吞咽异常、以及避免瑞士军刀式脚本等风险,并强调高内聚、低耦合、命名表意、必要注释、以及语言与框架的原生风格。

Core Features & Use Cases

  • 统一代码规范:确保生成、重构、修改代码时始终遵循同一组规则。
  • 质量与安全保障:覆盖防御性编程、资源管理、错误处理、命名与注释等方面,降低缺陷风险。
  • 适用场景示例:在大型业务项目中对新脚本进行快速合规审查,或对现有代码进行重构时保持一致性。

Quick Start

在需要生成、重构或修改任何业务代码时,严格遵循以上通用工程规范。

Frequently Asked Questions about code-writing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are defensive programming rules for code refactoring?

Defensive programming rules for code refactoring prohibit hardcoding, magic numbers, and swallowed exceptions. They enforce clear naming, error handling, and modularization to maintain high cohesion and low coupling across business logic.

How do I enforce coding standards when modifying business scripts?

To enforce coding standards when modifying business scripts, apply consistent rules that mandate necessary comments and language-specific conventions. This prevents risks like Swiss Army knife scripts and ensures uniform software engineering quality.

Can I use these naming conventions for any programming language?

Yes, these naming conventions apply to any programming language by adhering to native language and framework styles. The embedded standards enforce expressive naming while maintaining language-specific conventions across diverse projects.

What is the best way to avoid magic numbers in software engineering?

The best way to avoid magic numbers in software engineering is to enforce strict code writing standards that explicitly prohibit them. Replacing magic numbers with clearly named constants improves readability and reduces defect risks.

Why does high cohesion matter when generating new code?

High cohesion matters when generating new code because it ensures modules focus on a single responsibility, reducing coupling. This defensive programming practice lowers defect risks and maintains consistent project quality during refactoring.