跳到正文
cccskills
免费在 GitHub 公开

cleanup

Review and improve code changes on the current branch using Pipecat conventions. Refine names and structure, add type hints and documentation, check example patterns, and make conservative performance improvements while preserving compatibility.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Review, refactor, document, and validate code changes in the current branch

查看安装方法

适用场景

  • Cleaning up branch changes before review
  • Adding missing type hints and documentation
  • Checking Pipecat service and example patterns
  • Finding conservative performance improvements

包含的文件(1)

  • SKILL.md7.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Code Cleanup Skill

The Code Cleanup Skill reviews, refactors, and documents code changes in your current branch, ensuring alignment with Pipecat's architecture, coding standards, and example patterns. It focuses on readability, correctness, performance, and consistency, while avoiding breaking changes.


Skill Overview

This skill analyzes all changes introduced in your branch and performs the following actions:

  1. Analyze Branch Changes
    • Review uncommitted changes and outgoing commits
  2. Refactor for Readability
    • Improve clarity, naming, structure, and modern Python usage
  3. Enhance Performance
    • Identify safe, conservative optimization opportunities
  4. Add Documentation
    • Apply Pipecat-style, Google-format docstrings
  5. Ensure Pattern Consistency
    • Match existing Pipecat services, pipelines, and examples
  6. Validate Examples
    • Ensure examples follow foundational patterns (e.g. 07-interruptible.py)

Usage

Invoke the skill using any of the following commands:

  • "Clean up my branch code"
  • "Refactor the changes in my branch"
  • "Review and improve my branch code"
  • /cleanup

What This Skill Does

1. Analyze Branch Changes

The skill retrieves all uncommitted changes and outgoing commits to understand:

  • New files added
  • Modified files
  • Code additions and deletions
  • Overall scope and intent of changes

2. Code Refactoring

Readability Improvements

  • Replace tuples with named classes or dataclasses
  • Improve variable, method, and class naming
  • Extract complex logic into well-named helper methods
  • Add missing type hints
  • Simplify nested or complex conditionals
  • Replace deprecated methods and features
  • Normalize formatting to match Pipecat style

Performance Enhancements

  • Identify inefficient loops or repeated work
  • Suggest appropriate data structures
  • Optimize async workflows and I/O
  • Remove redundant operations

Performance changes are conservative and non-breaking.


3. Documentation

Documentation follows Google-style docstrings, consistent with Pipecat conventions.

Class Documentation

class ExampleService:
    """Brief one-line description.

    Detailed explanation of the class purpose, responsibilities,
    and important behaviors.

    Supported features:

    - Feature 1
    - Feature 2
    - Feature 3
    """

Method Documentation

def process_data(self, data: str, options: Optional[dict] = None) -> bool:
    """Process incoming data with optional configuration.

    Args:
        data: The input data to process.
        options: Optional configuration dictionary.

    Returns:
        True if processing succeeded, False otherwise.

    Raises:
        ValueError: If data is empty or invalid.
    """

Pydantic Model Parameters

class InputParams(BaseModel):
    """Configuration parameters for the service.

    Parameters:
        timeout: Request timeout in seconds.
        retry_count: Number of retry attempts.
        enable_logging: Whether to enable debug logging.
    """

    timeout: Optional[float] = None
    retry_count: int = 3
    enable_logging: bool = False

4. Pattern Consistency Checks

Service Classes

  • Correct inheritance (TTSService, STTService, LLMService)
  • Consistent constructor signatures
  • Frame emission patterns
  • Metrics support:
    • can_generate_metrics()
    • TTFB and TTFA metrics
    • Usage metrics
  • Alignment with similar existing services

Examples

Validated against examples/07-interruptible.py:

  • Proper create_transport() usage
  • Correct pipeline structure
  • Task setup and observers
  • Event handler registration
  • Runner and bot entrypoint consistency

5. Specific Implementation Patterns

Service Implementation

class ExampleTTSService(TTSService):
    def __init__(self, *, api_key: Optional[str] = None, **kwargs):
        super().__init__(**kwargs)
        self._api_key = api_key or os.getenv("SERVICE_API_KEY")

    def can_generate_metrics(self) -> bool:
        return True

    async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:
        try:
            await self.start_ttfb_metrics()
            yield TTSStartedFrame()
            # ... processing ...
            frame = TTSAudioRawFrame(...)
            await self.process_ttfa_metrics(frame)
            yield frame
        finally:
            await self.stop_ttfb_metrics()

Example Structure Pattern

transport_params = {
    "daily": lambda: DailyParams(...),
    "twilio": lambda: FastAPIWebsocketParams(...),
    "webrtc": lambda: TransportParams(...),
}


async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
    stt = DeepgramSTTService(...)
    tts = SomeTTSService(...)
    llm = OpenAILLMService(...)

    context = LLMContext(messages)
    user_aggregator, assistant_aggregator = LLMContextAggregatorPair(...)

    pipeline = Pipeline([...])
    worker = PipelineWorker(pipeline, params=..., observers=[...])

    runner = WorkerRunner(handle_sigint=runner_args.handle_sigint)

    await runner.add_workers(worker)

    @transport.event_handler("on_client_connected")
    async def on_client_connected(transport, client):
        await worker.queue_frames([LLMRunFrame()])

    @transport.event_handler("on_client_disconnected")
    async def on_client_disconnected(transport, client):
        await runner.cancel()

    await runner.run()


async def bot(runner_args: RunnerArguments):
    """Main bot entry point compatible with Pipecat Cloud."""
    transport = await create_transport(runner_args, transport_params)
    await run_bot(transport, runner_args)

Execution Flow

  1. Fetch uncommitted and outgoing changes
  2. Categorize files (services, examples, tests, utilities)
  3. Analyze each file:
    • Readability
    • Performance
    • Documentation
    • Pattern consistency
  4. Generate actionable recommendations
  5. Apply Pipecat standards
  6. Run /prose-review branch over the comments and docstrings written above, and fix anything it flags

Examples

Before: Tuple Usage

def get_audio_info(self) -> Tuple[int, int]:
    return (48000, 1)

After: Named Class

class AudioInfo:
    """Audio configuration information.

    Parameters:
        sample_rate: Sample rate in Hz.
        num_channels: Number of audio channels.
    """

    sample_rate: int
    num_channels: int


def get_audio_info(self) -> AudioInfo:
    return AudioInfo(sample_rate=48000, num_channels=1)

Before: Missing Documentation

class NewTTSService(TTSService):
    def __init__(self, api_key: str, voice: str):
        self._api_key = api_key
        self._voice = voice

After: Fully Documented

class NewTTSService(TTSService):
    """Text-to-speech service using NewProvider API.

    Streams PCM audio and emits TTSAudioRawFrame frames compatible
    with Pipecat transports.

    Supported features:
    - Text-to-speech synthesis
    - Streaming PCM audio
    - Voice customization
    - TTFB and TTFA metrics
    """

    def __init__(self, *, api_key: str, voice: str, **kwargs):
        """Initialize the NewTTSService.

        Args:
            api_key: API key for authentication.
            voice: Voice identifier to use.
            **kwargs: Additional arguments passed to the parent service.
        """
        super().__init__(**kwargs)
        self._api_key = api_key
        self.set_voice(voice)

Notes

  • Non-breaking improvements only
  • Backward compatibility preserved
  • Conservative performance changes
  • Google-style docstrings
  • Pattern checks follow recent Pipecat code

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

changelog

免费

Create changelog files for significant changes in a pull request, a proposed code change. Describe effects users will notice and organize entries by PR number and change type, such as features or fixes.

中文简介正在准备中。当前显示英语简介。

  • Writing changelog entries for a pull request
  • Separating new features from bug fixes
  • Explaining changes in user-facing language
pipecat-ai/pipecat1.7万2026年10月20日 更新

Review GitHub pull requests with specialized agents that check for clear bugs and violations of project instructions in CLAUDE.md. Validate bug findings before posting focused comments on the affected lines, with fix suggestions where appropriate.

中文简介正在准备中。当前显示英语简介。

  • Reviewing a pull request for clear bugs
  • Checking changes against CLAUDE.md rules
  • Posting validated findings on affected lines
pipecat-ai/pipecat1.7万2026年10月20日 更新

docstring

免费

Add or improve Google-style docstrings, the explanations embedded in Python code, for modules and classes. Document constructor arguments, public methods, configuration fields, and enum values while preserving existing documentation that already meets the project’s conventions.

中文简介正在准备中。当前显示英语简介。

  • Document a Python module
  • Explain constructor arguments and public methods
  • Describe configuration fields and enum values
pipecat-ai/pipecat1.7万2026年10月20日 更新

Draft or update GitHub pull request descriptions using the actual changes and related context. Explain the problem, changed behavior, and review concerns in plain language, including breaking changes and explicit issue-closing references when applicable.

中文简介正在准备中。当前显示英语简介。

  • Draft a description for a new pull request
  • Rewrite a description to reflect the final implementation
  • Explain behavior changes and review concerns
pipecat-ai/pipecat1.7万2026年10月20日 更新

pr-submit

免费

Submit current work as a GitHub pull request, handling relevant uncommitted changes and reviewing prose before pushing. After creating the PR, run companion skills to generate changelog files, update the description, and return its URL.

中文简介正在准备中。当前显示英语简介。

  • Submitting current work as a GitHub pull request
  • Creating a branch and commits for uncommitted changes
  • Reviewing prose and adding a changelog before handoff
pipecat-ai/pipecat1.7万2026年10月20日 更新

Review newly added comments, docstrings, and changelog entries so future readers can understand the current code. Revise development history, redundant explanations, and unclear shorthand while preserving constraints that the code cannot explain on its own.

中文简介正在准备中。当前显示英语简介。

  • Review comments before committing
  • Check prose added across a branch
  • Clarify function documentation for future readers
pipecat-ai/pipecat1.7万2026年10月20日 更新

查看 pipecat-ai 的全部技能

报告此技能的问题