.claude/skills/practical-development-validator/SKILL.md
务实开发原则检查和验证
npx skillsauth add shenjingnan/xiaozhi-client practical-development-validatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
我是务实开发原则检查技能,专门帮助开发团队避免过度设计,确保代码实现符合"如无必要勿增实体"的核心原则。
核心能力:识别代码中可能存在的过度设计和不必要的复杂性。
// ❌ 过度抽象
abstract class BaseService<T, U, V> {
abstract execute(request: T): Promise<U>;
abstract validate(request: T): V;
abstract handleError(error: Error): void;
}
// ✅ 简单直接
class UserService {
async createUser(userData: UserData): Promise<User> {
// 直接实现功能
}
}
评估代码变更的复杂度是否与其功能价值匹配。
// 复杂度检查清单
interface ComplexityChecklist {
// ✅ 合理的复杂度
hasClearPurpose: boolean; // 有明确的目的
solvesRealProblem: boolean; // 解决实际问题
necessaryAbstraction: boolean; // 必要的抽象
maintainableCode: boolean; // 可维护的代码
// ❌ 过度的复杂度
futureProofing: boolean; // 为未来过度设计
unnecessaryPatterns: boolean; // 不必要的设计模式
overConfiguration: boolean; // 过度配置
prematureOptimization: boolean; // 过早优化
}
验证代码实现的实用性,确保解决实际问题。
// ❌ 过度的错误处理
try {
const result = await apiCall();
if (result !== null && result !== undefined) {
if (typeof result === 'object' && result.data) {
// 过度嵌套的检查
}
}
} catch (error) {
if (error instanceof NetworkError) {
// 详细的错误分类
} else if (error instanceof ValidationError) {
// 详细的错误分类
}
// ...
}
// ✅ 实用的错误处理
try {
const result = await apiCall();
return result;
} catch (error) {
console.error('API调用失败:', error);
throw new Error('服务不可用');
}
确保架构设计有实际意义,避免不必要的抽象层。
请检查当前的代码变更,是否存在过度设计的问题?
请评估这个新功能的实现是否符合"如无必要勿增实体"的原则?
请检查当前的架构设计是否合理,是否存在不必要的抽象层?
请分析这段代码的复杂度,并提供简化建议。
// ✅ 推荐的简单设计
class ConfigManager {
private config: Config;
constructor(configPath: string) {
this.config = this.loadConfig(configPath);
}
get(key: string): any {
return this.config[key];
}
set(key: string, value: any): void {
this.config[key] = value;
}
}
// ❌ 避免的过度设计
abstract class ConfigurationProvider<T extends ConfigurationOptions> {
abstract getConfiguration(): Promise<Configuration<T>>;
abstract validateConfiguration(config: Configuration<T>): ValidationResult;
abstract transformConfiguration(config: Configuration<T>): TransformedConfiguration<T>;
}
class JSONConfigurationProvider<T extends JSONConfigurationOptions>
extends ConfigurationProvider<T> {
// 过度复杂的实现
}
通过这个技能的帮助,可以确保 xiaozhi-client 项目始终保持务实的设计理念,避免过度工程化,专注解决实际问题。
development
TypeScript严格模式检查
tools
Todo 管理技能,用于管理架构演进过程中的待办事项
testing
测试修复技能,用于分析和修复失败的测试用例
testing
测试创建技能,用于生成符合项目标准的测试用例