Suggest and apply code refactoring patterns — simplify complex code, extract functions, reduce duplication, improve naming, and modernize syntax.