ShareWisのソフトウェアエンジニアとして、私は日々の業務でコードと向き合っています。新機能の開発、バグ修正、チームメイトのプルリクエスト(PR)レビュー、その他さまざまなタスクに追われる毎日です。これらの作業は多くの時間と集中力を要しますが、近年急速に進化する生成AIのおかげで、ついに仕事のスピードと質を向上させるツールに出会うことができました。
最初に試したのは、ChatGPTを搭載したGitHub Copilotでした。しかし、その後さらに優れたツールが登場し、それ以来約1年間、私は「Cursor」を愛用しています。Cursorはまさにコーディングアシスタントと呼ぶべき存在で、コード記述、エラー修正、さらには複雑なコードの平易な解説までこなしてくれます。開発者のために作られたこのツールは、普段使っているコードエディタ(VS Codeのフォーク)内で直接動作します。
このブログ記事では、私が日々の業務でどのようにCursorを活用しているか、そしてCursorを効果的に使うためのヒントを共有したいと思います。
Cursorを使ったコーディングフロー
新機能を実装するときのCursorの使い方
Cursorには、主に2つの動作モードがあります。
- Agentモード: あなたの明示的な許可のもと、Cursorがコード編集、ターミナルコマンドの実行、その他のタスクを自律的に行います。
- Askモード: コードベースに関する質問、コード作成の支援、あるいは
@Stripe
、@AWS EC2
、@AWS Lambda
などのライブラリやサードパーティサービスについて問い合わせることができます。
Cursorには「YOLOモード」というものも存在しますが、これはAIエージェントが各ステップでユーザーの確認を求めることなくタスクを実行してしまうため、私たちのプロジェクトでは推奨していません。
新機能を実装する際、最も役立つのはAgentモードです。通常、分析や計画の段階ではAskモードと組み合わせて使用します。とはいえ、Jiraの要件をそのままCursorに丸投げするわけではありません。まず私自身がタスクを分析し、要件を完全に理解します。その後、Cursorの助けを借りてブレインストーミングと計画を行い、作業をより小さなステップに分割し、詳細な実装はCursorに任せつつ、私は各変更を監督するという流れで進めています。
リファクタリング
古いコードは複雑になりがちですし、たとえ書いたばかりのコードであっても、実装後にはクリーンアップが必要です。読みにくかったり、動作が遅かったりすることもあります。そんな時は、該当する箇所を選択してCursorの「Inline-Edit」機能を使い、「これをもう少しクリーンに、あるいは速くリファクタリングしてくれないか?」と尋ねます。すると、たいていの場合、より理解しやすく効率的な改善版を提案してくれます。「Multi-Line Edits」機能と「Cursor Prediction」も、リファクタリングの際には非常に役立ちます。
バグ修正
エラーに遭遇した際も、Cursorに助けを求めることができます。エラーメッセージや問題のあるコードをコピーし、「なぜこのエラーが起きているの?」と尋ねるだけです。Cursorは原因と可能性のある修正案を提案してくれます。多くの場合、私が見落としていたような些細なミスを発見してくれるのです。
ユニットテストの作成
テストは重要ですが、時には退屈な作業です。私はCursorにRSpecテスト(Ruby用)の作成を手伝ってもらっています。基本的なテストケースを生成してくれるので、それを元に編集・改善していくだけで済み、テスト作成の時間を大幅に短縮できます。さらに、自分では思いつかなかったようなエッジケースまでカバーしてくれることもあります。
PRレビュー
最近のバージョンでMCPサーバーとの連携機能が有効になったため、GitHub MCPをインストールしました。これにより、CursorがGitHub上の私たちのプルリクエストをチェックし、レビューしてくれるようになりました。Cursorはしばしば価値あるフィードバックを提供し、実装中やレビュープロセスで見逃していた盲点を明らかにしてくれます。
また、コミットしてプッシュする前に、ローカルでCursorにコードレビューを依頼することも可能です。実装完了後、Cursorに git diff
を実行させ、タスクに関するコンテキストをいくつか与えれば、私たちが行った変更点をレビューしてくれます。
その他の雑務
顧客からの依頼の中には、反復的で退屈な作業も少なくありません。これらの多くは自動化できますが、その自動化スクリプトを書くのにも以前は多くの時間がかかっていました。Cursorと、その背後にある強力なLLMのおかげで、このような小規模な独立したタスクこそ、Cursorが真価を発揮する分野であり、まさにうってつけと言えるでしょう。
Cursor Rules
Cursor Rulesは、再利用可能でスコープが限定された指示を通じて、Agentの振る舞いを制御するための機能です。適切に構造化されたルールでCursorの行動を導くことで、その能力を最大限に引き出すのに役立ちます。ルールには2種類あります。
- Project rules (プロジェクトルール): 特定のプロジェクトにのみ適用され、Gitでバージョン管理されます。
- User Rules (ユーザールール): すべてのチャットでグローバルに適用されます。
以下は、私がWisdomBaseプロジェクトで使用している現在のルールです。
あなたはシニアRuby on Railsエンジニアです。あなたの役割は、私(同レベルのシニア)とペアプログラミングパートナーとして働くことです。
プロジェクトに関する注意点
- このプロジェクトはモノリシックなRuby on Rails 6.0アプリケーションです。
- このプロジェクトは多言語対応にI18nを使用しています。メイン言語は日本語(管理者関連ページ向け)で、その他に英語、中国語(簡体字・繁体字)、ベトナム語、ポルトガル語、韓国語に対応しています。また、コース購入、メンバーシップ購入機能のために多通貨にも対応しています。
- ビューにはHAMLを使用しています。
- クライアントサイドのコードはJavascript (jQuery) を使用しており、古いコードにはBackboneとCoffeeScriptも使われています。
- このプロジェクトはDocker Composeで実行しているため、rspecテストコマンドは `dc run sharewis-act bundle exec rspec /path/to/file/` のように実行してください。
コードスタイルと構造
- 簡潔でRubyらしい慣用的なコードと正確な例を作成してください。
- Railsの規約とベストプラクティスに従ってください。
- 必要に応じて、オブジェクト指向と関数型プログラミングのパターンを使用してください。
- コードの重複よりも、イテレーションとモジュール化を優先してください。
- user_signed_in?, calculate_totalのような、説明的な変数名とメソッド名を使用してください。
- Railsの規約(MVC、concerns、helpersなど)に従ってファイルを構成してください。
構文とフォーマット
- Rubyスタイルガイド (<https://rubystyle.guide/>) に従ってください。
- Rubyの表現力豊かな構文(例:unless, ||=, &.) を使用してください。
- 文字列リテラルには、式展開が必要な場合を除き、シングルクォートを優先してください。
エラー処理とバリデーション
- 例外は制御フローのためではなく、例外的なケースに使用してください。
- 適切なエラーログとユーザーフレンドリーなメッセージを実装してください。
- モデルではActiveModelバリデーションを使用してください。
- コントローラでエラーを適切に処理し、適切なフラッシュメッセージを表示してください。
パフォーマンス最適化
- データベースインデックスを効果的に使用してください。
- キャッシュ戦略(フラグメントキャッシュ、ロシアンブルキャッシュなど)を実装してください。
- N+1クエリを避けるためにイーガーローディングを使用してください。
- includes, joins, selectを使用してデータベースクエリを最適化してください。
主要な規約
- RESTfulルーティングの規約に従ってください。
- モデルやコントローラ間で共有される振る舞いにはconcernsを使用してください。
- 複雑なビジネスロジックにはサービスオブジェクトを使用してください。
- 時間のかかるタスクにはバックグラウンドジョブ(例:Sidekiq)を使用してください。
セキュリティ
- 適切な認証と認可を実装してください(例:Devise, Cancancan)。
- コントローラではストロングパラメータを使用してください。
- 一般的なWebの脆弱性(XSS, CSRF, SQLインジェクションなど)から保護してください。
ルーティング、コントローラ、モデル、ビュー、その他のRailsコンポーネントにおけるベストプラクティスについては、公式のRuby on Railsガイドに従ってください。
CursorでどのLLMを使うべきか問題
この記事を書いている時点で、私が主に利用しているのはClaude Sonnet 3.7の「Thinking」モードです。これはコーディングに最適なLLMの一つとして広く認識されています。もし、これで期待する結果が得られない場合は、代替としてGemini Pro 2.5に切り替えています。また、ChatGPT o4-miniも非常に優れていますね。
結論、あまり固定せずに使い分けてます。
Cursorを最大限に活用するためのヒントとベストプラクティス
- 明確で、簡潔かつ具体的な指示を与える: 一度に多くのことを詰め込まず、小さな単位で指示を出すのがコツです。
- 人間の監視を怠らない: Agentモードは、AIが提案する計画をレビューした後にのみ使用しましょう。コミットする前には必ず差分を確認してください。
- プロンプトだけでなく、ルールを重視する: 効果的なルール設定が、より良い結果に繋がります。
- モデルを定期的に更新する: 新しいLLMのバージョン(Claude, Gemini, ChatGPT)は、ハルシネーション(もっともらしい誤情報)の修正や推論能力の向上が見られることが多いため、いつまでもデフォルト設定に固執しないようにしましょう。
おわりに
Cursorは現在進行系で進化しています。約1年間、毎日使い続けてきた今、最初に使い始めた頃と比較して劇的に優れていると断言できます。これは基盤となるLLMについても同様で、新しいリリースが登場するたびに、目に見えて賢くなっています。私たちのツールが日々鋭さを増し、より便利になり、仕事の効率を上げてくれるのを目の当たりにできるのは、ソフトウェアエンジニアとして実に刺激的で活力が湧いてくる経験です。
(ファット)
How I Work with Cursor AI to Boost My Productivity as a Software Engineer
As a software engineer at ShareWis, I work with code every day. Sometimes I write new features, sometimes I fix bugs, and other times I review teammate’s PRs or handle miscellaneous tasks. These activities can take a lot of time and focus. But thanks to the growth of generative AI in recent years, I’ve finally found a tool that help me work faster and smarter.
I first started with GitHub Copilot, which is powered by ChatGPT. Later, an even better tool appeared, and I’ve stuck with it for nearly a year: Cursor AI. Cursor AI is like a coding assistant—it helps me write code, fix errors, and even explain complex code in simple terms. It’s built for developers and runs directly inside their code editor (a fork of VS Code).
In this blog post, I want to share how I use Cursor AI in my daily work. I’ll also offer some tips for working effectively with Cursor AI.
My Coding Workflow with Cursor AI
Implement New Features
Cursor AI offers two primary modes:
- Agent mode: Allows Cursor AI to edit code, run terminal commands, and perform other tasks autonomously—with your explicit permission.
- Ask mode: Lets you ask questions about your codebase, request code assistance, or inquire about libraries and third-party services such as
@Stripe
,@AWS EC2
, or@AWS Lambda
, … etc.
Cursor AI also includes a YOLO mode, which I don’t recommend for our projects because it lets the AI agent execute tasks without requiring user confirmation at each step.
When I implement new features, Agent mode is the most useful—usually combined with Ask mode during the analysis and planning stages. Still, I can’t just hand everything over to Cursor AI by copying the Jira requirements into it. First, I analyze the task myself to be sure I fully understand the requirements. Then I brainstorm and plan with Cursor AI’s help, break the work into smaller steps, and let Cursor AI handle the detailed implementation while I supervise each change.
Refactoring
Old code can be messy—and even freshly written code should be cleaned up after implementation. Sometimes the code is hard to read or runs too slowly. I select the relevant section and use Cursor AI’s Inline-Edit feature, then ask, “Can you refactor this to make it cleaner or faster?” It usually produces an improved version that’s easier to understand and more efficient. The Multi-Line Edits feature with Cursor Prediction is also extremely helpful during refactoring.
Fixing Bugs
When I see an error, I can ask Cursor AI for help. I copy the error message or the problem code, and ask, “Why is this error happening?” Cursor AI suggests reasons and possible fixes. Many times, it finds small mistakes that I didn’t notice.
Writing Unit Tests
Testing is important but sometimes boring. I ask Cursor AI to help me write RSpec tests (for Ruby). It creates basic tests that I can then edit and improve. This makes testing much faster. Also, it covers many edge test cases that I even couldn’t think of.
Reviewing PRs
With MCP-server integration enabled in recent versions, I’ve installed GitHub MCP, which lets Cursor AI check and review our pull requests on GitHub. Cursor often highlights valuable feedback and uncovers blind spots I missed during implementation or during review process.
We can also ask Cursor AI to review our code locally before you commit and push. After finishing the implementation, ask Cursor AI to run git diff
, give Cursor AI some context about the task, and let it review the changes we’ve just made.
Other Chores
Some requests from customers are repetitive and boring tasks. Many of these can be automated, but writing the automation used to take a lot of time. Thanks to Cursor AI and the powerful LLMs behind it, small stand-alone tasks are where it really shines—making it ideal for handling this kind of work.
Cursor Rules
Cursor Rules let you control how the Agent behaves through reusable, scoped instructions. They help you get the most out of Cursor AI by guiding its behavior with well-structured rules. There are two kinds of rules: Project rules (only apply to a specific project, and is version-controlled with Git), User Rules (Global to all your chats).
Here are my current rules for the WisdomBase project:
You are a senior Ruby on Rails engineer. Your role is to work with me (same senior level) as a pair programming partner.
Notes for the project
- This project is a monothlic Ruby on Rails 6.0 application.
- This project Is using I18n for multi-languages. The main language is Japanese (for Admin related pages), then English, Chinese (Both Simplified and Traditional), Vietnamese, Portuguese, Korean. Also support multi currencies for Course Purchase, Membership Purchase features.
- Views are using HAML.
- Client Code is using Javascript (jQuery) with same Backbone and CoffeeScript for old code.
- This project is running with Docker Compose, so please execute any rspec test commands with `dc run sharewis-act bundle exec rspec /path/to/file/`.
Code Style and Structure
- Write concise, idiomatic Ruby code with accurate examples.
- Follow Rails conventions and best practices.
- Use object-oriented and functional programming patterns as appropriate.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable and method names (e.g., user_signed_in?, calculate_total).
- Structure files according to Rails conventions (MVC, concerns, helpers, etc.).
Syntax and Formatting
- Follow the Ruby Style Guide (<https://rubystyle.guide/>)
- Use Ruby's expressive syntax (e.g., unless, ||=, &.)
- Prefer single quotes for strings unless interpolation is needed.
Error Handling and Validation
- Use exceptions for exceptional cases, not for control flow.
- Implement proper error logging and user-friendly messages.
- Use ActiveModel validations in models.
- Handle errors gracefully in controllers and display appropriate flash messages.
Performance Optimization
- Use database indexing effectively.
- Implement caching strategies (fragment caching, Russian Doll caching).
- Use eager loading to avoid N+1 queries.
- Optimize database queries using includes, joins, or select.
Key Conventions
- Follow RESTful routing conventions.
- Use concerns for shared behavior across models or controllers.
- Implement service objects for complex business logic.
- Use background jobs (e.g., Sidekiq) for time-consuming tasks.
Security
- Implement proper authentication and authorization (e.g., Devise, Cancancan).
- Use strong parameters in controllers.
- Protect against common web vulnerabilities (XSS, CSRF, SQL injection).
Follow the official Ruby on Rails guides for best practices in routing, controllers, models, views, and other Rails components.
Which LLM that I’m using most in Cursor AI
As of this writing, I primarily rely on Claude Sonnet 3.7 in “Thinking” mode, widely regarded as one of the best LLMs for coding. When it doesn’t meet my needs, I switch to Gemini Pro 2.5 as an alternative. I’ve also heard that ChatGPT o4-mini is excellent—and it’s free to use.
Tips & Best Practices for Getting the Most Out of Cursor AI
- Give clear, bite-sized prompts.
- Keep human oversight: Use Agent mode only after you’ve reviewed the plan it proposes. Always scan the diff before committing.
- Lean on rules, not just prompts.
- Update models periodically: New LLM versions (Claude, Gemini, ChatGPT) often fix hallucinations and improve reasoning—don’t stick to the default forever.
Conclusion
Cursor AI hasn’t stopped improving. After nearly a year of daily use, I can say it is dramatically better than when I first started. The same is true of the underlying LLMs—each new release is noticeably smarter than the last. It’s both fascinating and energizing to watch our tools become sharper and more useful, making our work more efficient with every passing day.
(Phat)