Devin CLI Implementation

Devin CLI token optimization including Skills vs Rules preferences, Playbook workflows, and lazy-loading mechanics

Token Optimization Guide / Devin CLI Implementation

Devin CLI Token Optimization

Layer 1 β€” Platform Mechanics

Devin’s own documentation is explicit here: prefer Skills over Rules/AGENTS.md wherever possible, because Skills load only when relevant while Rules and AGENTS.md load into every session regardless. Keep AGENTS.md deliberately small and use it mainly to point at which Skill applies to which scenario. Rules below the project root are lazily discovered β€” only pulled into context when the agent actually touches files in that directory β€” so scope project-specific detail to the narrowest directory that needs it.

Key Strategies:

  • Skills Over Rules: Prefer Skills (load on-demand) over Rules/AGENTS.md (always load)
    • Skills load only when relevant to task
    • Rules/AGENTS.md load into every session
    • Keep AGENTS.md deliberately small
  • Lazy-Loading Mechanics: Rules below project root are lazily discovered
    • Only loaded when agent touches files in that directory
    • Scope project-specific detail to narrowest directory
    • Reduces unnecessary context loading
  • Pointer Pattern: Use AGENTS.md to point at Skills
    • “Use Skill X for scenario Y”
    • Keep actual instructions in Skills
    • Minimize always-loaded content

Layer 2 β€” Agent Operation

Turn recurring multi-step workflows into Playbooks (.devin.md files with Procedure / Specifications / Advice / success criteria / guardrails) instead of re-explaining the same task in prose every time. This is Devin’s core use case for general software engineering, not just documentation β€” dependency upgrades, ticket-to-PR, database migrations, and repeated scaffolding all fit the same pattern; a docs-build check is one narrow instance of it, not the norm. Devin CLI’s built-in duplicate-prompt detection (hashes your last 50 prompts) catches accidental re-runs before they burn ACUs twice. Use --json plus a dedicated --profile service for CI-style automation.

Operational Best Practices:

  • Playbook Workflows: Convert recurring workflows to Playbooks
    • .devin.md files with structured format
    • Procedure / Specifications / Advice / success criteria / guardrails
    • Applicable to general software engineering, not just docs
    • Examples: dependency upgrades, ticket-to-PR, database migrations
  • Duplicate-Prompt Detection: Built-in protection against re-runs
    • Hashes last 50 prompts
    • Catches accidental re-runs before they burn ACUs
    • Automatic cost control
  • CI/Scripted Operations: Use --json + --profile service
    • Dedicated service profile for automation
    • JSON output for programmatic consumption
    • Optimized for non-interactive workflows

Layer 3 β€” Codebase Architecture

Deliver the Conventions content via AGENTS.md (auto-read), or promote it into Devin’s cloud-side Knowledge if you want it to persist without being re-read from a file each session.

Architecture Rules:

  • AGENTS.md Delivery: Use AGENTS.md for architecture rules
    • Auto-read by Devin CLI
    • Shared with other tools
    • Keep consistent across codebase
  • Cloud-Side Knowledge: Alternative for persistent rules
    • Promote to Devin’s cloud-side Knowledge
    • Persists without file re-reading
    • Useful for org-wide standards

Devin CLI-Specific Features

Playbooks

Devin’s Playbook system (.devin.md files) provides structured workflow automation:

  • Structured Format: Procedure / Specifications / Advice / success criteria / guardrails
  • General Applicability: Not just documentation β€” applies to all software engineering workflows
  • Cost Optimization: Avoid re-explaining same task in prose repeatedly
  • Workflow Types: Dependency upgrades, ticket-to-PR, database migrations, scaffolding

Practical Playbook Example

dependency-upgrade.devin.md - Dependency Upgrade Playbook

---
name: "Dependency Upgrade"
description: "Identify outdated dependencies, upgrade them incrementally by risk group, and open one PR per group with passing tests."
---

## Procedure

1. Read the current dependency manifest (`package.json` / `requirements.txt`
   / `go.mod` / equivalent) to establish a baseline.
2. Identify outdated packages using the ecosystem's standard tool
   (`npm outdated`, `pip list --outdated`, `go list -u -m all`).
3. Group upgrades by risk: patch/minor versions together, each major
   version bump on its own.
4. Upgrade one group at a time β€” never all packages in a single commit.
5. Run the full test suite after each group; stop and report if any group
   introduces a failure rather than continuing to the next group.
6. Open one PR per package group, including a changelog/diff summary for
   anything bumped a major version.

## Specifications

- Package manager: [npm / pip / go modules / etc.]
- Test command: [test command]
- Do not upgrade [pinned/frozen packages β€” e.g. a security-patched fork]
  without explicit instruction.

## Advice

- A major-version bump with no resulting test failure is not
  automatically safe β€” check the package's changelog for breaking
  changes your test suite might not cover (removed CLI flags, changed
  defaults, dropped platform support).
- If a lockfile conflict appears, resolve it by re-running install, not
  by hand-editing the lockfile.
- Treat transitive dependency bumps (pulled in by a direct upgrade) as
  part of the same risk group, not a separate one.

## Success criteria

- Each PR upgrades exactly one risk group.
- Full test suite passes after each group's upgrade.
- No files outside the manifest, lockfile, and code needed for
  compatibility are changed.

## Guardrails

- Never upgrade a dependency pinned for a documented reason β€” check
  comments and CHANGELOG entries first.
- Open the PR and stop; do not merge. A human approves and merges.
- Stop and escalate if more than [N] packages in a group fail at once β€”
  don't attempt to fix unrelated failures to force a group through.

Key Pattern: The Playbook captures the entire workflow structure once, eliminating the need to re-explain the same process in prose every time. This is Devin’s core strength for recurring software engineering tasks.

Lazy-Loading Rules

Devin’s lazy-loading mechanism for rules below project root:

  • On-Demand Loading: Rules only load when agent touches files in that directory
  • Directory Scoping: Scope project-specific detail to narrowest directory
  • Cost Reduction: Reduces always-loaded token overhead
  • Context Precision: Only relevant rules enter context

Skills System

Devin’s own documentation explicitly prefers Skills over Rules:

  • Load-On-Demand: Skills only load when relevant
  • Reduced Overhead: Unlike Rules, Skills don’t load into every session
  • Task-Specific: Ideal for domain knowledge and procedures
  • Organization: Better organization of capabilities

Duplicate-Prompt Detection

Built-in protection against wasteful re-runs:

  • Hash-Based Detection: Hashes last 50 prompts
  • Automatic Prevention: Catches accidental re-runs
  • Cost Control: Prevents burning ACUs on duplicate work
  • Transparent: Operates automatically without user intervention

Profile System

Devin’s profile system supports different operational modes:

  • Service Profile: Dedicated profile for CI/automation
  • Interactive Profile: Full capabilities for daily development
  • JSON Output: --json flag for programmatic consumption
  • Cost Optimization: Different profiles for different cost constraints

Interactive Tools

Practical tools to help you think systematically, build better AI agents, and master prompt engineering.

Software Engineering Playbooks

Practical, End-to-End implementation guides for building Production-ready Software. Each playbook includes working code, architecture diagrams, and step-by-step instructions.

πŸ€–

Research Agent with Gateway

Build a production-ready AI research agent using Agent Gateway for unified traffic management, authentication, and observability across LLM providers.

Agent Gateway A2A Protocol Multi-Agent
πŸ”—

RAG Pipeline with Vector Database

Implement a complete Retrieval-Augmented Generation pipeline with vector embeddings, semantic search, and context injection for accurate AI responses.

RAG Vector DB Embeddings
πŸ”„

Multi-Agent Orchestration

Create a coordinated multi-agent system with specialized agents, task distribution, and result synthesis for complex problem-solving.

Orchestration Task Distribution Synthesis
1 / 2

Future References

Explore these resources for deeper learning on AI agent development, spec-driven development, and prompt engineering tools.

Spec-Driven Development

Comprehensive guide on Spec-Driven Development practices and methodologies.

Awesome Copilot

Curated list of GitHub Copilot resources, extensions, and best practices.

Promptfoo

Tool for testing, evaluating, and improving LLM prompts and applications.

Prompts.chat

Collection of prompt engineering resources and templates.

Agent Skills

Agent skills resources and documentation for building AI agent skills.

Awesome Skills

Curated list of awesome skill repositories and collections.

Agent Skills Topic

GitHub topic for discovering agent-related skills and repositories.

AI Agent Topic

Trendshift topic for discovering AI agents.

AI Skills Topic

Trendshift topic for discovering AI skills.

Agent Governance Toolkit

Agent governance toolkit.

Pattern Sources

Our patterns are curated from industry-leading sources with proper attribution and licensing compliance.

Refactoring.Guru

Classic GoF design patterns, code smells catalog, and refactoring techniques (https://refactoring.guru).

Enterprise Integration Patterns

65 messaging patterns for integrating enterprise applications by Gregor Hohpe and Bobby Woolf (CC BY 4.0).

Microservices.io

Comprehensive patterns for microservice architectures by Chris Richardson.

Agent Catalog Patterns

Patterns for agentic systems from agentpatternscatalog.org (CC BY 4.0).

OWASP Foundation

Security patterns from OWASP Top 10 for Web Applications, LLM Applications, and Agentic Applications (CC BY-SA 4.0).

Industry Research

ML/AI patterns from Microsoft, Google, Anthropic, and academic research.

AI Agent Patterns

Spec-driven development patterns from Claude, Gemini, OpenAI, and GitHub Copilot on github/spec-kit and OpenSpec.

Data Engineering Leaders

Data platform patterns from Martin Fowler (Data Mesh), Kimball Group (Dimensional Modeling), and cloud providers.

MLOps Best Practices

Data science patterns from MLflow, Great Expectations, and MLOps practitioners.

Streaming & Analytics

Real-time patterns from Confluent/Kafka, Apache projects, and serverless analytics platforms.

Academic Papers

Rigorous ML patterns from peer-reviewed research including data leakage prevention and active learning.

5-Day AI Agents Course

Intensive Vibe Coding Course With Google by Brenda Flynn et al. (2026) on Kaggle.

The Agent Loop

Foundational Agent Definition (Perceive + Act):
Russell, S. J., & Norvig, P. (1995). Artificial Intelligence: A Modern Approach. Prentice Hall. (Current edition: 4th Ed., Pearson, 2020)

Modern Iterative LLM Agent Loop:
Yao, S., Zhao, J., Yu, D., et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629.

Historical Context:
Incorporating AIMA's perceive/act model, Classical robotics' Sense-Plan-Act loop (Brooks, 1986), and ReAct's Thought→Action→Observation cycle.