Skip to content

Generate code snippets and usage examples for new features #3

@dividing-by-zaro

Description

@dividing-by-zaro

Overview

When new features are added to tracked repositories, use LLM to generate example code snippets showing how to use those features. This helps users quickly understand and adopt new functionality.

Goals

  • Reduce friction for users adopting new features from tracked repos
  • Provide practical, copy-paste-ready code examples
  • Make the feed more actionable, not just informational

Features

Usage Example Generation

  • For feature/enhancement updates, generate code showing:
    • Basic usage of the new API/function
    • Common use cases and patterns
    • Before/after comparisons (if applicable)
  • Examples should be:
    • Concise and focused
    • Syntactically correct for the repo's language
    • Include necessary imports/setup

Example Sources

  • Analyze the PR diff to understand the new API surface
  • Look for existing examples in:
    • PR description
    • Test files added/modified in the PR
    • README or docs changes in the PR
  • Generate examples when none exist in the PR

Feed Integration

  • Display code snippets in expandable section on UpdateCard
  • Syntax highlighting matching the repo's primary language
  • Copy-to-clipboard button
  • View full PR link for more context

Language Support

  • Detect repo's primary language from GitHub metadata
  • Support common languages: JavaScript/TypeScript, Python, Go, Rust, Java, Ruby
  • Fall back to generic pseudocode for unsupported languages

Quality Controls

  • Only generate examples for feature and enhancement categories
  • Skip for internal/patch changes
  • Include disclaimer: AI-generated example - verify before use
  • Allow users to flag/hide low-quality examples

Technical Considerations

  • Add new LLM prompt template for code generation
  • Store examples in GlobalUpdate table (new codeExample field)
  • Generate asynchronously during classification (do not block)
  • Consider token limits for large PRs
  • Cache examples (regenerate only on request)

Out of Scope (for now)

  • Interactive code playground
  • Multiple example variations
  • User-submitted/edited examples
  • Implementation explanations (how the feature was built)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions