> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## Multiple contracts in one file

**Severity**: `Info`
**ID**: `multi-contract-file`

### What it does

Reports each top-level `contract`, `interface`, or `library` definition (after the first) in a
file that contains more than one such declaration.

### Why restrict this?

Keeping one contract per file can improve discoverability and make import paths predictable.
Closely related interfaces, helper contracts, or test fixtures can also be reasonable to group.
File organization alone does not add unrelated contracts to a deployed contract's bytecode.

### Example

```solidity
// File: Token.sol
contract TokenA { /* ... */ }
contract TokenB { /* ... */ }
```

Use instead:

```solidity
// File: TokenA.sol
contract TokenA { /* ... */ }

// File: TokenB.sol
contract TokenB { /* ... */ }
```

### Configuration

Set `multi_contract_file_exceptions` under `[lint.lint_specific]` in `foundry.toml` to allow
multiple interfaces, libraries, or abstract contracts in one file. Regular contracts cannot be
exempted.

```toml
[lint.lint_specific]
multi_contract_file_exceptions = ["interface", "library", "abstract_contract"]
```
