Code2Prompt - Convert Codebase into LLM Prompt - Install Locally



AI Nuggets

Installation and Usage of code to prompt CLI Tool

Installation of Rust and code to prompt

  1. Install Rust:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  
    • Follow the prompts for the default installation.
    • After installation, either restart your shell or source the environment file to update your path.
  2. Check Rust version:

    rustc --version  
  3. Install code to prompt using Cargo:

    cargo install code_to_prompt  

Using code to prompt

  1. Create a simple git repository for demonstration.

  2. Generate a prompt from your code base:

    code_to_prompt <project_path>  
    • The prompt is automatically copied to the clipboard and can be pasted into a text file or any desired location.
  3. To use custom templates from the code to prompt GitHub repository:

    • Clone the repository (URL provided in the video description).
    • Use the -t flag to specify a template:
      code_to_prompt -t <template_path> <project_path>  

Features and Tips

  • Converts code base into a single LLM prompt.
  • Respects .gitignore files.
  • Can filter and exclude files using glob patterns.
  • Displays the token count of generated prompts.
  • Optionally includes git diff output in the generated prompt.
  • Saves the generated prompt to an output file.
  • Can exclude files and folders by name or path.
  • Adds line numbers to source code blocks.
  • Customizable prompt template.
  • Templates for documentation, finding security vulnerabilities, and bugs are available in the GitHub repository.

Additional Information

  • The video is sponsored by MK compute, which offers GPU rentals at affordable prices.
  • A coupon code for a 50% discount on already discounted offerings is mentioned (the code itself is not provided in the transcript).
  • The presenter is using an NVIDIA RTX A6000 with 48 GB of VRAM for the demonstration.

GitHub Repository and GPU Rental

  • GitHub Repository: The link is provided in the video’s description.
  • MK compute Website: The link is provided in the video’s description for GPU rental services.

Recommendations

  • Instead of using Cargo to install the latest version, consider cloning the GitHub repo and building from there to get the latest, less buggy release:
    git clone <repo_url>  
    cd <cloned_repo_directory>  
    cargo build --release  

Conclusion

  • The presenter finds code to prompt to be a useful tool for documentation and code analysis.
  • Encourages viewers to subscribe to the channel and share the content.

(Note: The exact URLs for the GitHub repository and MK compute website are not provided in the transcript and should be obtained from the video’s description as mentioned.)