UE-DOO

AI Development Tricks

MAGIC

Awkward 

Teenager

AI makes me feel a little like an

But we'll 

figure it out

Hello AI

  • AI is a co-pilot, not a developer
  • It                   your productivity
     
  • It can also                your productivity
  • Don't believe everything you hear on social media

(when used responsibly)

destroy

will boost

Why AI?

  • produce code more quickly
  • surface solutions you never even thought about
  • help you think at a higher business needs level

A Case Study

Text Book Exam Generator

A Case Study

Text Book Exam Generator

Using AI

to Write Code

Write

Download Cursor

First things first

Download Cursor

First things first

Inline AI Auto Completion

  • just press tab
  • context aware

Download Cursor

First things first

AI Chat

  • ask it questions
  • context aware

Download Cursor

First things first

Composer

  • Generates code in multiple files
  • Runs commands
  • Easily manage/revert with git
  • Writes files to system before accepting changes so you can preview output
  • Great for generating components, tests, or even full features

(let's give it a try)

Generate a Component

Generate a

Component

Generate a Component Tips:

  • Be specific about what you want
  • Use .cursorrules to specify preferences and steer LLM away from common mistakes
  • Don't expect a perfect working solution

My .cursorrules for components

## Vue Component Coding Patterns and Rules

This section describes some patterns to follow when creating new or updating existing Vue components.

- Shad-cn Vue is installed and can be used to generate most common UI elements. Only create a new custom component is shad-cn doesn't already have a solution.
- Shad-cn Vue components can be installed with a bash command like so: npx shadcn-vue@latest add button [or any other component]
- NEVER try to generate a ShadCN component, rather always prompt me to install it when needed
- Do NOT create long components with a lot of responsibilities. Instead, break components down into smaller, more focused components
- make most components "dumb" components. These focus on:
  - presentation
  - simple logic
  - Dumb components should include the keyword `Dumb` before the file suffix like this: `UserProfileCardDumb.vue`
- Limit "smart" components that make requests to API endpoints to only what's absolutely necessary
- break complex logic into composables or utility functions
- Always use TypeScript to define all components.
- Use Typescript to define component props and emits.
- use JS docs to document component props and emits
- Use script setup
- Provide the component sections in the following order:
  - script
  - template
  - style
- Use the built in Nuxt $fetch function instead of browser native fetch when reacting to user events and in lifecylcle hooks (except setup). Basically, anything that only runs in the browser (in the client) should use $fetch
- Any code that runs at the root level of script setup, should make https requests with useFetch or useAsyncData. Prefer useFetch when possible.
- Example of when to use $fetch vs useFetch:

```
<script setup lang="ts">
  const { data: users } = await useFetch("/api/users");
  async function createUser(newUser: User){
   const newUser = await $fetch('/api/users', {
       method: 'POST',
       body: newUser
   })
  }
```

-Components are named and auto imported based on their location within the components directory. For example:

- A component stored in `@/components/MyComponent` will be named MyComponent.
- A component stored in `@/components/users/UsersMyComponent` will be named UsersMyComponent
- ALWAYS prefix the component name with any directory it's nested under within the components directory

- Always use NuxtImg as a drop in replacement for ANY img tag. Be sure to specify appropriate width and heights to prevent CLS and configure styles so that the image is NEVER stretched or distorted
- When using NuxtImg on a src url that is from another site, make sure the domain is registered in nuxt.config.ts like this:

  ```
  image: {
    domains: ["images.unsplash.com", "[the-domain-here]", "etc"],
  },
  ```

Generate a Unit Test

I did not generate any unit tests for this project. But for in general I've found:

  • will use Vitest
  • generates relevant test cases
  • test cases usually require a little tweaking
  • But they are a great starting point!
  • generate a log of features
  • don’t generate everything from scratch, use existing libraries, etc
  • provide screenshots
  • commit early and commit often
  • don't trust the bot, review generated code
  • don’t try to do everything at one time
  • describe in detail what you want

General Workflow Tips

  • use .cursorrules to define your coding preferences and common patterns within your application
  • slow down
  • copy and paste example of your API payloads, JSON data, etc to pass the LLM

General Workflow Tips

Integrating AI

into Apps

Integrating

Use Cases

  • Extracting text from an image
  • Generating image alts
  • Translating text to a different language
  • Smarter search with RAG
  • Summarizing content
  • Generating images and video 

Use the right model for the right task

$00.09 claude-3-opus (35 seconds)
$00.01 claude-3.5 sonnet (17 seconds)

Provide examples in the prompt

Please extract and return all the text content from this textbook page. 

Format it naturally, preserving paragraphs, headings, 
and any important structural elements. 

Output the text in a markdown format, to preserve structures 
like lists, tables, and headings, etc.

Return ONLY a JSON object with the following structure:

{
  "pageNumber": "The page number of the textbook page if found as a string, otherwise null",
  "text": "The extracted text content in markdown format. Escape all new lines and line breaks."
}

Ask for JSON ONLY Responses

// ... prompt from previous slide

DO NOT RETURN ANYTHING ELSE.
ONLY RETURN THE JSON OBJECT as a raw string, 
no other text or formatting.

(xml works great too)

Mitigate Latency with Streaming or Queues

Need a JSON object back? can't really stream

Straight text,

stream it baby

Need a JSON object back? can't really stream

Example of a Scheduled

Task in Nuxt

export default defineNuxtConfig({
  nitro: {
    scheduledTasks: {
      // Run `scannedPages:process` task every minute
	 "* * * * *": ["scannedPages:process"],
    }
  }
})

Chunk Larger Requests into Smaller Pieces

and pass along a summary of the context

For example when generating longer quizzes

Generate 30 Questions

Came Back with 10 Questions

Sent back asking for 20 more

with previous questions as context

Useful

AI Tools

database.build

Supabase SQL AI

  • write queries
  • debug query issues
  • setup RLS policies 
  • and more

Bolt.new

bootstrap micro apps very quickly

Claude

ChatGPT Alternative

  • writes code better than ChatGPT
  • can run some code

example: chart CSVs

PhotoShop

  • generative fill
  • object removal
  • generative expand
  • etc 

danielkelly_io

I'll tweet out the slides and my .cursorrules after this

AI for Developers Masterclass?

Interested in a 

Thank you 🙏

Go code awesome things!

(with Vue and AI 😉)

Vue-doo Magic: AI Development Tricks

By Daniel Kelly

Vue-doo Magic: AI Development Tricks

  • 348