agentleFS
hiromailyhiromaily/go-crypto-wallet/.cursor/rules/internal/clean-architecture.mdc

go-crypto-wallet / internal

Cursor rule128 starsChanged 6 months agoMITView on GitHub

Clean Architecture Rules

We split this clean-architecture.mdc into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When editing files, verify imports follow the dependency direction:

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
clean-architecture.mdc
---
description: Clean Architecture Rules
globs: ["internal/**/*.go"]
alwaysApply: false
---


# Clean Architecture Rules

## Overview

Rules for maintaining Clean Architecture layer separation in the `internal/` directory.

## Dependency Direction

**CRITICAL**: Dependencies must flow in ONE direction only:

```text
Interface Adapters → Application Layer → Domain Layer ← Infrastructure Layer
```

### Layer Dependencies

| Layer | Can Import From | Cannot Import From |
|-------|-----------------|-------------------|
| Domain | (none) | application, infrastructure, interface-adapters |
| Application | domain | infrastructure, interface-adapters |
| Infrastructure | domain, application/ports, application/dto | application/usecase, interface-adapters |
| Interface Adapters | application | domain, infrastructure |

## Violations to Avoid

- Domain importing from infrastructure
- Application importing from infrastructure directly (use interfaces)
- Application importing from interface-adapters
- Infrastructure importing from application/usecase
- Interface-adapters importing from infrastructure or domain directly

## Quick Checks

When editing files, verify imports follow the dependency direction:

```go
// internal/domain/**/*.go
// ❌ NEVER import these:
import "github.com/hiromaily/go-crypto-wallet/internal/infrastructure/..."
import "github.com/hiromaily/go-crypto-wallet/internal/application/..."

// internal/application/usecase/**/*.go
// ❌ NEVER import these:
import "github.com/hiromaily/go-crypto-wallet/internal/infrastructure/..."
import "github.com/hiromaily/go-crypto-wallet/internal/interface-adapters/..."

// internal/interface-adapters/**/*.go
// ❌ NEVER import these:
import "github.com/hiromaily/go-crypto-wallet/internal/infrastructure/..."
import "github.com/hiromaily/go-crypto-wallet/internal/domain/..."
```

## Related Rules

- @.claude/rules/internal/domain-layer.md - Domain layer specifics
- @.claude/rules/internal/application-layer.md - Application layer specifics
- @.claude/rules/internal/infrastructure-layer.md - Infrastructure layer specifics
- @.claude/rules/internal/interface-adapters-layer.md - Interface adapters layer specifics
- @.claude/rules/go/conventions.md - Go conventions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.