Vibe Coding: From Natural Language to Runnable Scripts

    Vibe Coding lets users describe a task in natural language and use AI coding tools to generate an initial implementation, which is then inspected, run, and revised into a working solution. Using a CSV email-cleaning task as an example, this article explains the workflow, reviews a generated Python script, and discusses code review, validation, and the boundaries of responsible use.

    Many repetitive tasks are not difficult, yet they often consume a large amount of time. For example, a business user receives a CSV file from mixed sources containing malformed email addresses, duplicate records, blank lines, and irrelevant fields. In the past, this kind of task might require manual filtering or waiting for a developer to write a one-off script. Today, with natural-language-driven AI coding tools, people who are not familiar with code can also participate in building automated processing workflows.

    “Vibe Coding” does not mean letting a tool write code without any thinking. It means first describing the goal in near-conversational language, then having an AI coding tool generate an initial implementation, and finally checking, running, and correcting it to form an executable solution. It lowers the entry point for programming, but it does not remove the importance of requirements analysis, quality validation, and risk control.

    1. A Typical Data Cleaning Task

    Suppose the original file is named contacts.csv and has the following problems:

    • The email field contains empty values;
    • Some addresses lack the required structure, such as an “@” symbol;
    • The same email appears multiple times;
    • Letter casing is inconsistent;
    • Emails have leading or trailing spaces or invisible characters;
    • The file may contain other fields such as name and department.

    The traditional approach is usually to open the spreadsheet and check it row by row, then use filtering and duplicate-finding features. This works for small datasets, but when the file reaches tens of thousands of rows, manual work is easy to miss, and similar tasks must be repeated each time.

    A more efficient approach is to state the requirements clearly first, for example:

    “Read a CSV file, find the email field, trim leading and trailing spaces, convert emails to lowercase, filter out entries that clearly fail basic format rules, remove duplicate emails while keeping the first occurrence, and output a cleaned file plus the total number of valid emails. For rows that cannot be recognized, record the reason instead of silently deleting them.”

    This description is more precise than “help me process the emails” because it specifies the input, processing rules, output, and exception handling requirements at the same time.

    2. Basic Flow of Generating Code from Natural Language

    AI coding tools can usually generate a script based on the description above. The core logic of the script generally includes the following steps:

    1. Read the CSV file;
    2. Check whether the target field exists;
    3. Clean the field values as strings;
    4. Use basic rules to determine whether the format is reasonable;
    5. Deduplicate using a consistent form;
    6. Output a new CSV file;
    7. Count the number of valid records;
    8. Generate records for exceptions or a processing log.

    The following is an illustrative code sample, focused on explaining the processing approach:

    1. import csv
    2. import re
    3. email_pattern = re.compile(
    4. r"^[^@\s]+@[^@\s]+\.[^@\s]+$"
    5. )
    6. valid_rows = []
    7. invalid_rows = []
    8. seen = set()
    9. with open("contacts.csv", "r", encoding="utf-8-sig", newline="") as source:
    10. reader = csv.DictReader(source)
    11. if "email" not in (reader.fieldnames or []):
    12. raise ValueError("The CSV file does not contain an email field")
    13. for line_number, row in enumerate(reader, start=2):
    14. raw_email = row.get("email", "")
    15. email = raw_email.strip().lower()
    16. if not email_pattern.match(email):
    17. invalid_rows.append({
    18. "line": line_number,
    19. "email": raw_email,
    20. "reason": "Does not match basic format rules"
    21. })
    22. continue
    23. if email in seen:
    24. invalid_rows.append({
    25. "line": line_number,
    26. "email": raw_email,
    27. "reason": "Duplicate record"
    28. })
    29. continue
    30. seen.add(email)
    31. row["email"] = email
    32. valid_rows.append(row)
    33. fieldnames = reader.fieldnames
    34. with open("cleaned_contacts.csv", "w", encoding="utf-8", newline="") as target:
    35. writer = csv.DictWriter(target, fieldnames=fieldnames)
    36. writer.writeheader()
    37. writer.writerows(valid_rows)
    38. with open("rejected_records.csv", "w", encoding="utf-8", newline="") as target:
    39. writer = csv.DictWriter(
    40. target,
    41. fieldnames=["line", "email", "reason"]
    42. )
    43. writer.writeheader()
    44. writer.writerows(invalid_rows)
    45. print(f"Valid email count: {len(valid_rows)}")
    46. print(f"Invalid or duplicate record count: {len(invalid_rows)}")

    This code can complete basic data cleanup, but it does not mean every email can be accurately verified. A regular expression can only check the form; it cannot confirm whether an email actually exists or whether the target domain can receive mail. Therefore, when generating code, it is necessary to distinguish between “format validation” and “deliverability verification.”

    3. Why This Approach Saves Significant Time

    The value of automation is not only faster execution. More importantly, it turns one-time labor into a repeatable process.

    First, processing rules can be fixed. As long as the file field structure is similar, the script can be reused, avoiding repeated filtering each time.

    Second, results are more consistent. Manual processing may vary due to fatigue, attention, or personal habits, while a program executes according to fixed rules.

    Third, exceptions can be recorded. A reliable process should not simply delete problematic data. It should preserve exception line numbers, original values, and processing reasons for review.

    Fourth, the code can be extended further. For example, it can add functions such as merging multiple input files, classifying by domain, counting department distribution, and generating summary reports.

    For people who are not familiar with programming, the most direct change is that mechanical work that used to take hours may be compressed into minutes. However, “completed in minutes” does not mean “safe to deliver in minutes.” Follow-up validation is still essential.

    4. Code Review Cannot Be Skipped

    Code generated from natural language may contain logic gaps. Before use, at least the following items should be checked.

    1. Whether the input file is read correctly

    Confirm that the file encoding, delimiter, column names, and header match expectations. Some files may use a different encoding, or column names may contain spaces. If field names are inconsistent, the script may fail directly or even read the wrong data.

    2. Whether the deduplication rule meets business requirements

    “Duplicate” may have different definitions. Is the comparison based only on email, or on email plus name? If two contacts use the same email but belong to different departments, should both rows be kept? These questions must be clarified before running the script.

    3. Whether data is accidentally overwritten

    It is recommended to write cleaning results to a new file rather than directly overwriting the original file. The original data should be backed up so that it can be restored and compared if problems occur.

    4. Whether exception data is traceable

    Filtered data should be saved in a separate file with reasons noted. Otherwise, business users cannot tell whether data was correctly cleaned or mistakenly deleted by the program.

    5. Whether large files cause resource problems

    Loading all data into memory at once is suitable for small and medium-sized files. For very large files, use line-by-line processing and batch writing to avoid excessive memory usage.

    5. Proper Validation Methods

    After running the script, do not rely only on the counts displayed in the terminal. Sample checks should also be performed.

    First, prepare a small sample with known results, intentionally including valid addresses, obviously invalid addresses, case differences, spaces, and duplicates, then check whether the script output matches expectations.

    Then, verify the following metrics:

    • Whether the total input rows equal the sum of valid rows, invalid rows, blank lines, and other special cases;
    • Whether the output file can be opened normally;
    • Whether valid emails still contain duplicates;
    • Whether all email fields have been uniformly formatted;
    • Whether the original file and result file preserve the necessary other fields;
    • Whether the number of exception records matches expectations.

    If the results are abnormal, continue asking the AI coding tool specific questions. For example, “Why wasn’t an email with leading and trailing spaces recognized as a duplicate?” is more likely to produce an effective correction than simply saying “the code is wrong.”

    6. Boundaries of Vibe Coding

    Natural language programming is suitable for tasks with clear rules, controllable risk, and easily verifiable results, such as format conversion, file organization, data statistics, and simple report generation.

    However, extra caution is needed in the following scenarios:

    • Personal information, financial data, or sensitive business data is involved;
    • The script will batch delete, modify, or overwrite important files;
    • The code needs to access production systems;
    • The task involves permissions, authentication, or security policies;
    • The results directly affect customers, employees, or business decisions;
    • There is no verifiable standard for correctness.

    In these cases, AI tools can assist in generating code and explaining the approach, but they cannot replace professional review, testing, and approval.

    7. From “Describing” to “Owning Responsibility”

    What Vibe Coding truly changes is not making everyone a programmer immediately, but enabling more people to translate business problems into executable technical tasks. High-quality use should include:

    1. Clarify goals and boundaries first;
    2. Specify input formats and output requirements;
    3. List exceptions and handling rules;
    4. Ask the tool to explain key code;
    5. Test with a small sample;
    6. Preserve original data and processing logs;
    7. Accept results through sampling and statistical checks;
    8. Apply desensitization and access control to sensitive data.

    Therefore, a data cleaning task that seems to have “no technical content” may look like simply copying and running a script, but it actually involves requirement expression, rule design, result validation, and risk management. AI coding tools can greatly reduce implementation costs, but what ultimately determines result quality is still whether the user can ask accurate questions and take responsibility for validating the final output.