Effective AI Prompting
Clear, specific prompts yield better results. The AI responded well to detailed requirements about template processing and CLI interfaces.
Template Processor & AI Development Study - A practical Rust CLI application for processing templates with variable substitution, developed as a case study in AI-assisted development workflows.
The Template Processor is a practical Rust CLI application that processes Markdown templates with variable substitution. While the core functionality is straightforward template processing, the project serves as a comprehensive case study in AI-assisted development, having been built using AI assistance (specifically Ollama with qwen2.5-coder:14b via Avante in Neovim).
The project explores:
The application processes Markdown templates with variable substitution:
# Generate a document from templatecargo run -- \ -o output.md \ -t templates/default.md \ -v title="My Document" \ -v introduction="This is an example document."Templates use simple variable substitution syntax:
# {{title}}
{{introduction}}
## Details
This document was generated on {{date}}.This project was developed using Ollama with qwen2.5-coder:14b via the Avante plugin in Neovim. The AI assisted with:
// AI-generated: Basic CLI application structure#[derive(Parser)]#[command(name = "file-generator")]#[command(about = "Generate files from templates with variable substitution")]struct Args { /// Output file path #[arg(short, long)] output: PathBuf,
/// Template file path #[arg(short, long)] template: PathBuf,
/// Variable assignments (key=value) #[arg(short = 'v', long, value_parser = parse_key_value)] variables: Vec<(String, String)>,}// AI-generated: Core template processing functionfn process_template(content: &str, variables: &HashMap<String, String>) -> Result<String, anyhow::Error> { let mut result = content.to_string(); for (key, value) in variables { let placeholder = format!("{{{{{}}}}}", key); result = result.replace(&placeholder, value); } Ok(result)}serde_json dependency and used deprecated error handlingHere are specific instances where AI assistance was used in developing this documentation site:
// AI helped generate this sidebar structure{ label: 'Repositories', items: [ { label: 'Overview', slug: 'repositories' }, { label: 'Fretsome', slug: 'repositories/fretsome' }, { label: 'Robot Arm', slug: 'repositories/robot-arm' }, // ... additional items ]}// AI suggested this error handling approachfn process_template(content: &str, variables: &HashMap<String, String>) -> Result<String, anyhow::Error> { // Implementation with proper error propagation}AI assisted in creating consistent documentation patterns across all repository pages, including:
Effective AI Prompting
Clear, specific prompts yield better results. The AI responded well to detailed requirements about template processing and CLI interfaces.
Iterative Refinement
AI-generated code often needs human review and iteration. Dependencies and deprecated patterns required manual fixes.
Quality Validation
AI can produce functional code quickly, but human oversight ensures correctness, security, and best practices.
Workflow Integration
Tools like Avante make AI assistance seamless within existing development environments like Neovim.
[dependencies]clap = { version = "4.0", features = ["derive"] } # CLI argument parsingserde_json = "1.0" # JSON handlinganyhow = "1.0" # Error handling#[derive(Parser)]#[command(author, version, about)]struct Args { /// Output file path #[arg(short, long)] output: PathBuf,
/// Template file path #[arg(short, long)] template: PathBuf,
/// Variable assignments (key=value) #[arg(short = 'v', long, value_parser = parse_key_value)] variables: Vec<(String, String)>,}fn process_template(template: &str, variables: &HashMap<String, String>) -> String { let mut result = template.to_string(); for (key, value) in variables { let placeholder = format!("{{{{{}}}}}", key); result = result.replace(&placeholder, value); } result}Initial Prompting
Create a Rust CLI application that processes templates with variable substitutionIterative Refinement
Testing & Validation
file-generator/├── src/│ └── main.rs # CLI application logic├── templates/│ └── default.md # Sample template├── Cargo.toml # Project dependencies├── Cargo.lock # Dependency lock file└── README.md # Usage documentationanyhow# Create a blog postcargo run -- \ -o blog-post.md \ -t templates/blog.md \ -v title="My First Post" \ -v author="Ryan Parsley" \ -v date="2025-01-15"# Generate a config filecargo run -- \ -o config.json \ -t templates/config.json \ -v app_name="my-app" \ -v port="8080" \ -v debug="true"This project welcomes contributions in: