Xpersona
T

Tvs Clean Code

CLAWHUB · Unverified

代码清洁与整理,并添加增强用户理解的注释,让代码意图清晰、自解释,大幅降低阅读和维护的认知成本。 Skill: Tvs Clean Code Owner: inksnowhailong Summary: 代码清洁与整理,并添加增强用户理解的注释,让代码意图清晰、自解释,大幅降低阅读和维护的认知成本。 Tags: latest:1.0.1 Version history: v1.0.1 | 2026-05-18T07:13:04.365Z | user Update local tvs skills v1.0.0 | 2026-03-26T06:29:21.058Z | user tv-clean-code 1.0.0 初始版本发布 - 提供代码清洁与整理规范,聚焦降低阅读和维护的认知成本 - 明确四大最高优先级原则,包括减少冗余、集中业务逻辑、优化命名与补充关键注释 - 提出结构优化建议(如函数分拆、魔法值提取、早返回等) - 包含输出格式建议,便于用户清晰了解代码清理的改动 - 主动引导用户指定待清理的代码范围 Archi

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s177pqccte7rb6prtwj4ad2bpx83nmt8:tvs-clean-code
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-inksnowhailong-tvs-clean-code/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

5,722 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: tvs-clean-code
description: 代码清洁与整理,并添加增强用户理解的注释,让代码意图清晰、自解释,大幅降低阅读和维护的认知成本。
---

# 代码清洁与整理指南

核心目标:
让代码**意图清晰、自解释**,大幅降低阅读和维护的认知成本。
主动询问,若用户未指定要清理哪些代码,就要主动询问要清理的代码的文件路径,或者某些模块,某些目录。

## 优先级最高的清理原则(先做这些,收益最大)

1. **去除无意义的包装层和冗余代码**(最常见、最高优先级)
   - 多余的单行箭头函数 / 简单 setter 包装
   - 只用一次且名字没增加信息的中间变量
   - 不必要的解构 + 重新组装对象
   - 能用可选链 `?.` / `??` 解决的复杂条件判断

2. **禁止把核心业务逻辑分散到副作用钩子中**
   - 坏:`handleSubmit() → 改状态 → watch 监听到状态 → 执行保存`
   - 好:`async handleSubmit() { 设置状态 → await 保存 → 更新状态 }`
   - 原则:能写成顺序代码的,尽量不要拆成「动作 + 监听」

3. **命名必须表达意图而非实现细节**
   - 差:`handleData`、`changeStatus`、`doSubmit`
   - 好:`submitFormAndNotifyTeam`、`toggleFavorite`、`formatPriceWithCurrency`
4. **必须补充关键注释**
  至少要注释:
  - 所有的响应式变量,函数,特别是核心业务函数
  - 复杂的业务规则 / 计算逻辑
  - 重要分支的「为什么」
  - 边界情况 / 特殊处理的原因
  - 难以从名字一眼看出的副作用

## 重要但次优先的改进点

- **结构与现代风格调整**
  - 函数过长(>30–40行)→ 拆成单一职责小函数
  - 魔法值 → 抽取为命名常量(优先用 const enum / as const)
  - 嵌套过深(>3层)→ 优先使用早返回(guard clause)
  - 重复逻辑 → 抽取为 composable / util / shared hook

- **顺序与分组规范**
  - 推荐顺序(从上到下):
    1. import(分组:第三方 → @/别名 → ./相对路径)
    2. 类型 / 接口 / const enum
    3. 常量 / 配置
    4. ref / reactive / 计算属性(数据)
    5. 核心业务函数(按调用频率或重要性排序)
    6. 事件处理函数(handleXxx)
    7. 生命周期钩子 / watch / onMounted 等副作用(尽量少)

## 输出格式建议(给用户看改动时使用)

```diff
改动概要(用中文,简洁有力)
示例:
  - 删除了 4 处无意义单行函数包装
  - 合并了分散在 watch 中的保存逻辑到 handleSubmit
  - 优化命名:handleData → refreshAndNotify
  - 减少临时变量 5 个,代码行数减少约 18%
  - 核心业务逻辑增加 3 处「为什么」注释

_meta.json

{
  "ownerId": "kn780m7k958b5gw8krjjp3x3zd832r21",
  "slug": "tvs-clean-code",
  "version": "1.0.1",
  "publishedAt": 1779088384365
}

skill-card.md

## Description:

Tvs Clean Code guides an agent to refactor code for clearer intent, simpler structure, better naming, and explanatory comments.

This skill is ready for commercial/non-commercial use.

## Publisher:

[inksnowhailong](https://clawhub.ai/user/inksnowhailong)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to have an agent clean and organize code, reduce redundant wrappers and temporary variables, improve naming and structure, and add targeted comments that explain important intent and edge cases.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Refactoring guidance can change behavior if applied without review.

Mitigation: Review proposed code changes and run the project's normal tests before deployment.

Risk: The skill may steer the agent toward adding comments and simplifying code even when the requested scope is unclear.

Mitigation: Specify the target files, modules, or directories and review comments for accuracy and necessity.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/inksnowhailong/skills/tvs-clean-code)

## Skill Output:

**Output Type(s):** [Code, Markdown, Guidance]

**Output Format:** [Markdown summaries with code edits or refactoring guidance]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [The skill is guidance-only and has no executable code, persistence, credential access, or hidden behavior.]

## Skill Version(s):

1.0.1 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Tvs Clean Code and adjacent AI workflows.