Project Development

Clarinet streamlines the entire lifecycle of Clarity smart contract development. From project initialization to contract management and code formatting, you'll have the tools needed for professional workflows.

Creating a new project

The clarinet new command creates a complete project structure with all necessary configuration files:

$ clarinet new my-defi-app
Option
Description
Example

--disable-telemetry

Opt out of telemetry collection

clarinet new my-app --disable-telemetry

For a deeper look at what Clarinet generates, see the project structure guide.

Managing contracts

Creating new contracts

The clarinet contract new command generates both a contract file and a matching test file:

$ clarinet contract new token
Created file contracts/token.clar
Created file tests/token.test.ts
Updated Clarinet.toml

The generated contract includes a minimal template:

;; token
;; <add a description here>

;; constants
;;

;; data vars
;;

;; data maps
;;

;; public functions
;;

;; read only functions
;;

;; private functions
;;

Removing contracts

Clean up unused contracts with the rm command:

Checking project contract syntax

Validate your entire project setup:

Check specific contracts:

Code formatting

Clarinet includes a formatter to maintain consistent style across your project.

Format all contracts in your project:

Formatting options

Customize formatting to match your team's style guide:

Option
Description
Example

--dry-run

Preview changes without modifying files

clarinet format --dry-run

--in-place

Replace file contents (required for actual formatting)

clarinet format --in-place

--max-line-length

Set maximum line length

clarinet format --max-line-length 100

--indent

Set indentation size

clarinet format --indent 2

--tabs

Use tabs instead of spaces

clarinet format --tabs

Format single files

Format specific contracts with glob patterns:

Project configuration

Working with requirements

Add mainnet contracts as dependencies:

Clarinet adds the dependency to Clarinet.toml:

You can now implement traits from mainnet contracts:

Last updated

Was this helpful?