How I code 159% Faster using AI (Cursor + Sonnet 3.5)

Volo
16 Aug 202426:27

Summary

TLDRこのビデオでは、Visual Studio Codeに基づいてAI機能を内蔵した新しいコードエディター「カーソル」を紹介しています。カーソルはプログラミングを大幅に高速化できると主張しており、ビデオではカーソルを使用してアプリケーションを構築し、そのプロセスが従来の方法よりも2.5倍高速であることを実証しています。カーソルのAI機能は、コードの自動生成や改良を通じて開発者の生産性を高め、特にプログラミング初心者や経験豊富な開発者双方にとって有益であると示されています。

Takeaways

  • 😀 カーソルはVisual Studio Codeに基づいてAI機能を直接組み込んだ新しいコードエディターです。
  • 🔍 カーソルを使用することで、既に数年のコーディング経験があるユーザーでもコーディング速度が2.5倍速くなることがわかります。
  • 💻 カーソルをダウンロードするにはcursor.comにアクセスし、インストールボタンをクリックします。
  • 🆓 無料で使用することも可能ですが、プロプラン(月額20ドル)を利用することで追加機能や優れたモデルの使用が可能になります。
  • ⌨️ カーソルでは、コードをハイライトしてCtrl+Kを押すことでAIにコードの変更を指示することができます。
  • 🗂️ Ctrl+Lを押すことでチャットウィンドウを呼び出し、プロジェクト全体のファイルや特定のファイルを参照して変更を依頼できます。
  • 🛠️ AIによるコードの変更は「適用」ボタンをクリックすることで直接コードに反映させることができます。
  • 🖼️ カーソルを利用して、ユーザーが連絡先カードに画像をアップロードできる機能を実装しました。
  • 🔄 カーソルには「コンポーザー」機能があり、複数のファイルにわたる変更を並行して迅速に行うことができますが、まだベータ段階です。
  • 🔍 カーソルはコードベースをインデックス化するため、特定の変数や関数の設置場所を知るためのインテリジェントな検索が可能です。
  • 🎨 カーソルには画像からコードを生成する機能もあり、デザインのスクリーンショットからコードを自動生成することができます。

Q & A

  • カーソルAはどのようなコードエディターですか?

    -カーソルAはVisual Studio Codeに基づいて作られたコードエディターで、AI機能が直接組み込まれており、コーディングをはるかに高速化できます。

  • カーソルAを使用することで、コーディング速度はどのくらい向上するのですか?

    -ビデオのデモでは、経験豊富な開発者であってもカーソルAを使用することで、コーディング速度が2.5倍向上することが示されています。

  • カーソルAをダウンロードするにはどうすればいいですか?

    -カーソルAはcursor.comからダウンロードしてインストールできます。

  • カーソルAのProプランの月額料金はいくらですか?

    -カーソルAのProプランは月額20ドルです。

  • カーソルAのAI機能を使用するにはどうすればいいですか?

    -カーソルAを開き、コードを書くか、または特定のコードを選択してAIに指示を出して機能を使用できます。

  • カーソルAでコードを変更するにはどのようなショートカットを使用しますか?

    -コードを変更するにはControl+K、チャットウィンドウを開くにはControl+Lを使用します。

  • カーソルAはどのようにしてプロジェクト内のファイルを参照しますか?

    -カーソルAはプロジェクトを開くと、その中のファイルをインデックス化し、変更を加える際に素早く参照できます。

  • プロファイル画像を連絡先カードに追加する機能をどのように追加しましたか?

    -カーソルAのAI機能を利用して、画像アップロード機能を複数ファイルにまたがって追加しました。

  • カーソルAのオートコンプリート機能はどのように役立ちますか?

    -カーソルAのオートコンプリート機能は、TailwindやReactなどのフレームワークに精通しており、開発者がコードを入力する際にクラス名や関数を自動的に補完してくれます。

  • カーソルAでコードベースを検索するにはどうすればいいですか?

    -カーソルAでは、特定の変数や関数の設定場所を検索するためにサイドバーから指示を出して、コードベース全体をインテリジェントに検索できます。

Outlines

00:00

💻 カーソルコードエディターの紹介

カーソルはVisual Studio CodeをベースにAI機能を内蔵した新しいコードエディターです。AIの助けを借りることでコーディングが大幅に高速化されます。ダウンロードはcursor.comから行えますが、機能をフル活用するには月額20ドルのプロプランを推奨します。カーソルはVS Codeと同様のインターフェースを持ち、プラグインのインポートも可能です。AIはコードを理解し、特定の変更を求められた場合にコードを修正します。また、コードベースをインデックス作成し、変更を加えるファイルを選択することができます。

05:03

🔧 カーソルのAI機能の活用方法

カーソルのAI機能は、コードの特定部分をハイライトしてControl+Kを押すことで呼び出すことができます。AIは指示に基づいてコードを修正し、変更をレビューしてから適用することができます。さらに強力な機能として、Control+Lを押すことでチャットウィンドウを呼び出し、コードベースを理解した状態で変更を要求することができます。この機能により、複数のファイルにまたがる変更や大きな機能追加が簡単に行えます。

10:05

🖼️ 画像アップロード機能の追加

ビデオでは、ユーザーが連絡先カードに画像をアップロードできる機能を追加するプロセスが説明されています。カーソルのAIは、サーバーサイドの変更、ファイルの検証、アップロード処理など、必要な変更を自動的にコードに記述します。また、Google Cloud Storageを使用して画像を保存し、データベースに画像URLを追加する処理も含まれています。

15:05

🛠️ コードのリファクタリングと機能追加

カーソルの「Composer」機能を使用して、コードを複数のファイルに分割し、整理することができます。ただし、この機能はベータ版であり、エラーが発生する可能性があるため注意が必要です。また、カーソルはTailwind CSSやReactなどのフレームワークに精通しており、自動補完機能を通じてコーディングを支援します。

20:08

🖌️ デザインからコード生成

カーソルはスクリーンショットからコードを生成する機能も持ち、デザインの自動変換をサポートしています。これはFigmaなどのデザインツールからのコード出力機能とは異なり、スクリーンショットを元にAIがコードを生成します。この機能により、コーディングプロセスをスピードアップさせることができます。

25:10

🔎 カーソルの高度な検索機能

カーソルはコードベース内をインデックス化し、特定の変数や関数の場所を知るための高度な検索機能を提供しています。また、AIのオートコンプリート機能は、Tailwind CSSのクラス名など、コーディング中に次の入力を予測してタブを押すことでコードを迅速に記述できます。

Mindmap

Keywords

💡カーソルA

カーソルAは、Visual Studio CodeをベースにAI機能を直接組み込んだ新しいコードエディターです。ビデオでは、カーソルAを使用することでコーディング速度が大幅に向上することが示されています。特に、ビデオの作成者が経験豊富なプログラマーであっても、カーソルAを使用することで2.5倍速くコーディングができたと述べています。

💡AI機能

AI機能とは、カーソルAエディターに組み込まれている人工知能の機能を指します。ビデオでは、このAI機能がコードの自動生成や改良を支援し、開発者の作業を効率化する重要な役割を果たしていると説明されています。

💡プログラミング速度向上

プログラミング速度向上とは、開発者がコードを書く速度やプロジェクトを進める速度を高めることを指します。ビデオでは、カーソルAのAI機能が既存の知識やGoogleでの検索とは比べて、開発者のコーディング速度を2.5倍速くすることが証明されています。

💡ダウンロード

ダウンロードとは、ソフトウェアやデータなどのデジタルコンテンツをリモートサーバーからローカルコンピュータに取得する行為を指します。ビデオでは、カーソルAをダウンロードして利用する方法が紹介されており、ダウンロード後、Visual Studio Codeに慣れているユーザーにとって馴染みやすいインターフェースであることが強調されています。

💡プロプラン

プロプランとは、カーソルAの有料版サブスクリプションサービスを指します。ビデオでは、プロプランの月額20ドルのオプションが推奨されており、追加機能や高精度なAIモデルの使用権が含まれていると説明されています。

💡コードベース

コードベースとは、特定のソフトウェアプロジェクトの全コードの集合体を指します。ビデオでは、カーソルAがプロジェクトを開くとコードベースをインデックス化し、AIが迅速に参照できるようにすることで、コードの変更や機能追加が効率化されると述べています。

💡マルチファイル操作

マルチファイル操作とは、複数のファイルに対して同時に操作を行うことを指します。ビデオでは、カーソルAが1つのファイルだけでなく、複数のファイルに対しても変更を加える機能を持っていると紹介されており、大きな機能追加やコードのリファクタリングにおいて非常に役立つとされています。

💡オートコンプリート

オートコンプリートとは、入力を補助してコードの記述を加速させる機能です。ビデオでは、カーソルAがTailwind CSSやReactなどのフレームワークに熟知しているため、開発者がクラス名をタイプする際にオートコンプリートを利用して効率的にコーディングを行うことができると説明されています。

💡コンポーザー

コンポーザーとは、カーソルAの機能の一つで、複数のファイルに対して並行して変更を行うことができます。ビデオでは、コンポーザーが新しいファイルを作成し、コードのリファクタリングを支援する力強いツールであると紹介されていますが、ベータ版であり、完全ではない部分もあると同時に触れています。

💡画像アップロード機能

画像アップロード機能とは、ユーザーがプロファイルやカードに画像を追加できる機能を指します。ビデオでは、カーソルAのAIがこの機能を実装するコードを生成し、ユーザーが連絡先カードに画像をアップロードして共有できるようにする大きな機能追加の例として説明されています。

Highlights

介绍了Cursor A,一个基于Visual Studio Code的新型代码编辑器,内置AI功能,能显著提高编码速度。

与仅使用传统编码知识和Google搜索相比,Cursor A使编码速度提高了2.5倍。

Cursor A可以从cursor.com下载,界面与Visual Studio Code相似,易于上手。

Cursor A提供免费使用,也提供每月20美元的Pro计划,包含更多高级功能。

演示了如何使用Cursor A迭代开发一个通过二维码交换联系信息的应用。

展示了Cursor A的AI功能,如使用Control+K命令来改进代码。

通过Control+L命令,可以召唤聊天窗口,进行更复杂的代码修改请求。

Cursor A能够理解代码库,提供基于当前文件的上下文来优化代码。

展示了如何通过聊天窗口请求Cursor A进行代码更改,包括界面和功能上的改进。

讨论了Cursor A的撤销功能,允许开发者回退到编辑前的状态。

展示了如何使用Cursor A添加新功能,如上传图片到联系卡片。

介绍了Cursor A的Composer功能,用于处理多文件交互和重构代码。

讨论了Composer功能的局限性,以及在实际使用中可能遇到的问题。

展示了如何使用Cursor A的图像识别功能来生成代码。

介绍了Cursor A的自动补全功能,能够预测并补全代码。

展示了如何使用Cursor A搜索整个代码库,以找到特定功能的实现位置。

总结了使用Cursor A可以显著提高编码速度,并鼓励观众提出问题以制作更多相关视频。

Transcripts

play00:00

today we're taking a look at cursor a

play00:02

new code editor that is based on Visual

play00:04

Studio code but has AI features built

play00:07

directly into it which can help you code

play00:09

much much faster in fact in my last

play00:11

video I built the same app Twice first

play00:13

using cursor and then just using my own

play00:16

knowledge and what I could find on

play00:17

Google and I found that cursor actually

play00:19

made me 2 and a half times faster and

play00:22

this is as someone who's had many years

play00:24

of coding experience so it can really

play00:26

speed you up so let's dive into what's

play00:29

different about cursor and how you can

play00:31

actually use it first of all to download

play00:32

cursor you're going to go to cursor.

play00:35

comom and there's a button you can

play00:36

download it install it again it's pretty

play00:39

much like Visual Studio code with some

play00:41

additional features so if you've used vs

play00:43

code you're going to feel right at home

play00:45

now you can use it for free to some

play00:47

degree and you can also bring API keys

play00:49

from other services like open AI or

play00:51

anthropic but I highly recommend the $20

play00:54

a month Pro Plan because you get some

play00:57

additional features and you get pretty

play00:59

much limited usage of some of the best

play01:01

models like Claude Sonet 3.5 and you'll

play01:04

quickly see your return on investment

play01:06

with that even if you're already using

play01:08

AI like chat GPT to code because this

play01:10

really is much faster so when you first

play01:12

open this up it's going to look pretty

play01:14

familiar if you've used VSS code before

play01:16

and you're able to just write code here

play01:18

you're able to set your different theme

play01:20

and you can actually import some of the

play01:22

plugins and other things that you would

play01:24

have in vs code so they've designed it

play01:26

to be a pretty smooth transition to

play01:28

demonstrate how cursor works I'm I'm

play01:29

going to be iterating on the application

play01:31

that I built in my last video which is

play01:33

called quiron or QR contact and it's

play01:37

essentially a way to exchange contact

play01:39

information quickly through a QR code

play01:42

I'm going to be adding a new feature

play01:43

here which is going to allow us to have

play01:45

profile pictures that you can associate

play01:47

with your different contact cards and

play01:50

we're going to use cursor to help

play01:52

actually write most of the code for us

play01:54

now there's a few different ways in

play01:56

which AI is baked into this and the

play01:58

first one I'll show is the command or

play02:00

contrl k where you can highlight some

play02:03

code and then if you press control K uh

play02:07

you're going to be able to write some

play02:08

instructions for the AI to iterate on

play02:11

that code or to take that code into

play02:12

account and do something that you want

play02:14

it to do so in here we can for example

play02:17

highlight this code which represents

play02:19

this delete button and let's just say we

play02:21

want to add some more padding to it add

play02:24

more padding to this

play02:27

button okay and it's going to go through

play02:30

it's going to make some adjustments

play02:31

right so you can see here that it

play02:33

removed some code it added some code

play02:35

coding effectively becomes like

play02:37

reviewing pull requests from the AI so

play02:39

we can accept that change and then we

play02:41

will see that the trash icon has moved

play02:44

now the cool thing with cursor is we can

play02:46

actually undo these changes so if I

play02:48

press contrl Z it's going to go back to

play02:50

that edited State and I can kind of

play02:53

review my code again I can just go back

play02:55

to the code that I previously had and

play02:57

just ignore the changes that it made so

play02:59

control K can be a good way to make

play03:01

these targeted sort of precise little

play03:03

changes but the most powerful feature

play03:06

that I like to use most of the time is

play03:08

control or command L and pressing

play03:11

control L is going to summon this chat

play03:13

window that you see on the right and I

play03:16

like to think of this in many ways like

play03:18

chat GPT with a lot of additional

play03:21

benefits the cool thing about cursor is

play03:23

it already knows your code base when you

play03:25

open a project in cursor it's going to

play03:28

index all of the files that you have so

play03:30

that it can quickly reference them when

play03:32

you are making changes but you also have

play03:34

control over which files you want to

play03:37

reference when you're asking it for

play03:39

changes that's going to make it so that

play03:40

it doesn't just search the entire code

play03:42

base and get confused by having too much

play03:45

context you can actually hone in on

play03:48

specific files that you want to change

play03:50

and the context that you want it to use

play03:52

when it's doing something that you want

play03:54

it to do so let me just give an example

play03:56

of this right when I'm making this

play03:58

change here by default when when you

play04:01

open up that chat window it's going to

play04:04

reference the file that you have opened

play04:06

and you will see it down here so card

play04:08

list now let's say we want to make a

play04:10

change to this card list where we want

play04:12

the QR code to appear to the left and

play04:14

then we want the title and the

play04:16

description to be on the right of that

play04:17

instead of this kind of vertical thing

play04:19

so we can go in here and we'll just

play04:22

describe what changes we actually want

play04:24

now as I think through the design here

play04:26

and what I actually want I'm realizing I

play04:29

don't know where I want this trash icon

play04:31

to be but let's actually change it for a

play04:33

menu icon you know like the little three

play04:36

dots that you can click and then we'll

play04:37

have a delete item inside of that menu

play04:40

so let's just go ahead and add it to

play04:42

this code we can actually request

play04:43

multiple changes in this chat okay now

play04:46

when we're ready it's going to again use

play04:48

the context of this card and we'll go

play04:50

ahead and ask it for those changes okay

play04:52

so it's written some code for us I am

play04:54

using Claude Sonet 3.5 here which I've

play04:57

found to be the best model for coding as

play05:00

of right now this is middle of August 24

play05:02

I'm sure new models will come out but

play05:04

this has been a real game changer

play05:06

honestly um so now we have this code

play05:09

that it's written if you generated

play05:11

something like this with Chad GPT you

play05:14

would be spending your time replacing

play05:16

these existing code portions with the

play05:19

code that you have so you'd still have

play05:21

to spend a lot of time taking the

play05:23

changes that it made and integrating

play05:25

them in your code but with cursor we

play05:27

have this apply button which is going to

play05:30

go ahead and apply all of those changes

play05:33

directly into our code so this way we

play05:35

can review the changes that it made and

play05:38

we can also just go ahead and accept

play05:40

them and see what this looks like and

play05:42

honestly that looks pretty good and look

play05:44

at that uh it's pretty much done exactly

play05:46

what we want it's replaced the trash

play05:49

with this little menu and we have the QR

play05:52

code on the left descriptions so this

play05:54

looks all good one issue I do see is

play05:58

that when I click onto this menu and

play06:01

when I click away the menu doesn't

play06:03

disappear so we're just going to go back

play06:05

to cursor and we're going to ask the AI

play06:08

to iterate on that I usually try to say

play06:10

something like this looks good so that

play06:12

it doesn't go and try to change a bunch

play06:14

of code but then I'll add the additional

play06:16

code that I want changed so we're just

play06:18

going to keep it going in this

play06:19

conversation because the change that we

play06:21

want is related to the changes that it's

play06:23

made so I'll just say that looks great

play06:26

but when I click away from the menu when

play06:28

it is open it doesn't disappear can you

play06:30

add some clickaway functionality to make

play06:32

it close this can be a good way to build

play06:35

a feature pretty much just in the chat

play06:37

box where you have an idea in mind you

play06:40

ask for the initial request you see what

play06:42

the changes look like and then you just

play06:44

iterate on that in that same chat until

play06:47

you pretty much get to a complete

play06:48

feature sometimes you'll want to start

play06:50

over in which case you can just close

play06:52

this chat and open a new one and then

play06:54

you'll have fresh context it's like

play06:56

opening a new conversation in chat GPT

play07:00

okay so it's written some code for us

play07:01

we'll go ahead and apply those

play07:04

changes all right it's using a use

play07:06

effect here for the click

play07:09

away all right now let's test those

play07:11

changes now if I click here click away

play07:15

Perfect all right that's exactly what we

play07:18

wanted great so we've made some small

play07:20

changes to this one file but can we go

play07:23

beyond that how do we change multiple

play07:25

files or add really big features well

play07:28

this chat window is capable of a lot

play07:30

more than just working on one file we

play07:32

can actually tag different files and ask

play07:34

it to change those files or just use

play07:36

them as references so that it knows how

play07:38

to change the file that you're on so to

play07:41

demonstrate this let's take a pretty big

play07:43

feature we're going to want to allow

play07:45

users to upload images that they can use

play07:48

as part of their cards so that when they

play07:50

share this contact information you can

play07:53

see the picture of the person that's

play07:54

actually sharing it but that's going to

play07:56

involve a lot of different pieces right

play07:58

we're going to need to change the

play07:59

configuration page we're going to need

play08:02

to validate the files need to send it to

play08:05

the server the server is going to have

play08:07

to upload it to some kind of file

play08:09

storage bucket and verify that you know

play08:13

it's an image and it's not too big we're

play08:16

going to have some security features

play08:17

there's a lot of different factors that

play08:19

are at play here but I want to show the

play08:21

power of cursor and how we can really

play08:23

quickly make a lot of those changes and

play08:26

they're not going to be perfect but

play08:28

they're going to get you like 80 % of

play08:29

the way there and then if you know how

play08:31

to code already you're going to be able

play08:33

to make up that last 20% very quickly

play08:36

and usually it'll be just by asking

play08:38

cursor to change some things again so

play08:41

let's go ahead and make a request to

play08:43

modify multiple files to add this pretty

play08:46

big feature all right so let's take a

play08:49

look at this request that I wrote up we

play08:51

want to add the ability for users to add

play08:53

images to their contact card to make

play08:55

this happen we'll need to add a button

play08:57

to this page which is the configuration

play08:59

page page that allows them to select an

play09:01

image to upload then when the user saves

play09:04

the card we will send that file to the

play09:06

server which will save it to a storage

play09:09

bucket and add the URL of the image to

play09:11

the card before saving it in the

play09:13

database actually I'm going to add here

play09:15

to specify which storage bucket I'm

play09:17

talking about so that it can write the

play09:19

code for that as well we will be

play09:23

using gcp uh

play09:26

storage okay we'll need to modify

play09:29

this file to add the upload feature the

play09:32

communication should happen through the

play09:33

serom JS file that I have to ensure that

play09:37

we attach the user token when we're

play09:38

making that request and we'll also need

play09:41

to modify the server side of things to

play09:43

support this new functionality so let's

play09:45

go ahead and make that request now it's

play09:47

going to write code for all of these

play09:49

different files and we'll just go file

play09:51

by file and be able to apply it let's

play09:54

take a look at the changes that it made

play09:56

so first of all we're going to edit this

play09:57

configuration page okay sure I'll just

play10:00

apply all the changes I'm just going to

play10:02

trust it for the time being and if

play10:04

something goes wrong I'll just roll

play10:06

forward and we'll make changes from

play10:08

there so now we'll go over to server com

play10:11

we'll we'll make changes there okay that

play10:14

looks

play10:15

fine and then we're going to go to our

play10:18

server and we got a bunch of changes in

play10:20

here as well okay now we're going to use

play10:22

molter as a new library we're going to

play10:24

use Google Cloud Storage that sounds

play10:26

good and here's a bunch of code that it

play10:29

wrote to actually upload that file and

play10:31

then use it we'll review all of this

play10:33

code to make sure it's doing this in a

play10:35

secure way so it recognizes that we're

play10:38

going to need these two new libraries so

play10:40

I can actually just copy this and run it

play10:44

in my server we're going to install

play10:46

those two

play10:47

libraries looks

play10:51

good

play10:53

okay so we'll switch over

play10:56

here let's try adding a new contact

play10:59

all right now look at that we got a

play11:01

button here and as soon as I click it

play11:04

it's letting me select an image so let's

play11:06

go ahead and I don't know choose this

play11:09

one okay well it's rendering something

play11:12

for me in the UI here now that's that's

play11:14

not necessarily uploaded yet we haven't

play11:16

tried to save it but you can see that we

play11:18

already have this functioning kind of

play11:20

image upload where I can select the file

play11:22

and uh it's going to display here now

play11:26

before I click save to upload this I am

play11:28

actually going to review the code

play11:29

because I don't want it to just go to

play11:31

some random bucket I want it to go to a

play11:33

bucket that I specify and that I have

play11:35

set up for this so let's take a look at

play11:37

how that code works okay I'm just going

play11:39

to press undo real quick so that I can

play11:42

see the changes and this is going to

play11:43

highlight for me when that image upload

play11:45

H happens okay so the relevant changes

play11:48

are right here in handle submit we're

play11:50

going to go ahead and make a request

play11:52

with the card ID and the image and we're

play11:55

going to get the image URL out of that

play11:57

and then we'll call the API to save the

play11:59

card I think that's that's very

play12:01

reasonable um so again just control

play12:04

enter you're able to accept all of the

play12:06

changes or you're able to go line by

play12:08

line and then make changes as you wish

play12:11

let's see what bucket it's trying to use

play12:12

and then we'll make sure that it's

play12:15

properly set up in Google Cloud okay so

play12:18

it looks like it's looking for the

play12:20

bucket that we have specified in our

play12:23

environmental variables I think that's

play12:25

perfectly reasonable okay so I'm going

play12:27

to go ahead and add this to my EnV file

play12:30

so that we can properly upload to the

play12:33

bucket that I want okay I've got the

play12:35

bucket set up as far as I can tell so

play12:36

let's see what happens when I try to

play12:38

save this with image let's call it right

play12:43

saving seems take a little while and

play12:46

then we got an error okay um take a look

play12:49

here all right so right now it looks

play12:53

like it's trying to connect to the

play12:55

database but it crashes so let's try to

play12:58

figure out what's going on here now

play13:00

again I'm going to just iterate on the

play13:02

thing that happened before so I'm

play13:03

getting this error and I kind of have a

play13:06

clue as to what might be happening uh

play13:08

but let's go ahead and ask the AI to

play13:10

troubleshoot it for us all right this

play13:12

seems pretty good but I get this error

play13:14

uh let's see do we need some additional

play13:16

changes okay eror suggests DB object is

play13:20

undefined all right updated version of

play13:23

index JS let's check it out let's see

play13:25

what changes it

play13:27

made okay down here well first of all

play13:31

it's going to try to catch that error

play13:33

and then error updating the URL and here

play13:38

um looks like update image card okay so

play13:41

this method doesn't look very clean

play13:44

because we actually have a database file

play13:47

so let's ask it to just use that instead

play13:49

I'm going to just press contrl Z to

play13:52

remove those changes and keep the last

play13:55

ones and then we're going to ask it to

play13:57

use our database file and update that as

play14:00

necessary I see the problem we should

play14:02

use dbj to handle database interactions

play14:05

let's change the server and the DB

play14:10

file all right so we'll go here apply

play14:13

some changes there we go it added a new

play14:15

method for us which is going to be to

play14:17

update the

play14:19

card and then back to index.js we'll go

play14:22

ahead and apply these changes as

play14:26

well here we go now it's going to

play14:28

actually use database connection

play14:31

properly all right let's try to save

play14:34

again there we go it actually saved this

play14:37

time and if we look at this it logged

play14:39

our card it says with image and then it

play14:41

has the image URL that should be in the

play14:43

database

play14:45

amazing so if we go back and then we go

play14:48

to the with image card um we don't yet

play14:51

see it so let's keep iterating we'll

play14:53

keep adjusting this so that it actually

play14:55

shows the image I'm pretty confident

play14:57

that it saved it it just needs needs to

play14:59

render it when we first open the card at

play15:01

this point the chat on the right is

play15:03

getting a little long and I think I'm

play15:04

going to be better off just starting a

play15:06

new conversation with the AI and kind of

play15:08

explaining some of the context that I

play15:10

set because I'm just going to want

play15:12

different set of files to be changed and

play15:15

I don't need it to get confused by all

play15:17

these previous changes that it's been

play15:18

making so we'll start a new chat and

play15:20

we'll go back to this configure contact

play15:22

details so here I'm basically saying

play15:24

what is currently happening and what I

play15:26

want to happen and I'm allowing it to

play15:29

sort of figure out what changes it needs

play15:30

to make so I'm not overprescribing a

play15:32

solution because I'm not going to spend

play15:34

too much time thinking about it but if

play15:36

it struggles with this then I will get

play15:38

into more details all right here's the

play15:40

changes we go ahead and

play15:42

apply and it looks like pretty straight

play15:44

forward essentially when we load the

play15:46

card yeah we're just going to use the

play15:48

image if it's already there and that's

play15:50

that's

play15:51

great all right we'll accept the

play15:54

change now when we go in here we see

play15:56

clippy perfect all right and it was that

play16:01

smooth in what 10 15 minutes we added

play16:03

the ability to upload images retrieve

play16:06

them as needed and you know that

play16:08

probably would have taken a lot more

play16:10

time without the help of AI so now let's

play16:12

just clean this up a little bit and

play16:14

we'll show this near the top instead of

play16:16

kind of in the middle here all right now

play16:18

it's going to move some things around

play16:19

for us we'll we'll apply these

play16:22

changes all right there we go that's

play16:24

looking a little bit

play16:26

better we can change profile picture

play16:28

let's Let's uh let's use something

play16:31

else all

play16:33

right save okay it's saved let's see if

play16:37

it comes up again yep we got our new

play16:39

picture and if we look over here this is

play16:42

our storage

play16:43

bucket we can see those images that got

play16:47

uploaded so this sidebar is really how I

play16:49

do a lot of the coding and it's really

play16:51

the Workhorse for me but there are some

play16:54

other features which I find really

play16:55

beneficial as well so now that we've

play16:57

made all of these Chang this file is

play16:59

getting a little bit too large and I

play17:02

want to refactor it into something more

play17:04

manageable and because I'm going to be

play17:06

creating new files I'm going to show you

play17:07

one more feature that cursor has which

play17:10

is uh one of the more powerful newer

play17:12

features and that's called the composer

play17:15

now the composer is really designed for

play17:17

doing all of these multifile

play17:19

interactions and sometimes it gets

play17:21

overwhelming and confusing because you

play17:23

can't as clearly see the changes and

play17:26

revert them but in this sort of

play17:28

situation it can be a really quick way

play17:30

to create all of these new files and

play17:32

keep things organized to activate the

play17:34

composer you might have to go to file

play17:36

preferences cursor settings and then in

play17:40

the beta section it is this multic

play17:44

composer so we'll go ahead and open it

play17:47

using control shift I and let's ask it

play17:50

to refactor some things for us the cool

play17:52

thing about the composer is that it

play17:54

works on all of these files separately

play17:57

but in parallel so it's actually faster

play17:59

than going one by one and changing these

play18:02

files and it's actually creating new

play18:05

files for me which is going to be really

play18:08

useful okay so it's taking out a bunch

play18:11

of these sections making them into new

play18:13

files and we can kind of compare the

play18:15

differences Let's uh let's be bold and

play18:18

just accept all and see how it goes all

play18:21

right we'll close

play18:23

that so now we have all these additional

play18:27

files so contact d detail item contact

play18:30

detail form let's go ahead and switch

play18:34

over and it looks like it left out a lot

play18:37

of these different dependencies so you

play18:39

know the composer is still a work in

play18:41

progress let's uh let's open it back up

play18:44

and give it some feedback okay looks

play18:47

like it's applying some changes to those

play18:49

files well I'll be honest this didn't

play18:52

work as well as I expected and I feel

play18:55

like it's going to be pretty difficult

play18:56

for me to fix that form and know what

play19:00

context it's working with so while the

play19:03

composer is a powerful way and I expect

play19:05

this is going to be the best way to work

play19:07

with cursor in the future I think right

play19:09

now it's at a point where it's a little

play19:12

difficult to tell what it's going to

play19:13

change and how it's going to change it

play19:15

like the scope is too large that when it

play19:18

makes errors like this it's really

play19:20

difficult to roll things back so um you

play19:23

know the composer is still in beta we're

play19:25

going to go ahead and undo

play19:29

those changes so I went ahead and just

play19:31

contrl z i undid those changes now we

play19:34

got some new files I'm going to delete

play19:36

those I think it's just that the scope

play19:38

of the changes it tries to make can be

play19:40

so large that some wires get crossed and

play19:43

some of the models just don't keep up

play19:45

with it just yet and that's why it's in

play19:47

beta I mean they're still developing

play19:48

this feature so I'm going to go ahead

play19:50

and ask it to refactor things for me in

play19:52

the sidebar and we'll keep it to

play19:54

something a little more manageable let's

play19:56

just move the image upload stuff in to a

play19:58

separate file and then we'll reference

play20:00

it here let's call the file profile

play20:02

picture instead all right and then

play20:04

here's how

play20:08

we okay great so now when we go here it

play20:12

still works as

play20:16

expected save the changes okay that all

play20:19

looks good when I open it it loads the

play20:22

correct file so that refactor was a

play20:24

little bit smoother and this is the cool

play20:26

thing is that you know when you're doing

play20:27

a refactor man manually you're going to

play20:29

have to go in and change all these

play20:31

different values but AI can really

play20:33

accelerate that so you can actually like

play20:35

you start off with Messy code because

play20:37

you have ai write all this but you can

play20:40

also get AI to refactor it so you can

play20:42

make things cleaner and much more

play20:43

organized so at this point we've added

play20:46

the ability to upload these pictures and

play20:48

we can see it during this configuration

play20:49

page but when we go to the preview the

play20:52

picture is not there and this could use

play20:54

a little bit more polishing so I want to

play20:56

show you another cursor feature which I

play20:58

really like like and that's the ability

play21:00

to use images you can actually take

play21:02

screenshots of a design for example and

play21:05

have cursor build out what it sees in

play21:07

the image so I have here an outline of

play21:10

what I want this card to look like and

play21:12

this is kind of a rough draft and keep

play21:14

in mind that cursor is not going to be

play21:15

perfect about this but it can be a

play21:17

really great way to get started so if

play21:19

you're working on a project and a

play21:21

designer sends you you know a figma file

play21:23

you can take a screenshot and then just

play21:25

generate code out of that I know figma

play21:27

has some code exporting features but

play21:29

they just never seem to work for me so I

play21:32

found this to be a more effective

play21:33

approach anyhow the way that I like to

play21:35

do this is to just take a screenshot of

play21:37

the

play21:39

design and then we'll flip over back

play21:41

into cursor I'm on the contact preview

play21:44

card here and I'm going to go ahead and

play21:47

just give it this design and say let's

play21:50

make I'll just give it a hint of where

play21:52

that data is located so let's give this

play21:55

a try all right we got a bunch of

play21:57

changes we'll flip back

play21:59

over to the

play22:01

browser and let's see what the preview

play22:03

looks like well it looks mostly correct

play22:06

except that the it's it's full width so

play22:09

we just need to control the width let's

play22:11

say I don't know 400

play22:16

pixels okay and then we kind of want to

play22:20

center it so let's see if we can MX Auto

play22:25

look at that this is this is another

play22:26

powerful feature of course that it auto

play22:29

suggests and now it's saying okay so

play22:32

there we go that's looking a lot closer

play22:34

to what I wanted maybe we can also give

play22:37

it a Max height let's add a little

play22:42

border nice and by the way I don't know

play22:45

if you noticed that but cursor just

play22:47

autoc completed a lot of that for me so

play22:49

I just typed in B and automatically it

play22:52

is suggesting border border gray rounded

play22:55

large Shadow large so I can autocomplete

play22:58

that the way that it knows that is

play22:59

because it's very familiar with Tailwind

play23:02

it's familiar with react familiar with a

play23:04

lot of Frameworks so there we go this

play23:07

card is looking a lot nicer and closer

play23:09

to what I wanted with one more prompt we

play23:11

got the blue going halfway down and we

play23:13

got that nice white border around the

play23:15

image and you know this looks a lot more

play23:17

professional you can see again here when

play23:19

I type in send because I don't remember

play23:21

the Tailwind class I want the text to be

play23:24

centered and I type in send and it auto

play23:26

recommends I do text Center so we'll do

play23:30

that and boom my name is now centered I

play23:33

didn't have to go look up what that

play23:35

class name was actually called so

play23:38

perfect another cursor feature that I

play23:40

want to highlight is the autocomplete

play23:42

Plus Auto tab where cursor can actually

play23:45

predict where you're going to want to go

play23:46

next and this can be a really great way

play23:49

to edit code manually without that

play23:51

sidebar so looking at this function here

play23:54

I have an if statement with a bunch of

play23:56

else ifs um just as an example let's try

play24:00

to switch this to a switch case

play24:03

statement instead so let's say I change

play24:06

this and I type

play24:08

switch well it immediately knows the

play24:11

rest of what I want to type on this

play24:13

line then it predicts how I'm going to

play24:16

want to change some of the following

play24:17

lines and I can just press Tab and then

play24:21

it even knows which next line I want to

play24:24

go to after that so I'll go over here

play24:26

and it predicts to switch it to email I

play24:30

can basically just keep pressing Tab and

play24:33

uh and there we go and let's just format

play24:35

that real quick okay and now I've

play24:37

switched all those ifal statements to

play24:40

cases I don't know if this is actually

play24:42

any more readable I think if I refactor

play24:44

this into some smaller functions then it

play24:47

might look better so let's go back to

play24:49

that control K we'll just select that

play24:51

section of the code and say Vector this

play24:55

all right it it gave us all those

play24:57

changes now we have this format value

play25:01

and some very specific formatting

play25:03

functions so a pretty quick easy way to

play25:06

refactor and makes it a lot more

play25:07

readable oh and I almost forgot one

play25:09

other feature which is pretty useful at

play25:11

times especially if you're working in a

play25:13

really large codebase because cursor

play25:16

indexes all of the files you can

play25:18

actually search your codebase more

play25:20

intelligently so in the sidebar here I

play25:22

could ask it where in my code base does

play25:27

the cck on get set and then I can press

play25:31

controll enter to search the entire code

play25:35

base and now it's going to go look

play25:36

through all these different files and

play25:39

it'll be able to provide me with an

play25:41

answer so in this case set in the index

play25:46

HTML file there it goes it points me to

play25:49

the right place so if you're just lost

play25:51

in a large codebase this can be a really

play25:53

great way to find your way around and to

play25:56

try to understand how some files Rel to

play25:58

each other once you do have a better

play26:00

understanding of the code base I would

play26:02

recommend that you just tag specific

play26:04

files instead of searching across the

play26:05

whole code base but if you're totally

play26:07

lost and you're not sure where something

play26:09

is it can be an effective way to find

play26:11

that so hopefully this helps you see how

play26:14

you can code much faster using cursor

play26:16

and if you have any questions drop them

play26:17

down in the comments because I'd love to

play26:19

make more videos like this showing you

play26:21

how you can use AI to improve your

play26:23

coding speed as always thanks for

play26:25

watching take care

Rate This

5.0 / 5 (0 votes)

Related Tags
CursorAIコーディング開発効率Visual Studio Codeプログラミングエディター自動生成コード補完TailwindReact
Do you need a summary in English?