Topview Logo
  • Create viral videos with
    GPT-4o + Ads library
    Use GPT-4o to edit video empowered by Youtube & Tiktok & Facebook ads library. Turns your links or media assets into viral videos in one click.
    Try it free
    gpt video

    SECRET SAUCE of AI Coding? AI Devlog with Aider, Cursor, Bun and Notion

    blog thumbnail

    Introduction

    Hello, engineers! Indie Dev Dan here with an action-packed AI coding dev log. In this session, I will share insights and techniques while demonstrating how to leverage two of the best AI coding assistants: Aider and Cursor. We'll work with a new Bun code base, focusing on how these tools can help us ship more code in less time. I'll also reveal the secret sauce of AI coding—something you might not expect, but that can greatly enhance your productivity in both speed and quality.

    Setting Up Aider

    Let's kick things off by configuring Aider, which has a YAML file for extensive customization. Currently, I'm enabling Sonat 3.5 prompt caching and disabling auto commits—since I prefer manual commits. Next, I’m setting up a test command and an auto-test flag, which hint at our secret sauce, but more on that later.

    Another exciting feature in Aider is the option to specify read-on files, ensuring they are excluded from updates during prompting. I’m adding the README and a conventions file, which outlines rules for how I’d like Aider to write code. This conventions file can be updated based on the specific code base, allowing for versatility across projects.

    As I structure the codebase, I’m creating modules, tests, and a types file. I'm very curious to know how you handle your TypeScript types. Do you keep them in a single file or spread them across individual components? For me, having a single types file on the top-level has been advantageous for easy searching and access by AI models.

    After fixing a minor error in the Aider configuration file, we reboot Aider to see the changes take effect. Everything is running smoothly now!

    Building a Notion API Wrapper

    We're actually developing a Notion API wrapper class. Our product requires CRUD operations on Notion pages. I start by asking Aider to add a main function to our index.ts, which is vital for kicking off our application’s flow. Here, Aider's auto-test flag runs bun test after the prompt, which is a huge win.

    Next, I'm creating an additional module for our Notion logic, which will house the wrapper class. After some simple prompts, we have a working Notion wrapper designed for reuse throughout our application.

    Now, it's time to set up our tests. We want to create a basic Bun test to validate our functionality. The test is successfully created, and Aider utilizes the auto-test feature to run the test automatically. This pattern, where we keep verifying our code with tests after every substantial change, is what I call the secret sauce of AI coding.

    As we go on, I ask Aider to move the Notion page ID to a new constants file, allowing it to be used in both tests and application logic. Aider suggests further code fixes, demonstrating the powerful collaborative effect of using AI tools in coding.

    Creating Additional Functionality

    We start working on the delete block command, reusing the AI coding prompt pattern for consistency. After obtaining feedback from Aider, I realize that we need to create corresponding tests for our new functionality—an essential step that further validates our updates.

    Now to focus on a crucial method: getting all Notion page blocks. This involves recursively obtaining the correct block type for nested blocks. I prompt Aider to create a new function across multiple files, and it correctly handles all necessary updates.

    After reviewing the latest changes, I spot some inconsistencies in our output concerning empty text blocks. I issue another prompt, and Aider implements recursive logic to extract all necessary components, significantly improving our error-handling capabilities.

    Wrapping Up with Documentation and CLI

    With our CRUD operations functional, I update the README to reflect our API wrapper's capabilities. Documentation is paramount, and spending time on this can save headaches later. As a best practice, it's crucial to think of your toolkit as adaptable. No single tool reigns supreme; instead, use different tools depending on your needs. This modular approach is critical when utilizing AI in coding.

    In concluding thoughts, in roughly 45 minutes, we've built a sophisticated Notion API wrapper complete with tests, documentation, and a delicious serving of AI coding secrets. Stay tuned for the next episode of our dev log where we'll further enhance our code base.


    Keywords

    • Aider
    • Cursor
    • AI coding assistants
    • Notion API wrapper
    • Bun
    • CRUD operations
    • TypeScript
    • Tests
    • Documentation

    FAQ

    Q: What tools are used in this AI coding session?
    A: The session utilizes Aider and Cursor as AI coding assistants alongside Bun and Notion for building the code base.

    Q: What is the primary functionality being developed?
    A: The main focus is to create a Notion API wrapper that supports CRUD operations on Notion pages.

    Q: How does the auto-test feature in Aider enhance productivity?
    A: The auto-test feature automatically runs tests after code changes, ensuring continuous validation of functionality, which accelerates development cycles.

    Q: Why is documentation important in AI coding?
    A: Comprehensive documentation saves time, aids in collaboration, and facilitates easier onboarding for future developers interacting with the codebase.

    Q: How should I choose AI coding tools?
    A: It's essential to test multiple tools and assess their strengths and weaknesses rather than relying on a single tool. This approach enhances versatility and adapts to varying project requirements.

    One more thing

    In addition to the incredible tools mentioned above, for those looking to elevate their video creation process even further, Topview.ai stands out as a revolutionary online AI video editor.

    TopView.ai provides two powerful tools to help you make ads video in one click.

    Materials to Video: you can upload your raw footage or pictures, TopView.ai will edit video based on media you uploaded for you.

    Link to Video: you can paste an E-Commerce product link, TopView.ai will generate a video for you.

    You may also like