# Init Command

This guide explains how to use the DeepLint init command to set up DeepLint in your project.

## Overview

The `init` command initializes DeepLint in your project by creating a configuration file. This is typically the first command you'll run when setting up DeepLint for a new project.

The init command:

* Creates a configuration file in your project root
* Sets up default configuration options
* Prompts you for any required information

## Basic Usage

To initialize DeepLint in your project, run:

```bash
deeplint init
```

This will create a configuration file with default settings in your project root.

{% hint style="info" %}
By default, the init command creates a JavaScript configuration file (`deeplint.config.js`). You can specify a different format using the `--js` or `--yaml` flags.
{% endhint %}

## Command Options

The init command supports the following options:

```
OPTIONS
  --force, -f        Overwrite existing config    [default: false]
  --js               Create JavaScript config     [default: true]
  --yaml             Create YAML config           [default: false]
  --help, -h         Display help for this command
```

### --force, -f

The `--force` option allows you to overwrite an existing configuration file:

```bash
deeplint init --force
```

This is useful when you want to reset your configuration to the default values.

### --js

The `--js` option explicitly specifies that you want to create a JavaScript configuration file:

```bash
deeplint init --js
```

This is the default behavior, so you don't need to specify this option unless you want to be explicit.

### --yaml

The `--yaml` option specifies that you want to create a YAML configuration file:

```bash
deeplint init --yaml
```

This will create a `.deeplintrc.yml` file instead of a JavaScript configuration file.

## Command Aliases

The init command has the following aliases:

* **Full-Word Aliases**:
  * `initialize`: Initialize DeepLint in the current project
  * `create-config`: Create a DeepLint configuration file
* **Short Aliases**:
  * `i`: Initialize DeepLint in the current project

You can use any of these aliases instead of `init`:

```bash
deeplint initialize
deeplint create-config
deeplint i
```

## Examples

Here are some examples of using the init command:

{% tabs %}
{% tab title="Basic Initialization" %}

```bash
deeplint init
```

Creates a JavaScript configuration file (`deeplint.config.js`) with default settings.
{% endtab %}

{% tab title="Force Overwrite" %}

```bash
deeplint init --force
```

Overwrites an existing configuration file with default settings.
{% endtab %}

{% tab title="YAML Configuration" %}

```bash
deeplint init --yaml
```

Creates a YAML configuration file (`.deeplintrc.yml`) with default settings.
{% endtab %}

{% tab title="Using Aliases" %}

```bash
deeplint i
deeplint initialize
deeplint create-config
```

All of these commands do the same thing as `deeplint init`.
{% endtab %}
{% endtabs %}

## Configuration File

The init command creates a configuration file with default settings. Here's an example of the default configuration:

{% tabs %}
{% tab title="JavaScript (deeplint.config.js)" %}

```javascript
import { defineConfig } from "deeplint";

export default defineConfig({
  contextBuilder: {
    contextType: "light",
    maxTokens: 8000,
    tokensPerFile: 1000,
    maxFileSize: 500,
    includeDependencies: false,
    maxDependencyDepth: 1,
    includeStructure: true,
  },
  files: {
    include: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
    exclude: ["node_modules/**", "dist/**", "build/**"],
    useGitignore: true,
  },
  git: {
    includeUnstaged: false,
  },
  logging: {
    level: "info",
  },
});
```

{% endtab %}

{% tab title="YAML (.deeplintrc.yml)" %}

```yaml
contextBuilder:
  contextType: light
  maxTokens: 8000
  tokensPerFile: 1000
  maxFileSize: 500
  includeDependencies: false
  maxDependencyDepth: 1
  includeStructure: true

files:
  include:
    - "**/*.js"
    - "**/*.ts"
    - "**/*.jsx"
    - "**/*.tsx"
  exclude:
    - "node_modules/**"
    - "dist/**"
    - "build/**"
  useGitignore: true

git:
  includeUnstaged: false

logging:
  level: info
```

{% endtab %}
{% endtabs %}

## Troubleshooting

### Configuration File Already Exists

If a configuration file already exists, the init command will fail with an error:

```
ERROR: Configuration file already exists at /path/to/your/project/deeplint.config.js
```

To overwrite the existing configuration file, use the `--force` option:

```bash
deeplint init --force
```

### Permission Issues

If you don't have permission to write to the project directory, the init command will fail with an error:

```
ERROR: Permission denied: Could not write to /path/to/your/project/deeplint.config.js
```

Make sure you have write permission for the project directory.

## Next Steps

After initializing DeepLint, you can:

1. [Configure DeepLint](https://docs.deeplint.com/getting-started/configuration) for your project
2. [Run your first analysis](https://docs.deeplint.com/getting-started/first-run)
3. [Set up Git integration](https://docs.deeplint.com/getting-started/git-integration)

For more information about DeepLint's configuration options, see the [Configuration](https://docs.deeplint.com/getting-started/configuration) guide.
