CtrlK
BlogDocsLog inGet started
Tessl Logo

code-simplifier

Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.

72

1.00x
Quality

57%

Does it follow best practices?

Impact

100%

1.00x

Average score across 3 eval scenarios

SecuritybySnyk

Passed

No known issues

Optimize this skill with Tessl

npx tessl skill review --optimize ./plugins/code-simplifier/skills/code-simplifier/SKILL.md
SKILL.md
Quality
Evals
Security

Code Simplifier

Expert code simplification focused on clarity, consistency, and maintainability while preserving exact functionality. Prioritizes readable, explicit code over overly compact solutions.

Core Principles

1. Preserve Functionality

Never change what the code does — only how it does it. All original features, outputs, and behaviors must remain intact.

2. Apply Project Standards

Follow established coding standards from the project's CLAUDE.md or equivalent, including:

  • Proper import sorting and module conventions
  • Preferred function declaration style (e.g., function keyword over arrow functions)
  • Explicit return type annotations for top-level functions
  • Proper component patterns with explicit Props types
  • Proper error handling patterns (avoid try/catch when possible)
  • Consistent naming conventions
  • File naming conventions (e.g., snake_case)

3. Enhance Clarity

  • Reduce unnecessary complexity and nesting
  • Eliminate redundant code and abstractions
  • Use clear, descriptive variable and function names
  • Consolidate related logic
  • Remove comments that describe obvious code
  • Avoid nested ternary operators — prefer switch statements or if/else chains for multiple conditions
  • Choose clarity over brevity — explicit code is better than dense one-liners

4. Maintain Balance — Do Not Over-Simplify

Avoid:

  • Overly clever solutions that are hard to understand
  • Combining too many concerns into single functions or components
  • Removing helpful abstractions that improve organization
  • Prioritizing "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
  • Making code harder to debug or extend

Refinement Process

  1. Identify recently modified code sections (check git diff, session edit history, or open files)
  2. Analyze for opportunities to improve clarity and consistency
  3. Apply project-specific best practices and coding standards
  4. Verify all functionality remains unchanged
  5. Confirm the refined code is simpler and more maintainable

Scope

  • Default: Only refine code that has been recently modified or touched in the current session
  • Expanded: Refine broader scope only when explicitly instructed

Workflow

When invoked (either explicitly or proactively after code changes):

  1. Read the project's CLAUDE.md (or equivalent) for project-specific standards
  2. Identify recently changed files via git status/diff or session context
  3. Read and analyze the changed code
  4. Apply refinements following the core principles above
  5. Run the project's linter (make check-style-fix or equivalent) to verify standards compliance
  6. Run relevant tests to confirm functionality is preserved
  7. Summarize significant changes made

Examples

Reducing Nesting

Before:

func process(items []Item) error {
    if len(items) > 0 {
        for _, item := range items {
            if item.IsValid() {
                if err := item.Save(); err != nil {
                    return err
                }
            }
        }
    }
    return nil
}

After:

func process(items []Item) error {
    for _, item := range items {
        if !item.IsValid() {
            continue
        }
        if err := item.Save(); err != nil {
            return err
        }
    }
    return nil
}

Avoiding Nested Ternaries

Before:

const label = status === 'active' ? 'Active' : status === 'pending' ? 'Pending' : status === 'error' ? 'Error' : 'Unknown';

After:

function getStatusLabel(status: string): string {
    switch (status) {
        case 'active':
            return 'Active';
        case 'pending':
            return 'Pending';
        case 'error':
            return 'Error';
        default:
            return 'Unknown';
    }
}

Consolidating Related Logic

Before:

func handleRequest(r *Request) (*Response, error) {
    userID := r.GetUserID()
    if userID == "" {
        return nil, errors.New("missing user ID")
    }

    channelID := r.GetChannelID()
    if channelID == "" {
        return nil, errors.New("missing channel ID")
    }

    teamID := r.GetTeamID()
    if teamID == "" {
        return nil, errors.New("missing team ID")
    }

    // ... rest of handler
}

After:

func handleRequest(r *Request) (*Response, error) {
    if err := validateRequiredFields(r); err != nil {
        return nil, err
    }

    // ... rest of handler
}

func validateRequiredFields(r *Request) error {
    required := map[string]string{
        "user ID":    r.GetUserID(),
        "channel ID": r.GetChannelID(),
        "team ID":    r.GetTeamID(),
    }
    for name, value := range required {
        if value == "" {
            return fmt.Errorf("missing %s", name)
        }
    }
    return nil
}
Repository
mattermost/mattermost-ai-marketplace
Last updated
Created

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.