A CLI and Android Studio plugin for generating Clean Architecture boilerplate.
Android Studio Plugin | CLI | |
---|---|---|
New Clean Architecture project | ✔️ | ✔️ |
Generate Architecture package | ✔️ | ✔️ |
Generate a new feature | ✔️ | ✔️ |
Generate a use case | ✔️ | ✔️ |
Generate a ViewModel | ✔️ | ✔️ |
Generate a data source | ✔️ | ✔️ |
Automatic git staging | ✔️ | ✔️ |
Configurable | ✔️ | ✔️ |
Inline inspections | ✔️ | ❌️ |
Android Studio Plugin is available on the IDE Plugins Marketplace.
Terminal command is available via Homebrew.
Adds multiple time-saving code generation shortcuts to Android Studio.
Navigate to File
> New
> New Project...
and select the Clean Architecture template.
Right-click on relevant directories and expand the New
menu item.
Settings are available under Tools
> Clean Architecture
.
For a working project example, visit Clean Architecture For Android.
Work out of the box. You can disable any or all inspections via Android Studio's settings.
Generates Clean Architecture Android code from your terminal.
- Install via Homebrew:
brew tap EranBoudjnah/cag
brew install EranBoudjnah/cag/cag
- Run via installed script:
./gradlew :cli:installDist
"./cli/build/install/cag/bin/cag" --new-feature --name=MyFeature
"./cli/build/install/cag/bin/cag" --new-view-model --name=MyViewModel
- Run via Gradle (no install):
./gradlew :cli:run --args="--new-feature --name=MyFeature"
./gradlew :cli:run --args="--new-view-model --name=MyViewModel"
Usage (canonical):
cag [--new-project --name=ProjectName --package=PackageName [--no-compose] [--ktlint] [--detekt] [--ktor] [--retrofit]]... [--new-architecture [--no-compose] [--ktlint] [--detekt]]... [--new-feature --name=FeatureName [--package=PackageName]]... [--new-datasource --name=DataSourceName [--with=ktor|retrofit|ktor,retrofit]]... [--new-use-case --name=UseCaseName [--path=TargetPath]]... [--new-view-model --name=ViewModelName [--path=TargetPath]]...
- Full reference:
cag --help
- Topic help:
cag --help --topic=new-feature
orcag --help -t new-use-case
- Man page:
man cag
(see Manual page (optional) below for generating/installing locally)
# Generate a new project
cag --new-project --name=MyApp --package=com.example.myapp
# Add architecture to an existing project/module
cag --new-architecture --ktlint --detekt
# Add a new feature
cag --new-feature --name=Profile --package=com.example.feature.profile
# Add a data source with Retrofit
cag --new-datasource --name=User --with=retrofit
# Add a use case
cag --new-use-case --name=FetchUser --path=architecture/domain/src/main/kotlin
# Add a ViewModel
cag --new-view-model --name=Profile
If you prefer to use man
to read your documentation, this section is for you.
# Generate man page (writes cli/build/man/cag.1)
./gradlew :cli:generateManPage
# Install to a man1 directory (may require sudo for system directories)
./gradlew :cli:installManPage
# Preview after install
man cag
You can configure library and plugin versions used by the CLI via a simple INI-style config file named .cagrc
.
-
Locations:
- Project root:
./.cagrc
- User home:
~/.cagrc
- Project root:
-
Precedence:
- Values in the project
.cagrc
override values in~/.cagrc
.
- Values in the project
-
Sections:
[new.versions]
— applied when generating new projects (e.g.,--new-project
).[existing.versions]
— applied when generating into an existing project (e.g., new architecture, feature, data source, use case, or view model).
-
Keys correspond to version keys used by the generator, for example:
kotlin
,androidGradlePlugin
,composeBom
,composeNavigation
,retrofit
,ktor
,okhttp3
, etc.
Example ~/.cagrc
:
[new.versions]
kotlin=2.2.10
composeBom=2025.08.01
[existing.versions]
retrofit=2.11.0
ktor=3.0.3
Example ./.cagrc
(project overrides):
[new.versions]
composeBom=2025.09.01
[existing.versions]
okhttp3=4.12.0
With the above, new projects will use composeBom=2025.09.01
(from project), kotlin=2.2.10
(from home). For operations on existing projects, retrofit=2.11.0
(home) and okhttp3=4.12.0
(project) will be applied.
Contributions to this project are welcome. Learn about contributing.
Reach out to me via my profile page.