본문으로 건너뛰기
cccskills
무료GitHub에 공개

code-simplifier

Simplify Rust code in RTK by replacing verbose loops, unnecessary copies, and excessive abstractions with common Rust patterns. Preserve behavior and project requirements, including error context, fallback handling, exit codes, and existing test modules.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Review RTK Rust code for idiomatic simplification. Detects over-engineering, unnecessary allocations, verbose patterns. Applies Rust idioms without changing behavior.

설치 방법 보기

이럴 때 유용합니다

  • Simplifying verbose loops and string construction
  • Removing unnecessary string copies
  • Reducing nested conditional and error handling code
  • Refactoring while preserving RTK requirements

포함된 파일(1)

  • SKILL.md4.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

RTK Code Simplifier

Review and simplify Rust code in RTK while respecting the project's constraints.

Constraints (never simplify away)

  • LazyLock regex — cannot be moved inside functions even if "simpler"
  • .context() on every ? — verbose but mandatory
  • Fallback to raw command — never remove even if it looks like dead code
  • Exit code propagation — never simplify to Ok(())
  • #[cfg(test)] mod tests — never remove test modules

Simplification Patterns

1. Iterator chains over manual loops

// ❌ Verbose
let mut result = Vec::new();
for line in input.lines() {
    let trimmed = line.trim();
    if !trimmed.is_empty() && trimmed.starts_with("error") {
        result.push(trimmed.to_string());
    }
}

// ✅ Idiomatic
let result: Vec<String> = input.lines()
    .map(|l| l.trim())
    .filter(|l| !l.is_empty() && l.starts_with("error"))
    .map(str::to_string)
    .collect();

2. String building

// ❌ Verbose push loop
let mut out = String::new();
for (i, line) in lines.iter().enumerate() {
    out.push_str(line);
    if i < lines.len() - 1 {
        out.push('\n');
    }
}

// ✅ join
let out = lines.join("\n");

3. Option/Result chaining

// ❌ Nested match
let result = match maybe_value {
    Some(v) => match transform(v) {
        Ok(r) => r,
        Err(_) => default,
    },
    None => default,
};

// ✅ Chained
let result = maybe_value
    .and_then(|v| transform(v).ok())
    .unwrap_or(default);

4. Struct destructuring

// ❌ Repeated field access
fn process(args: &MyArgs) -> String {
    format!("{} {}", args.command, args.subcommand)
}

// ✅ Destructure
fn process(&MyArgs { ref command, ref subcommand, .. }: &MyArgs) -> String {
    format!("{} {}", command, subcommand)
}

5. Early returns over nesting

// ❌ Deeply nested
fn filter(input: &str) -> Option<String> {
    if !input.is_empty() {
        if let Some(line) = input.lines().next() {
            if line.starts_with("error") {
                return Some(line.to_string());
            }
        }
    }
    None
}

// ✅ Early return
fn filter(input: &str) -> Option<String> {
    if input.is_empty() { return None; }
    let line = input.lines().next()?;
    if !line.starts_with("error") { return None; }
    Some(line.to_string())
}

6. Avoid redundant clones

// ❌ Unnecessary clone
fn filter_output(input: &str) -> String {
    let s = input.to_string();  // Pointless clone
    s.lines().filter(|l| !l.is_empty()).collect::<Vec<_>>().join("\n")
}

// ✅ Work with &str
fn filter_output(input: &str) -> String {
    input.lines().filter(|l| !l.is_empty()).collect::<Vec<_>>().join("\n")
}

7. Use if let for single-variant match

// ❌ Full match for one variant
match output {
    Ok(s) => process(&s),
    Err(_) => {},
}

// ✅ if let (but still handle errors in RTK — don't silently drop)
if let Ok(s) = output {
    process(&s);
}
// Note: in RTK filters, always handle Err with eprintln! + fallback

RTK-Specific Checks

Run these after simplification:

# Verify no regressions
cargo fmt --all && cargo clippy --all-targets && cargo test

# Verify no new regex in functions
grep -n "Regex::new" src/<file>.rs
# Fixed, reused patterns should be in `LazyLock<Regex>` statics

# Verify no new unwrap in production
grep -n "\.unwrap()" src/<file>.rs
# Should only appear inside #[cfg(test)] blocks

What NOT to Simplify

  • static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(...).unwrap()); — the .unwrap() here is acceptable, it's init-time
  • .context("description")? chains — verbose but required
  • The fallback match arm Err(e) => { eprintln!(...); raw_output } — looks redundant but is the safety net
  • std::process::exit(code) at end of run() — looks like it could be Ok(())but it isn't

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Choose Rust design patterns for RTK modules that process command output. Use concrete examples to structure configuration, prevent type mixups, manage parser states, and select abstractions suited to the task without adding unnecessary architectural complexity.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Planning the structure of a new command output filter
  • Preventing mixups between values with the same underlying type
  • Organizing configuration with many optional fields
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

Organize open GitHub issues by category, risk, linked pull requests, duplicate candidates, and inactivity. Optionally analyze selected issues in depth, draft responses, and apply approved comments, labels, or closures to keep the backlog actionable.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Sorting a growing backlog of open issues
  • Checking whether suspected duplicate issues are truly duplicates
  • Prioritizing security risks and breaking changes
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

pr-triage

무료

Sort open GitHub pull requests by change size, automated check results, conflicts, and inactivity. Review selected changes in detail, draft constructive feedback, and post comments after the user approves them.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Prioritizing a backlog of open pull requests
  • Finding overlapping changes and failing checks
  • Reviewing selected pull requests in detail
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

rtk-tdd

무료

Guide Rust development through test-driven development: write a failing test, implement enough code to pass, then refactor. Includes practical test patterns and final checks for formatting, static analysis, and test results.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding Rust features with tests first
  • Reproducing bugs with failing tests before fixing them
  • Testing invalid inputs and error paths
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

Review GitHub issues and pull requests together to find duplicate work, security findings without fixes, and critical bugs without linked changes. Produce action tables and a dated report to support backlog reviews and sprint planning.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Reviewing issues and pull requests before a sprint
  • Finding pull requests that duplicate the same work
  • Identifying security findings without proposed fixes
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

tdd-rust

무료

Develop Rust filters for RTK through tests written before implementation. Use real command output as test inputs, check output snapshots and unexpected inputs, verify a minimum reduction target, and complete formatting, linting, and test checks before finishing.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding a new RTK command filter
  • Checking filtered output against saved snapshots
  • Testing empty, malformed, or ANSI-colored input
rtk-ai/rtk8.4만2026년 10월 19일 업데이트

rtk-ai의 스킬 모두 보기

이 스킬의 문제 신고