πŸ“ Tutorials
Β· 5 min read

Build a Local AI Environment Configurator β€” Describe Your Project, Get Configs


Every new project starts with boilerplate: .env files, ESLint configs, Prettier settings, CI/CD pipelines, Docker configs. It takes hours to set up correctly. What if you could describe your stack and get everything configured?

In this tutorial, you’ll build an environment configurator that takes a project description and generates all the configuration files you need. No API keys, no cloud calls, everything runs on your machine.

How It Works

  1. You describe your project: β€œReact app with TypeScript, ESLint, and GitHub Actions”
  2. AI generates all configuration files
  3. You get .env, .eslintrc, .prettierrc, and CI/CD configs

Prerequisites

  • Ollama installed
  • Python 3.10+

Step 1: Pull the model

ollama pull qwen2.5-coder:7b

Step 2: Create the configurator

#!/usr/bin/env python3
"""AI environment configurator using Ollama."""

import subprocess
import sys
import json
import urllib.request
import os

OLLAMA_URL = "http://localhost:11434/api/generate"
MODEL = "qwen2.5-coder:7b"

CONFIG_TEMPLATES = {
    "env": """Generate a .env.example file for this project.

Project: {description}

Include:
1. Database connection strings
2. API keys (with placeholder values)
3. Port configurations
4. Feature flags
5. Debug/production settings
6. Comments explaining each variable

Output ONLY the .env.example content:""",

    "eslint": """Generate an ESLint configuration for this project.

Project: {description}
Framework: {framework}

Include:
1. Recommended rules for the framework
2. Custom rules for code quality
3. Import ordering
4. Unused variable detection
5. Consistent style rules

Output ONLY the .eslintrc.json content:"",

    "prettier": """Generate a Prettier configuration for this project.

Project: {description}

Include:
1. Standard formatting rules
2. Print width
3. Tab settings
4. Semicolons
5. Quote style
6. Trailing commas

Output ONLY the .prettierrc.json content:""",

    "github_actions": """Generate GitHub Actions CI/CD configuration.

Project: {description}
Language: {language}

Include:
1. Test workflow
2. Lint workflow
3. Build workflow
4. Deployment workflow (if applicable)
5. Caching for dependencies

Output the content for .github/workflows/ci.yml:"""
}


def generate_config(config_type, description, **kwargs):
    """Generate a configuration file."""
    template = CONFIG_TEMPLATES[config_type].format(
        description=description,
        **kwargs
    )

    payload = json.dumps({
        "model": MODEL,
        "prompt": template,
        "stream": False,
        "options": {"temperature": 0.3, "num_predict": 1500}
    }).encode()

    req = urllib.request.Request(
        OLLAMA_URL,
        data=payload,
        headers={"Content-Type": "application/json"}
    )

    with urllib.request.urlopen(req, timeout=60) as resp:
        response = json.loads(resp.read())["response"].strip()
        # Clean up response
        if response.startswith("```"):
            lines = response.split("\n")
            response = "\n".join(lines[1:-1])
        return response.strip()


def create_project_configs(project_dir, description, language="python", framework="none"):
    """Generate all configuration files for a project."""
    os.makedirs(project_dir, exist_ok=True)

    configs = {
        ".env.example": ("env", {}),
        ".eslintrc.json": ("eslint", {"framework": framework}),
        ".prettierrc.json": ("prettier", {}),
    }

    # Add CI/CD for specific languages
    if language in ["python", "javascript", "typescript"]:
        configs[".github/workflows/ci.yml"] = (
            "github_actions",
            {"language": language}
        )

    generated_files = []

    for filename, (config_type, extra_kwargs) in configs.items():
        print(f"Generating {filename}...")
        content = generate_config(config_type, description, **extra_kwargs)

        filepath = os.path.join(project_dir, filename)
        os.makedirs(os.path.dirname(filepath), exist_ok=True)

        with open(filepath, "w") as f:
            f.write(content)

        generated_files.append(filepath)
        print(f"  Created: {filepath}")

    return generated_files


if __name__ == "__main__":
    project_dir = input("Project directory [./my-project]: ").strip() or "./my-project"
    description = input("Describe your project: ")
    language = input("Primary language (python/javascript/typescript) [python]: ").strip() or "python"
    framework = input("Framework (react/nextjs/vue/express/none) [none]: ").strip() or "none"

    print(f"\nGenerating configurations for {project_dir}...")
    files = create_project_configs(project_dir, description, language, framework)

    print(f"\n{'=' * 60}")
    print(f"Generated {len(files)} configuration files:")
    for f in files:
        print(f"  - {f}")

    print(f"\nNext steps:")
    print(f"  1. Review and customize .env.example")
    print(f"  2. Copy .env.example to .env and fill in values")
    print(f"  3. Install dependencies")
    print(f"  4. Start developing!")

Step 3: Run it

python env_configurator.py

Example Session

Project directory [./my-project]: ./blog-api
Describe your project: Express.js REST API with PostgreSQL and Redis
Primary language (python/javascript/typescript) [python]: javascript
Framework (react/nextjs/vue/express/none) [none]: express

Generating configurations for ./blog-api...

Generating .env.example...
  Created: ./blog-api/.env.example
Generating .eslintrc.json...
  Created: ./blog-api/.eslintrc.json
Generating .prettierrc.json...
  Created: ./blog-api/.prettierrc.json
Generating .github/workflows/ci.yml...
  Created: ./blog-api/.github/workflows/ci.yml

============================================================
Generated 4 configuration files:
  - ./blog-api/.env.example
  - ./blog-api/.eslintrc.json
  - ./blog-api/.prettierrc.json
  - ./blog-api/.github/workflows/ci.yml

Next steps:
  1. Review and customize .env.example
  2. Copy .env.example to .env and fill in values
  3. Install dependencies
  4. Start developing!

What Gets Generated

FileWhat It Contains
.env.exampleEnvironment variables with placeholders
.eslintrc.jsonLinting rules for your framework
.prettierrc.jsonCode formatting settings
.github/workflows/ci.ymlCI/CD pipeline

The AI understands your stack and generates appropriate configurations:

  • React: JSX rules, hooks linting, import sorting
  • Express: Node.js best practices, async/await rules
  • Python: Type checking, import ordering, docstring rules

Limitations

  • Generated configs may need fine-tuning
  • Custom rules require manual addition
  • Some frameworks need specific plugins
  • CI/CD configs are basic templates

Real-World Use Cases

Startup teams. When starting a new project, the configurator generates all the boilerplate in seconds. The team can focus on features instead of tooling setup.

Consulting projects. For client projects, quickly generate standardized configurations that match your team’s standards.

Learning new frameworks. When trying a new framework, the configurator generates appropriate configs so you can focus on learning the framework, not the tooling.

Team standardization. Generate consistent configurations across multiple projects to ensure uniform code quality.

CI/CD setup. The generated GitHub Actions configs provide a starting point for continuous integration.

Tips for Better Configs

  1. Be specific about your stack. β€œReact with TypeScript and Tailwind” gives better results than β€œfrontend app.”
  2. Mention your tools. β€œUsing ESLint, Prettier, and Jest” generates configs for those tools.
  3. Include team preferences. β€œWe use 4-space indentation and single quotes” customizes the output.
  4. Review the CI/CD config. The generated pipeline is a starting point, not production-ready.

Variations

  • Docker configs: Generate Dockerfile and docker-compose.yml
  • VS Code settings: Generate .vscode/settings.json
  • Git hooks: Generate pre-commit and pre-push hooks
  • Test configs: Generate Jest, Pytest, or Go test configurations

My Take

This tool saves the 30-60 minutes you spend setting up each new project. The generated configs are good starting points that cover 80% of what you need. The remaining 20% is project-specific customization.

Rating: 7.5/10 β€” Good for standard projects. Custom setups still need manual work.

FAQ

How accurate are the generated configs?

Very accurate for standard stacks. The AI understands common patterns and generates appropriate configurations. For specialized setups, review and adjust.

Can I add custom config files?

Yes. Add new entries to the CONFIG_TEMPLATES dictionary with your custom template.

Does this work with any framework?

The basic templates work with most frameworks. For framework-specific rules, modify the prompts to include framework details.

Can I use this for existing projects?

Yes. Point it at your project directory and it will generate configs. Existing files will not be overwritten.

Related: ESLint Best Practices Β· GitHub Actions Tutorial Β· Ollama Complete Guide