Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AI Coding in Bakuraku's Monorepo: Environment S...

AI Coding in Bakuraku's Monorepo: Environment Setup & Case Studies with {Roo, Claude} Code [EN]

Avatar for upamune / Yu SERIZAWA

upamune / Yu SERIZAWA

June 12, 2025
Tweet

More Decks by upamune / Yu SERIZAWA

Transcript

  1. AI Coding in Bakuraku's Monorepo: Environment Setup & Case Studies

    with {Roo, Claude} Code 2025/06/12 AI Coding Meetup #2 @upamune
  2. id: upamune (upa) $ whoami LayerX BAKURAKU Division (2022-04 -)

    Software Engineer BAKURAKU Attendance Tech Lead Mercari, Inc. / Merpay, Inc.(2018-04 - 2022-03) Love Roo Code and contributed .roorules support and .roo directory feature to Roo Code core AI Coding subscriptions: Cursor, Windsurf, Augment Code, Claude Max (Claude Code) Was a heavy Roo Code user until late May, but... © LayerX Inc.
  3. Today's Topics I'll share the nitty-gritty details of using AI

    Coding Agents, what's not working well, and finally some practical use cases © LayerX Inc. Intro Environment Setup for AI Coding Agent-agnostic Context Preparation Use Cases with Roo Code / Claude Code 3
  4. Context: BAKURAKU Development in Monorepo We have separate monorepos for

    backend and webapp. © LayerX Inc. bakuraku-backend BAKURAKU Expense Management backend BAKURAKU Invoice backend BAKURAKU Attendance backend ... bakuraku-webapps BAKURAKU Expense Management web app BAKURAKU Invoice web app BAKURAKU Attendance web app ... 5
  5. Specific Challenges When Starting AI Coding © LayerX Inc. In

    monorepos, different developers need different AI Coding Agent rules Different teams with different needs Working on different services Not always opened from repository root Often opened from specific service directories Context provided to AI tends to become large 6
  6. Challenge 1: Different Developers Need Different Rules © LayerX Inc.

    In a monorepo, different developers work on different directories with different teams and tech stacks Each team has slightly different coding conventions and tech stacks Rules helpful for one team might be disruptive for others... Unused or unnecessary rules waste context window space and create noise 8
  7. Challenge 1: Different Developers Need Different Rules © LayerX Inc.

    Add .clinerules/ and .roo/rules/ to .gitignore to avoid git tracking Place .gitkeep in each to preserve the directories Manage rules in a separate directory under git control 10
  8. Challenge 1: Different Developers Need Different Rules © LayerX Inc.

    Copying desired rules from Rules Bank to .clinerules/ or .roo/rules is tedious Created github.com/upamune/airule - a fuzzy finder with preview to pick rules easily Works with both Cline and Roo Code using airule --from /path/to/source --to /path/to/destination Cline: airule --from /path/to/rules-bank --to .clinerules Roo Code: airule --from /path/to/rules-bank --to .roo/rules Supports environment variables for those who want to just run airule without specifying paths each time 12
  9. Challenge 2: Not Always Opened from Repository Root © LayerX

    Inc. In monorepos, it's common to open workspace from the service directory you're developing When this happens, Cline and Roo Code can't recognize the rules Rules aren't loaded because there's no .clinerules/ or .roo/ directory in the opened directory 15
  10. Challenge 2: Not Always Opened from Repository Root © LayerX

    Inc. Solution: Created a tool to distribute rules to required directories github.com/upamune/airulesync Provide a config file like below and it syncs the rules 16
  11. Solutions So Far © LayerX Inc. This isn't about "use

    the tools I introduced!" but rather... AI Coding Agent barriers can be solved with AI Coding Agents You can quickly develop tools tailored to your organization's specific challenges, and if they're general enough, make them OSS Off Topic: When adding more tools increases installation time... There's an elegant tool called aqua that handles this, but let's discuss that at the after-party if we have time... Lightning-fast local environment setup with aqua in the age of everyone coding - LayerX Engineer Blog 17
  12. Challenge 3: Context for AI Tends to Become Large bakuraku-backend

    line count (June 2025) by boyster/scc © LayerX Inc. 19
  13. Challenge 3: Context for AI Tends to Become Large bakuraku-backend

    line count (June 2025) Includes auto-generated files 4.2 million lines (゚A゚;) gulp © LayerX Inc. Files: 19,959 files Lines of code: 4,217,551 lines 20
  14. Challenge 3: Context for AI Tends to Become Large ©

    LayerX Inc. Context window fills up quickly when referencing many files Too many files to search through, hard to find the right ones 21
  15. Challenge 3: Context for AI Tends to Become Large Honestly,

    haven't found a good solution yet © LayerX Inc. 22
  16. Challenge 3: Context for AI Tends to Become Large ©

    LayerX Inc. Context window fills up quickly when referencing many files Gemini 2.5 Pro with its large context window solves the size issue, but performance degrades rapidly with large contexts Roo Code recently added Intelligent Context Condensing which summarizes early context when window is full, but I haven't really felt the improvement Too many files to search through, hard to find the right ones Roo Code recently added Codebase Indexing, so I set up an environment to test it... Uses OpenAI or Ollama (Local) for embedding models, creates embeddings, and uses Qdrant vector database Codebase Indexing - Roo Code Cline doesn't do Codebase Indexing ref. Why Cline Doesn't Index Your Codebase (And Why That's a Good Thing) 23
  17. Challenge 3: Context for AI Tends to Become Large I

    think there's still room for improvement, so I'd love to learn about different approaches © LayerX Inc. Claude Code is working surprisingly well Claude Code has built-in ripgrep (fast grep tool/Rust implementation) and uses it instead of RAG Persistently searches with various patterns using ripgrep to find the right implementations and files 25
  18. Why is Context Preparation Important? When context is insufficient... Context

    preparation becomes a valuable asset even as AI Coding Agents change © LayerX Inc. Can only make suggestions based on general best practices Generates code that ignores project-specific conventions Cannot maintain consistency with existing code AI Coding Agent has fewer clues to reach the correct answer 27
  19. Concrete Context Examples ① © LayerX Inc. ADR (Architecture Decision

    Records) / Design Doc / Spec Developed internal tool to automatically fetch from Notion and convert to Markdown Technical decision records and specifications Provides "why we chose this design" in a format AI can understand DB Schema Information Using k1low/tbls Tool that auto-generates documentation from DB schema Generates ER diagrams, table definitions, and relation info in Markdown format Generate and commit to repository More accurate than CREATE TABLE SQL definitions 28
  20. Concrete Context Examples ② Internal Library and Framework Usage ©

    LayerX Inc. Store internal best practices in Markdown format under docs/libraries Writing from scratch is tedious, so use MCP servers to create drafts while documenting how to use libraries and how we want them to be used Context7: Access latest documentation Deep Wiki: Provides wiki by analyzing GitHub repositories 29
  21. tips: AI Playground Directory © LayerX Inc. A temporary workspace

    for AI to generate files and output modification proposals Place for files like plan.md containing implementation plans Add this to .gitignore The name of this directory might be controversial depending on people/organizations lol 32
  22. tips: First, Make an Implementation Plan © LayerX Inc. This

    has been said many times, but for complex implementations, it's best to plan first Cline has Plan mode, Roo Code has Architect mode, Claude Code got Plan mode today(?) Have AI output to z/plan.md or similar and review it If the content is good, start implementation based on that However, things don't always go smoothly... Task breakdown is necessary Roo Code's Orchestrator mode and Claude Code can take you far when you feed them plan.md 33
  23. tips: Creating Implementation Playbooks © LayerX Inc. Feature implementations often

    have standard procedures. It's recommended to document these as "implementation playbooks" For example, "adding a product usage flag for users" - a defined workflow Even when AI creates implementation plans, if many files are involved, things get missed in the plan, and humans don't remember what needs to be touched, leading to "it doesn't work" after implementation Creating this documentation becomes useful for humans too 34
  24. tips: Creating Implementation Playbooks Example: Adding a product usage flag

    for users © LayerX Inc. Writing from scratch is tedious for humans, so it's recommended to have AI document from a previously implemented Pull Request diff 35
  25. tips: Using git worktree What is git worktree ? A

    Git feature that allows you to work on multiple branches simultaneously in separate directories within a single repository Value explodes with CLI-based Claude Code: © LayerX Inc. CLI makes it easier to run in parallel, further increasing worktree value Run multiple Claude Code sessions in parallel for different branches 36
  26. tips: Using git worktree Wrote a wrapper script for git

    worktree and committed it to the repository for sharing © LayerX Inc. When using middleware like MySQL or LocalStack, you want to isolate data when adding worktrees Since MySQL and LocalStack run in docker, clone docker volumes at runtime and place docker-compose.override.yml in the worktree directory to use the cloned volumes for data isolation Of course, this script was also implemented by AI Coding Agent 37
  27. What is Roo Code? A Cline fork developed by an

    American veterinary staffing company Key features: Forget that it's a Cline fork (features in Cline don't automatically come to Roo Code) © LayerX Inc. Custom Modes: Unlike Cline's Plan/Act duo, users can define their own modes Orchestrator: A built-in mode that switches between other modes and executes subtasks Rapid Development: Exceptionally fast development speed with many experimental features 39
  28. Why Roo Code? © LayerX Inc. Orchestrator is convenient Breaks

    down large tasks into subtasks and executes them while switching to appropriate modes Fun with many experimental features Codebase Indexing Intelligent Context Condensing Concurrent File Reads Open development - if you have issues, contribute and implement it yourself feat: Add support for .roorules configuration files by upamune #2309 feat: enhance rule file loading with .roo/rules directory support by upamune #2354 40
  29. Using Roo Code's Custom Modes © LayerX Inc. Create specialized

    modes for different roles beyond Cline's Plan/Act Recently enabled YAML definitions (previously JSON only) 41
  30. Using Roo Code's Custom Modes Custom modes allow you to

    specify: © LayerX Inc. roleDefinition: Main role definition for the custom mode. Placed at the beginning of system prompt groups: Available tools (read, edit, browser, command) edit can specify allowed files with regex patterns customInstruction: Mode-specific rules. Placed later in system prompt whenToUse: Describes when to use this mode. Referenced especially by Orchestrator mode when switching 42
  31. Custom Mode Examples We Use ADR / Design Doc Writer

    Figma UI/Playwright UX Reviewer : Devin Instructor : © LayerX Inc. Instructs on internal ADR and Design Doc formats and perspectives to cover Figma UI review with defined personas Accessibility and usability review using Playwright Generates prompts for Devin (because writing prompts for Devin was tedious, so we have it generate nice ones) 43
  32. The Arrival of Claude Code © LayerX Inc. Started using

    it after Claude Sonnet 4 / Claude Opus 4 launched Using about $300-$400 per day Works well even without setting up rules As mentioned earlier, works quite well even in monorepos About 90% of things I thought "this vague instruction probably won't work..." actually worked Haven't had any major failures yet, so I haven't experienced disappointment - would love to hear about disappointing experiences 45
  33. New Current Challenges © LayerX Inc. With Claude Code's arrival,

    things work pretty well without much effort on rules/prompts Actually, our software engineers' excitement about Claude Code is greater than for any previous AI Coding Agent Code reviews have increased dramatically When I use AI Coding Agent, it's essentially code review, and others are also accelerating development with AI Coding Agents, speeding up PR creation Searching for good methods... Copilot Review, AI Coding Agent reviews, CodeRabbit, Greptile, etc... 47
  34. Summary © LayerX Inc. AI Coding Agent barriers can be

    solved with AI Coding Agents themselves Well-prepared context is an asset that transcends tools Have AI help prepare rules and workflows too Roo Code's appeal is customizable modes (especially the powerful Orchestrator mode) Claude Code's arrival produces decent output without excessive rule preparation If you haven't tried AI Coding Agents, start with the Pro plan ($20/month) and experience it! When starting seriously, I strongly recommend reading the official docs thoroughly Claude Code Overview 48